diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-04-10 14:32:45 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:55 +0800 |
commit | 800934fabe031ada3ffc2db6d34361d632dfcc17 (patch) | |
tree | 4c052fa214de4d878d649c0fd946f4346ac7baa3 /core/vm/oracle_contracts_test.go | |
parent | 41416137914cb97f5368f5d05af64a7d86bffcdc (diff) | |
download | go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.tar go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.tar.gz go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.tar.bz2 go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.tar.lz go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.tar.xz go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.tar.zst go-tangerine-800934fabe031ada3ffc2db6d34361d632dfcc17.zip |
core: vm: improve MPK reverse lookup performance
By storing array offset in the original DKGMasterPublicKeyProposed map,
we can locate MPK by proposer ID easily.
Diffstat (limited to 'core/vm/oracle_contracts_test.go')
-rw-r--r-- | core/vm/oracle_contracts_test.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/vm/oracle_contracts_test.go b/core/vm/oracle_contracts_test.go index dd7de495b..6b6eebb9e 100644 --- a/core/vm/oracle_contracts_test.go +++ b/core/vm/oracle_contracts_test.go @@ -976,7 +976,7 @@ func (g *OracleContractsTestSuite) TestResetDKG() { // Clear DKG states for next round. dkgSet := dkgSets[round-1] - g.s.ClearDKGMasterPublicKeyProposed() + g.s.ClearDKGMasterPublicKeyOffset() g.s.ClearDKGMasterPublicKeys() g.s.ClearDKGComplaintProposed() g.s.ClearDKGComplaints() @@ -1002,6 +1002,7 @@ func (g *OracleContractsTestSuite) TestResetDKG() { g.Require().Len(dkgSet, int(g.s.NotarySetSize().Uint64())) dkgSets[round] = dkgSet + i := 0 for id := range dkgSet { offset := g.s.NodesOffsetByNodeKeyAddress(IdToAddress(id)) if offset.Cmp(big.NewInt(0)) < 0 { @@ -1015,7 +1016,7 @@ func (g *OracleContractsTestSuite) TestResetDKG() { panic(err) } g.s.PushDKGMasterPublicKey(b) - g.s.PutDKGMasterPublicKeyProposed(Bytes32(id.Hash), true) + g.s.PutDKGMasterPublicKeyOffset(Bytes32(id.Hash), big.NewInt(int64(i))) // Prepare Complaint. y := dkgTypes.Complaint{} b, err = rlp.EncodeToBytes(&y) @@ -1033,6 +1034,7 @@ func (g *OracleContractsTestSuite) TestResetDKG() { g.s.PutDKGFinalized(addr, true) g.s.IncDKGFinalizedsCount() } + i += 1 } dkgSetSize := len(dkgSet) g.Require().Len(g.s.DKGMasterPublicKeys(), dkgSetSize) |