diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-09 14:12:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-09 14:12:15 +0800 |
commit | d28cc2c0cf87061fed9356509a28a307b9f55943 (patch) | |
tree | 09ac5ccd9ec721072f2c653e8201c1487e9e265c /simulation | |
parent | 7326f9722771633f3d137944c814544888a7a87f (diff) | |
download | dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.gz dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.bz2 dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.lz dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.xz dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.zst dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.zip |
core: Add Block.IsGenesis() and set Block.ParentHash to 0 in genesis block. (#37)
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/validator.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/simulation/validator.go b/simulation/validator.go index a30420e..b4e6127 100644 --- a/simulation/validator.go +++ b/simulation/validator.go @@ -135,7 +135,7 @@ func (v *Validator) MsgServer(isStopped chan struct{}) { } } else { pendingBlocks = append(pendingBlocks, val) - if val.ParentHash == val.Hash { + if val.IsGenesis() { v.gov.addValidator(val.ProposerID) } validatorSet := v.gov.GetValidatorSet() @@ -162,11 +162,10 @@ func (v *Validator) BroadcastGenesisBlock() { for v.network.NumPeers() != v.config.Num { time.Sleep(time.Second) } - hash := common.NewRandomHash() b := &types.Block{ ProposerID: v.ID, - ParentHash: hash, - Hash: hash, + ParentHash: common.Hash{}, + Hash: common.NewRandomHash(), Height: 0, Acks: map[common.Hash]struct{}{}, Timestamps: map[types.ValidatorID]time.Time{ |