Skip to content

Commit

Permalink
core: unon fast sync completion wait for governance to be initialized…
Browse files Browse the repository at this point in the history
… in order to calculate rewards distribution correctly
  • Loading branch information
sadoci committed Jan 21, 2022
1 parent 6656da8 commit 880b5cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
metaminer "github.com/ethereum/go-ethereum/metadium/miner"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -1837,6 +1838,18 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
if err != nil {
return it.index, err
}

if !metaminer.IsPoW() {
// make sure the previous block exists in order to calculate rewards distribution
for {
if _, _, err := metaminer.CalculateRewards(
block.Number(), big.NewInt(0), big.NewInt(100000000), nil); err == nil {
break
}
time.Sleep(100 * time.Millisecond)
}
}

// Enable prefetching to pull in trie node paths while processing transactions
statedb.StartPrefetcher("chain")
activeState = statedb
Expand Down

0 comments on commit 880b5cb

Please sign in to comment.