From 9e60e64076a7edce31786b6ce5ebd5cc61b806f9 Mon Sep 17 00:00:00 2001 From: lizhefeng Date: Sat, 8 Sep 2018 20:43:44 -0700 Subject: [PATCH] IOTEX-22 Create creator's state first when recovering from fresh state db (#72) --- blockchain/blockchain.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index ed4c3d87e6..8480a0a6bd 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -310,6 +310,12 @@ func (bc *blockchain) Start(ctx context.Context) (err error) { } startHeight = factoryHeight + 1 } + // If restarting factory from fresh db, first create creator's state + if startHeight == 0 { + if _, err := bc.sf.LoadOrCreateState(Gen.CreatorAddr, Gen.TotalSupply); err != nil { + return err + } + } for i := startHeight; i <= bc.tipHeight; i++ { blk, err := bc.GetBlockByHeight(i) if err != nil {