From adf740c23b2843bc28c9f5dcb97def0ce91174fd Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Thu, 18 Aug 2022 12:32:38 +0200 Subject: [PATCH] docs(1434): add more logs --- app/lib/blockchain/DuniterBlockchain.ts | 1 + app/lib/blockchain/Switcher.ts | 5 +++++ app/lib/computation/BlockchainContext.ts | 2 +- app/modules/dump/blocks/dump.blocks.ts | 4 ++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/lib/blockchain/DuniterBlockchain.ts b/app/lib/blockchain/DuniterBlockchain.ts index 9ab3e5efa..063a09505 100644 --- a/app/lib/blockchain/DuniterBlockchain.ts +++ b/app/lib/blockchain/DuniterBlockchain.ts @@ -545,6 +545,7 @@ export class DuniterBlockchain { if (block) { await this.undoDeleteTransactions(block, dal); } + NewLogger().info("Reverted block #%s", blockstamp); } static async undoMembersUpdate(blockstamp: string, dal: FileDAL) { diff --git a/app/lib/blockchain/Switcher.ts b/app/lib/blockchain/Switcher.ts index f600aeedf..ebeb59acc 100644 --- a/app/lib/blockchain/Switcher.ts +++ b/app/lib/blockchain/Switcher.ts @@ -277,6 +277,11 @@ export class Switcher<T extends SwitchBlock> { s[0].number + i, e && e.message ); + if (e.type === "NotFoundError" && this.logger) { + this.logger.error( + "CRITICAL: LevelDB has inconsistent state: " + e.stack + ); + } added = false; } i++; diff --git a/app/lib/computation/BlockchainContext.ts b/app/lib/computation/BlockchainContext.ts index a0589908f..4ec0d7934 100644 --- a/app/lib/computation/BlockchainContext.ts +++ b/app/lib/computation/BlockchainContext.ts @@ -165,7 +165,7 @@ export class BlockchainContext { async revertCurrentBlock(): Promise<DBBlock> { const head_1 = await this.dal.bindexDAL.head(1); - this.logger.debug("Reverting block #%s...", head_1.number); + this.logger.debug("Reverting block #%s-%s...", head_1.number, head_1.hash); const block = await this.dal.getAbsoluteValidBlockInForkWindow( head_1.number, head_1.hash diff --git a/app/modules/dump/blocks/dump.blocks.ts b/app/modules/dump/blocks/dump.blocks.ts index f09670484..19229811d 100644 --- a/app/modules/dump/blocks/dump.blocks.ts +++ b/app/modules/dump/blocks/dump.blocks.ts @@ -28,5 +28,9 @@ export async function dumpBlocks( } export function dumpBlockIfDefined(b: DBBlock | undefined | null) { + console.log("-------- BLOCK --------"); + console.log("Number: " + b?.number); + console.log("Hash: " + b?.hash); + console.log(""); console.log(BlockDTO.fromJSONObject(b).getRawSigned()); } -- GitLab