Manage oracle block in startup

This commit is contained in:
StephenButtolph 2020-04-27 23:34:16 -04:00
parent 5250895714
commit 5c0b89d5eb
1 changed files with 17 additions and 3 deletions

View File

@ -45,10 +45,24 @@ func (t *Transitive) Initialize(config Config) {
}
func (t *Transitive) finishBootstrapping() {
tail := t.Config.VM.LastAccepted()
t.Config.VM.SetPreference(tail)
t.Consensus.Initialize(t.Config.Context, t.Params, tail)
t.bootstrapped = true
tailID := t.Config.VM.LastAccepted()
t.Consensus.Initialize(t.Config.Context, t.Params, tailID)
tail, err := t.Config.VM.GetBlock(tailID)
if err != nil {
t.Config.Context.Log.Error("Failed to get last accepted block due to: %s", err)
return
}
switch blk := tail.(type) {
case OracleBlock:
for _, blk := range blk.Options() {
t.deliver(blk)
}
default:
t.Config.VM.SetPreference(tailID)
}
}
// Shutdown implements the Engine interface