Skip to content

Commit 150e89b

Browse files
authored
Fixes an issue when reindex takes more than one minute (#351)
- The .Tip is null if the "FlushChain" is run before reindex has completed.
1 parent 55fd969 commit 150e89b

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/Blockcore/Base/BaseFeature.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,18 @@ private async Task StartChainAsync()
289289
}
290290

291291
// Get latest flags (often cached) and persist.
292-
var flags = this.nodeDeployments.GetFlags(this.consensusManager.Tip);
293-
294-
if (this.deploymentFlags == null || flags.ScriptFlags != this.deploymentFlags.ScriptFlags)
292+
if (this.consensusManager.Tip != null)
295293
{
296-
// Update the persistent disk cache of Flags when we retrieve it.
297-
this.keyValueRepo.SaveValueJson("deploymentflags", flags);
294+
var flags = this.nodeDeployments.GetFlags(this.consensusManager.Tip);
295+
296+
if (this.deploymentFlags == null || flags.ScriptFlags != this.deploymentFlags.ScriptFlags)
297+
{
298+
// Update the persistent disk cache of Flags when we retrieve it.
299+
this.keyValueRepo.SaveValueJson("deploymentflags", flags);
298300

299-
// Update the local cached copy used to validate against. We don't want to persist to disk unless the flags actually has changed.
300-
this.deploymentFlags = flags;
301+
// Update the local cached copy used to validate against. We don't want to persist to disk unless the flags actually has changed.
302+
this.deploymentFlags = flags;
303+
}
301304
}
302305
},
303306
this.nodeLifetime.ApplicationStopping,

src/Node/Blockcore.Node/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"CITY (MAIN/LOCAL)": {
4848
"commandName": "Project",
49-
"commandLineArgs": "--chain=CITY -server -addressindex -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -enableauth=0"
49+
"commandLineArgs": "--chain=CITY -server -addressindex -txindex=1 -reindex=0 -rpcallowip=127.0.0.1 -rpcbind=127.0.0.1 -rpcpassword=rpcpassword -rpcuser=rpcuser -datadir=nodedata -enableauth=0"
5050
},
5151
"CITY (TEST/LOCAL)": {
5252
"commandName": "Project",

0 commit comments

Comments
 (0)