Deployment monitoring and recovery tooling
This commit is contained in:
@@ -41,6 +41,7 @@ export class Ledger {
|
||||
private readonly pow: PowEngine;
|
||||
private closed = false;
|
||||
private revision = 0;
|
||||
private reorgs = 0;
|
||||
private canonicalCache: { tip: string; blocks: TestnetBlock[] } | undefined;
|
||||
private constructor(file: string, db: DatabaseSync, pow: PowEngine) { this.file = file; this.db = db; this.pow = pow; }
|
||||
|
||||
@@ -148,6 +149,9 @@ export class Ledger {
|
||||
}
|
||||
|
||||
get size(): number { return this.nodes.size; }
|
||||
diagnostics() { const createdAt=this.nodes.get(this.tip)?.block.createdAt??null;
|
||||
return { height:this.height(), dagBlocks:this.size, pending:this.pending.length, mutationQueue:this.queued,
|
||||
reorgsSinceStartup:this.reorgs,tipCreatedAt:createdAt,tipAgeSeconds:createdAt===null?null:Math.max(0,Date.now()/1000-createdAt) }; }
|
||||
get allBlocks(): TestnetBlock[] {
|
||||
const rows = this.db.prepare('SELECT block_json FROM blocks ORDER BY sequence').all() as { block_json: string }[];
|
||||
return rows.map(row => blockSchema.parse(JSON.parse(row.block_json)));
|
||||
@@ -191,6 +195,7 @@ export class Ledger {
|
||||
await this.persist(node.block, pending);
|
||||
this.nodes.set(node.block.hash, node);
|
||||
if (wins) this.tip = node.block.hash;
|
||||
if (disconnected.length) this.reorgs++;
|
||||
this.pending = pending;
|
||||
if (filtered) this.pendingState = filtered.state;
|
||||
this.revision++;
|
||||
|
||||
Reference in New Issue
Block a user