diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-12-26 15:56:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-26 15:56:33 +0800 |
commit | ca82c3c26ac206c2c81dfa636902aacf327381b1 (patch) | |
tree | c708d058e81aae4ae41eb8bb195cf1e64c7739d5 /core | |
parent | 39c02fe0f7c81491ea897fafcf32595d280bbdbe (diff) | |
download | dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.tar dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.tar.gz dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.tar.bz2 dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.tar.lz dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.tar.xz dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.tar.zst dexon-consensus-ca82c3c26ac206c2c81dfa636902aacf327381b1.zip |
core: Polish randomness (#385)
Diffstat (limited to 'core')
-rw-r--r-- | core/consensus.go | 6 | ||||
-rw-r--r-- | core/types/block-randomness.go | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/core/consensus.go b/core/consensus.go index cab28cb..3353d1d 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -988,9 +988,7 @@ func (con *Consensus) ProcessBlockRandomnessResult( } if needBroadcast { con.logger.Debug("Calling Network.BroadcastRandomnessResult", - "hash", rand.BlockHash.String()[:6], - "position", &rand.Position, - "randomness", hex.EncodeToString(rand.Randomness)) + "randomness", rand) con.network.BroadcastRandomnessResult(rand) } return con.deliverFinalizedBlocks() @@ -1011,7 +1009,7 @@ func (con *Consensus) pullRandomness() { case <-con.ctx.Done(): return case <-con.resetRandomnessTicker: - case <-time.After(1 * time.Second): + case <-time.After(1500 * time.Millisecond): // TODO(jimmy): pulling period should be related to lambdaBA. hashes := con.ccModule.pendingBlocksWithoutRandomness() con.logger.Debug("Calling Network.PullRandomness", "blocks", hashes) diff --git a/core/types/block-randomness.go b/core/types/block-randomness.go index 1c64d4a..65cb635 100644 --- a/core/types/block-randomness.go +++ b/core/types/block-randomness.go @@ -18,6 +18,7 @@ package types import ( + "encoding/hex" "fmt" "github.com/dexon-foundation/dexon-consensus/common" @@ -42,3 +43,10 @@ type BlockRandomnessResult struct { Position Position `json:"position"` Randomness []byte `json:"randomness"` } + +func (r *BlockRandomnessResult) String() string { + return fmt.Sprintf("blockRandomness{Block:%s Pos:%s Rand:%s}", + r.BlockHash.String()[:6], &r.Position, + hex.EncodeToString(r.Randomness)[:6], + ) +} |