native: drop OnPersistEnd

Now that PostPersist is being run for every native contract we can do our
dirty caching tricks right there instead of OnPersistEnd.
This commit is contained in:
Roman Khimov 2020-12-13 23:30:21 +03:00
parent 938be298f0
commit cb5ecaefe7
9 changed files with 21 additions and 64 deletions

View file

@ -320,7 +320,14 @@ func (n *NEO) PostPersist(ic *interop.Context) error {
}
}
n.OnPersistEnd(ic.DAO)
if n.gasPerBlockChanged.Load().(bool) {
gr, err := n.getSortedGASRecordFromDAO(ic.DAO)
if err != nil {
panic(err)
}
n.gasPerBlock.Store(gr)
n.gasPerBlockChanged.Store(false)
}
return nil
}
@ -347,18 +354,6 @@ func (n *NEO) getGASPerVote(d dao.DAO, key []byte, index ...uint32) []big.Int {
return reward
}
// OnPersistEnd updates cached values if they've been changed.
func (n *NEO) OnPersistEnd(d dao.DAO) {
if n.gasPerBlockChanged.Load().(bool) {
gr, err := n.getSortedGASRecordFromDAO(d)
if err != nil {
panic(err)
}
n.gasPerBlock.Store(gr)
n.gasPerBlockChanged.Store(false)
}
}
func (n *NEO) increaseBalance(ic *interop.Context, h util.Uint160, si *state.StorageItem, amount *big.Int) error {
acc, err := state.NEOBalanceStateFromBytes(si.Value)
if err != nil {