mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
native: decode storage item in Seek
This commit is contained in:
parent
0f827ee6ba
commit
adf403666f
1 changed files with 8 additions and 1 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
|
@ -336,13 +337,19 @@ func (n *NEO) PostPersist(ic *interop.Context) error {
|
|||
func (n *NEO) getGASPerVote(d dao.DAO, key []byte, index ...uint32) []big.Int {
|
||||
var max = make([]uint32, len(index))
|
||||
var reward = make([]big.Int, len(index))
|
||||
var si state.StorageItem
|
||||
d.Seek(n.ContractID, key, func(k, v []byte) {
|
||||
if len(k) == 4 {
|
||||
num := binary.BigEndian.Uint32(k)
|
||||
for i, ind := range index {
|
||||
if max[i] < num && num <= ind {
|
||||
max[i] = num
|
||||
reward[i] = *bigint.FromBytes(v)
|
||||
r := io.NewBinReaderFromBuf(v)
|
||||
si.DecodeBinary(r)
|
||||
if r.Err != nil {
|
||||
return
|
||||
}
|
||||
reward[i] = *bigint.FromBytes(si.Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue