From 8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8 Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Thu, 30 Aug 2018 15:09:15 +0800 Subject: core: tune total ordering performance (#81) - Replace map with slice Compared to slice, accessing to map is slower and the memory usage is inefficient. --- core/consensus.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/consensus.go') diff --git a/core/consensus.go b/core/consensus.go index 36cd57e..6c841bf 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -84,10 +84,14 @@ func NewConsensus( } // Setup sequencer by information returned from Governace. + var validators types.ValidatorIDs + for vID := range validatorSet { + validators = append(validators, vID) + } to := newTotalOrdering( uint64(gov.GetTotalOrderingK()), uint64(float32(len(validatorSet)-1)*gov.GetPhiRatio()+1), - uint64(len(validatorSet))) + validators) return &Consensus{ rbModule: rb, -- cgit v1.2.3