diff options
author | Mission Liao <mission.liao@dexon.org> | 2019-04-01 12:25:09 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-01 12:25:09 +0800 |
commit | ecc5e12b1ac4826e302607769f5b831ab4c27046 (patch) | |
tree | e01fbf5d796c555f1d343e14023c282ad83bcba8 /core/test/network.go | |
parent | 46f00c345dc0993cf888523e482ae0ff385c4391 (diff) | |
download | tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.gz tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.zst tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.zip |
core: clean TODOs (#539)
* core: fix block timestamp (#529)
* Remove TODO
dMoment is still required when the block timestamp of
the genesis block is still need to be verified.
* Refine timestamp when preparing blocks
* Add timestamp checking in sanity check
* Revert code to patch position when preparing
* Remove TODOs that seems meaningless now
* Remove TODOs related to refactoring
* core: remove finalization (#531)
- Remove types.FinalizationResult, randomness
field would be moved to `types.Block` directly.
- Add a placeholder for types.Block.Randomness
field for blocks proposed from
round < DKGDelayRound. (refer to core.NoRand)
- Make the height of the genesis block starts
from 1. (refer to types.GenesisHeight)
- The fullnode's behavior of
core.Governance.GetRoundHeight is (assume
round-length is 100):
- round: 0 -> 0 (we need to workaround this)
- round: 1 -> 101
- round: 2 -> 201
- test.Governance already simulate this
behavior, and the workaround is wrapped at
utils.GetRoundHeight.
* core: fix issues (#536)
fixing code in these condition:
- assigning position without initializing them
and expected it's for genesis
- compare height with 0
Diffstat (limited to 'core/test/network.go')
-rw-r--r-- | core/test/network.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/core/test/network.go b/core/test/network.go index b0ce3f7..f32c27f 100644 --- a/core/test/network.go +++ b/core/test/network.go @@ -295,10 +295,7 @@ func (n *Network) BroadcastBlock(block *types.Block) { } n.addBlockToCache(block) if block.IsFinalized() { - n.addBlockFinalizationToCache( - block.Hash, - block.Finalization.Height, - block.Finalization.Randomness) + n.addBlockRandomnessToCache(block.Hash, block.Randomness) } } @@ -308,11 +305,7 @@ func (n *Network) BroadcastAgreementResult( if !n.markAgreementResultAsSent(result.BlockHash) { return } - n.addBlockFinalizationToCache( - result.BlockHash, - result.FinalizationHeight, - result.Randomness, - ) + n.addBlockRandomnessToCache(result.BlockHash, result.Randomness) notarySet := n.getNotarySet(result.Position.Round) count := maxAgreementResultBroadcast for nID := range notarySet { @@ -626,16 +619,14 @@ func (n *Network) addBlockToCache(b *types.Block) { n.blockCache[b.Hash] = b.Clone() } -func (n *Network) addBlockFinalizationToCache( - hash common.Hash, height uint64, rand []byte) { +func (n *Network) addBlockRandomnessToCache(hash common.Hash, rand []byte) { n.blockCacheLock.Lock() defer n.blockCacheLock.Unlock() block, exist := n.blockCache[hash] if !exist { return } - block.Finalization.Height = height - block.Finalization.Randomness = rand + block.Randomness = rand } func (n *Network) addVoteToCache(v *types.Vote) { |