this means we can skip over dids we don't care about without parsing JSON *AND* we get good lexicographic sorting of log files (which will be useful for more complex compaction later)
19 lines
494 B
TypeScript
19 lines
494 B
TypeScript
import { ensureDir } from "jsr:@std/fs@1";
|
|
|
|
import { ExportEntry } from "./directory-tailer.ts";
|
|
|
|
await ensureDir("./data/plc/live");
|
|
|
|
export async function writeLiveRecord(entry: ExportEntry, raw: string) {
|
|
const didplc = "did:plc:".length;
|
|
const prefix = entry.did.substring(didplc, didplc + 2);
|
|
const out = "./data/plc/live/" + prefix;
|
|
|
|
await Deno.writeTextFile(
|
|
out,
|
|
[entry.did, entry.createdAt, entry.cid, raw].join("\u001f") + "\n",
|
|
{
|
|
append: true,
|
|
}
|
|
);
|
|
}
|