diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-08-30 15:09:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 15:09:15 +0800 |
commit | 8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8 (patch) | |
tree | b9ea30e61b410557cc87aa4d828c4cb3cf771984 /core/test/blocks-generator.go | |
parent | 1f34da04eb9d80648349140eb1442cab87ba5cd8 (diff) | |
download | tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.tar tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.tar.gz tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.tar.bz2 tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.tar.lz tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.tar.xz tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.tar.zst tangerine-consensus-8cb1d5c4f3f7f93d8b2c54addf5c2caced0a1eb8.zip |
core: tune total ordering performance (#81)
- Replace map with slice
Compared to slice, accessing to map is slower and
the memory usage is inefficient.
Diffstat (limited to 'core/test/blocks-generator.go')
-rw-r--r-- | core/test/blocks-generator.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/test/blocks-generator.go b/core/test/blocks-generator.go index 3cd97ee..b05d08f 100644 --- a/core/test/blocks-generator.go +++ b/core/test/blocks-generator.go @@ -236,7 +236,8 @@ func (gen *BlocksGenerator) Generate( validatorCount int, blockCount int, ackingCountGenerator func() int, - writer blockdb.Writer) (err error) { + writer blockdb.Writer) ( + validators types.ValidatorIDs, err error) { if ackingCountGenerator == nil { ackingCountGenerator = normalAckingCountGenerator( @@ -244,7 +245,7 @@ func (gen *BlocksGenerator) Generate( float64(validatorCount/2), float64(validatorCount/4+1)) } - validators := []types.ValidatorID{} + validators = types.ValidatorIDs{} for i := 0; i < validatorCount; i++ { validators = append( validators, types.ValidatorID{Hash: common.NewRandomHash()}) |