From bd820fb48fe2338aaae27383e949c003577e4d1e Mon Sep 17 00:00:00 2001 From: Christopher Schuchardt Date: Mon, 5 Aug 2024 22:54:47 -0400 Subject: [PATCH] Stopped `RecoveryLogs` store from being created when `IgnoreRecoveryLogs` is `true` (#3444) Co-authored-by: Shargon --- src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs b/src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs index 2e6a3a19a6..d6a4340544 100644 --- a/src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs +++ b/src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs @@ -116,7 +116,9 @@ public ConsensusContext(NeoSystem neoSystem, Settings settings, Wallet wallet) this.wallet = wallet; this.neoSystem = neoSystem; dbftSettings = settings; - store = neoSystem.LoadStore(settings.RecoveryLogs); + + if (dbftSettings.IgnoreRecoveryLogs == false) + store = neoSystem.LoadStore(settings.RecoveryLogs); } public Block CreateBlock() @@ -168,7 +170,7 @@ public Block EnsureHeader() public bool Load() { - byte[] data = store.TryGet(ConsensusStateKey); + byte[] data = store?.TryGet(ConsensusStateKey); if (data is null || data.Length == 0) return false; MemoryReader reader = new(data); try @@ -272,7 +274,7 @@ public void Reset(byte viewNumber) public void Save() { - store.PutSync(ConsensusStateKey, this.ToArray()); + store?.PutSync(ConsensusStateKey, this.ToArray()); } public void Deserialize(ref MemoryReader reader)