aboutsummaryrefslogtreecommitdiffstats
path: root/core/genesis.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/genesis.go')
-rw-r--r--core/genesis.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/genesis.go b/core/genesis.go
index 67c3a3b58..4c0323c17 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -27,6 +27,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
)
@@ -73,7 +75,7 @@ func WriteGenesisBlock(stateDb, blockDb common.Database, reader io.Reader) (*typ
Nonce: types.EncodeNonce(common.String2Big(genesis.Nonce).Uint64()),
Time: common.String2Big(genesis.Timestamp).Uint64(),
ParentHash: common.HexToHash(genesis.ParentHash),
- Extra: common.Hex2Bytes(genesis.ExtraData),
+ Extra: common.FromHex(genesis.ExtraData),
GasLimit: common.String2Big(genesis.GasLimit),
Difficulty: difficulty,
MixDigest: common.HexToHash(genesis.Mixhash),
@@ -82,6 +84,15 @@ func WriteGenesisBlock(stateDb, blockDb common.Database, reader io.Reader) (*typ
}, nil, nil, nil)
block.Td = difficulty
+ if block := GetBlockByHash(blockDb, block.Hash()); block != nil {
+ glog.V(logger.Info).Infoln("Genesis block already in chain. Writing canonical number")
+ err := WriteCanonNumber(blockDb, block)
+ if err != nil {
+ return nil, err
+ }
+ return block, nil
+ }
+
statedb.Sync()
err = WriteBlock(blockDb, block)