native: optimize totalSupply operations during token burn/mint
We burn GAS in OnPersist for every transaction so some buffer reuse here is quite natural. This also doesn't change a lot in the overall TPS picture, maybe adding some 1%.
This commit is contained in:
parent
dede4fa7b1
commit
64c780ad7a
3 changed files with 16 additions and 11 deletions
|
@ -189,7 +189,8 @@ func (n *NEO) Initialize(ic *interop.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if n.nep17TokenNative.getTotalSupply(ic.DAO).Sign() != 0 {
|
||||
_, totalSupply := n.nep17TokenNative.getTotalSupply(ic.DAO)
|
||||
if totalSupply.Sign() != 0 {
|
||||
return errors.New("already initialized")
|
||||
}
|
||||
|
||||
|
@ -977,7 +978,8 @@ func (n *NEO) computeCommitteeMembers(bc blockchainer.Blockchainer, d dao.DAO) (
|
|||
votersCount := bigint.FromBytes(si)
|
||||
// votersCount / totalSupply must be >= 0.2
|
||||
votersCount.Mul(votersCount, big.NewInt(effectiveVoterTurnout))
|
||||
voterTurnout := votersCount.Div(votersCount, n.getTotalSupply(d))
|
||||
_, totalSupply := n.getTotalSupply(d)
|
||||
voterTurnout := votersCount.Div(votersCount, totalSupply)
|
||||
|
||||
sbVals := bc.GetStandByCommittee()
|
||||
count := len(sbVals)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue