forked from TrueCloudLab/neoneo-go
core: rename state.NEP17Balances to state.NEP17TransferInfo
Balances are to be removed from state.NEP17TransferInfo, so the remnant fields are NextTransferBatch, NewBatch and a map of LastUpdatedBlocks. These fields are more staff-related. Also rename dao.[Get, Put, put]NEP17Balances and STNEP17Balances preffix. Also rename NEP17TransferInfo.Trackers to LastUpdatedBlockTrackers because NEP17TransferInfo.Balances are to be removed.
This commit is contained in:
parent
c0a2c74e0c
commit
e46d76d7aa
10 changed files with 69 additions and 69 deletions
|
@ -260,7 +260,7 @@ func (chain *FakeChain) ForEachNEP17Transfer(util.Uint160, func(*state.NEP17Tran
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNEP17Balances implements Blockchainer interface.
|
// GetNEP17Balances implements Blockchainer interface.
|
||||||
func (chain *FakeChain) GetNEP17Balances(util.Uint160) *state.NEP17Balances {
|
func (chain *FakeChain) GetNEP17Balances(util.Uint160) *state.NEP17TransferInfo {
|
||||||
panic("TODO")
|
panic("TODO")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -989,14 +989,14 @@ func (bc *Blockchain) processNEP17Transfer(cache *dao.Cached, h util.Uint256, b
|
||||||
Tx: h,
|
Tx: h,
|
||||||
}
|
}
|
||||||
if !fromAddr.Equals(util.Uint160{}) {
|
if !fromAddr.Equals(util.Uint160{}) {
|
||||||
balances, err := cache.GetNEP17Balances(fromAddr)
|
balances, err := cache.GetNEP17TransferInfo(fromAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bs := balances.Trackers[id]
|
bs := balances.LastUpdated[id]
|
||||||
bs.Balance = *new(big.Int).Sub(&bs.Balance, amount)
|
bs.Balance = *new(big.Int).Sub(&bs.Balance, amount)
|
||||||
bs.LastUpdatedBlock = b.Index
|
bs.LastUpdatedBlock = b.Index
|
||||||
balances.Trackers[id] = bs
|
balances.LastUpdated[id] = bs
|
||||||
transfer.Amount = *new(big.Int).Sub(&transfer.Amount, amount)
|
transfer.Amount = *new(big.Int).Sub(&transfer.Amount, amount)
|
||||||
balances.NewBatch, err = cache.AppendNEP17Transfer(fromAddr,
|
balances.NewBatch, err = cache.AppendNEP17Transfer(fromAddr,
|
||||||
balances.NextTransferBatch, balances.NewBatch, transfer)
|
balances.NextTransferBatch, balances.NewBatch, transfer)
|
||||||
|
@ -1006,19 +1006,19 @@ func (bc *Blockchain) processNEP17Transfer(cache *dao.Cached, h util.Uint256, b
|
||||||
if balances.NewBatch {
|
if balances.NewBatch {
|
||||||
balances.NextTransferBatch++
|
balances.NextTransferBatch++
|
||||||
}
|
}
|
||||||
if err := cache.PutNEP17Balances(fromAddr, balances); err != nil {
|
if err := cache.PutNEP17TransferInfo(fromAddr, balances); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !toAddr.Equals(util.Uint160{}) {
|
if !toAddr.Equals(util.Uint160{}) {
|
||||||
balances, err := cache.GetNEP17Balances(toAddr)
|
balances, err := cache.GetNEP17TransferInfo(toAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bs := balances.Trackers[id]
|
bs := balances.LastUpdated[id]
|
||||||
bs.Balance = *new(big.Int).Add(&bs.Balance, amount)
|
bs.Balance = *new(big.Int).Add(&bs.Balance, amount)
|
||||||
bs.LastUpdatedBlock = b.Index
|
bs.LastUpdatedBlock = b.Index
|
||||||
balances.Trackers[id] = bs
|
balances.LastUpdated[id] = bs
|
||||||
|
|
||||||
transfer.Amount = *amount
|
transfer.Amount = *amount
|
||||||
balances.NewBatch, err = cache.AppendNEP17Transfer(toAddr,
|
balances.NewBatch, err = cache.AppendNEP17Transfer(toAddr,
|
||||||
|
@ -1029,7 +1029,7 @@ func (bc *Blockchain) processNEP17Transfer(cache *dao.Cached, h util.Uint256, b
|
||||||
if balances.NewBatch {
|
if balances.NewBatch {
|
||||||
balances.NextTransferBatch++
|
balances.NextTransferBatch++
|
||||||
}
|
}
|
||||||
if err := cache.PutNEP17Balances(toAddr, balances); err != nil {
|
if err := cache.PutNEP17TransferInfo(toAddr, balances); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +1037,7 @@ func (bc *Blockchain) processNEP17Transfer(cache *dao.Cached, h util.Uint256, b
|
||||||
|
|
||||||
// ForEachNEP17Transfer executes f for each nep17 transfer in log.
|
// ForEachNEP17Transfer executes f for each nep17 transfer in log.
|
||||||
func (bc *Blockchain) ForEachNEP17Transfer(acc util.Uint160, f func(*state.NEP17Transfer) (bool, error)) error {
|
func (bc *Blockchain) ForEachNEP17Transfer(acc util.Uint160, f func(*state.NEP17Transfer) (bool, error)) error {
|
||||||
balances, err := bc.dao.GetNEP17Balances(acc)
|
balances, err := bc.dao.GetNEP17TransferInfo(acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1058,8 +1058,8 @@ func (bc *Blockchain) ForEachNEP17Transfer(acc util.Uint160, f func(*state.NEP17
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNEP17Balances returns NEP17 balances for the acc.
|
// GetNEP17Balances returns NEP17 balances for the acc.
|
||||||
func (bc *Blockchain) GetNEP17Balances(acc util.Uint160) *state.NEP17Balances {
|
func (bc *Blockchain) GetNEP17Balances(acc util.Uint160) *state.NEP17TransferInfo {
|
||||||
bs, err := bc.dao.GetNEP17Balances(acc)
|
bs, err := bc.dao.GetNEP17TransferInfo(acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1068,22 +1068,22 @@ func (bc *Blockchain) GetNEP17Balances(acc util.Uint160) *state.NEP17Balances {
|
||||||
|
|
||||||
// GetUtilityTokenBalance returns utility token (GAS) balance for the acc.
|
// GetUtilityTokenBalance returns utility token (GAS) balance for the acc.
|
||||||
func (bc *Blockchain) GetUtilityTokenBalance(acc util.Uint160) *big.Int {
|
func (bc *Blockchain) GetUtilityTokenBalance(acc util.Uint160) *big.Int {
|
||||||
bs, err := bc.dao.GetNEP17Balances(acc)
|
bs, err := bc.dao.GetNEP17TransferInfo(acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return big.NewInt(0)
|
return big.NewInt(0)
|
||||||
}
|
}
|
||||||
balance := bs.Trackers[bc.contracts.GAS.ID].Balance
|
balance := bs.LastUpdated[bc.contracts.GAS.ID].Balance
|
||||||
return &balance
|
return &balance
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGoverningTokenBalance returns governing token (NEO) balance and the height
|
// GetGoverningTokenBalance returns governing token (NEO) balance and the height
|
||||||
// of the last balance change for the account.
|
// of the last balance change for the account.
|
||||||
func (bc *Blockchain) GetGoverningTokenBalance(acc util.Uint160) (*big.Int, uint32) {
|
func (bc *Blockchain) GetGoverningTokenBalance(acc util.Uint160) (*big.Int, uint32) {
|
||||||
bs, err := bc.dao.GetNEP17Balances(acc)
|
bs, err := bc.dao.GetNEP17TransferInfo(acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return big.NewInt(0), 0
|
return big.NewInt(0), 0
|
||||||
}
|
}
|
||||||
neo := bs.Trackers[bc.contracts.NEO.ID]
|
neo := bs.LastUpdated[bc.contracts.NEO.ID]
|
||||||
return &neo.Balance, neo.LastUpdatedBlock
|
return &neo.Balance, neo.LastUpdatedBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ type Blockchainer interface {
|
||||||
GetNativeContractScriptHash(string) (util.Uint160, error)
|
GetNativeContractScriptHash(string) (util.Uint160, error)
|
||||||
GetNatives() []state.NativeContract
|
GetNatives() []state.NativeContract
|
||||||
GetNextBlockValidators() ([]*keys.PublicKey, error)
|
GetNextBlockValidators() ([]*keys.PublicKey, error)
|
||||||
GetNEP17Balances(util.Uint160) *state.NEP17Balances
|
GetNEP17Balances(util.Uint160) *state.NEP17TransferInfo
|
||||||
GetNotaryContractScriptHash() util.Uint160
|
GetNotaryContractScriptHash() util.Uint160
|
||||||
GetNotaryBalance(acc util.Uint160) *big.Int
|
GetNotaryBalance(acc util.Uint160) *big.Int
|
||||||
GetPolicer() Policer
|
GetPolicer() Policer
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
// objects in the storeBlock().
|
// objects in the storeBlock().
|
||||||
type Cached struct {
|
type Cached struct {
|
||||||
DAO
|
DAO
|
||||||
balances map[util.Uint160]*state.NEP17Balances
|
balances map[util.Uint160]*state.NEP17TransferInfo
|
||||||
transfers map[util.Uint160]map[uint32]*state.NEP17TransferLog
|
transfers map[util.Uint160]map[uint32]*state.NEP17TransferLog
|
||||||
|
|
||||||
dropNEP17Cache bool
|
dropNEP17Cache bool
|
||||||
|
@ -21,21 +21,21 @@ type Cached struct {
|
||||||
|
|
||||||
// NewCached returns new Cached wrapping around given backing store.
|
// NewCached returns new Cached wrapping around given backing store.
|
||||||
func NewCached(d DAO) *Cached {
|
func NewCached(d DAO) *Cached {
|
||||||
balances := make(map[util.Uint160]*state.NEP17Balances)
|
balances := make(map[util.Uint160]*state.NEP17TransferInfo)
|
||||||
transfers := make(map[util.Uint160]map[uint32]*state.NEP17TransferLog)
|
transfers := make(map[util.Uint160]map[uint32]*state.NEP17TransferLog)
|
||||||
return &Cached{d.GetWrapped(), balances, transfers, false}
|
return &Cached{d.GetWrapped(), balances, transfers, false}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNEP17Balances retrieves NEP17Balances for the acc.
|
// GetNEP17TransferInfo retrieves NEP17TransferInfo for the acc.
|
||||||
func (cd *Cached) GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, error) {
|
func (cd *Cached) GetNEP17TransferInfo(acc util.Uint160) (*state.NEP17TransferInfo, error) {
|
||||||
if bs := cd.balances[acc]; bs != nil {
|
if bs := cd.balances[acc]; bs != nil {
|
||||||
return bs, nil
|
return bs, nil
|
||||||
}
|
}
|
||||||
return cd.DAO.GetNEP17Balances(acc)
|
return cd.DAO.GetNEP17TransferInfo(acc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutNEP17Balances saves NEP17Balances for the acc.
|
// PutNEP17TransferInfo saves NEP17TransferInfo for the acc.
|
||||||
func (cd *Cached) PutNEP17Balances(acc util.Uint160, bs *state.NEP17Balances) error {
|
func (cd *Cached) PutNEP17TransferInfo(acc util.Uint160, bs *state.NEP17TransferInfo) error {
|
||||||
cd.balances[acc] = bs
|
cd.balances[acc] = bs
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func (cd *Cached) Persist() (int, error) {
|
||||||
// caches (accounts/transfer data) in any way.
|
// caches (accounts/transfer data) in any way.
|
||||||
if ok {
|
if ok {
|
||||||
if cd.dropNEP17Cache {
|
if cd.dropNEP17Cache {
|
||||||
lowerCache.balances = make(map[util.Uint160]*state.NEP17Balances)
|
lowerCache.balances = make(map[util.Uint160]*state.NEP17TransferInfo)
|
||||||
}
|
}
|
||||||
var simpleCache *Simple
|
var simpleCache *Simple
|
||||||
for simpleCache == nil {
|
for simpleCache == nil {
|
||||||
|
@ -105,7 +105,7 @@ func (cd *Cached) Persist() (int, error) {
|
||||||
buf := io.NewBufBinWriter()
|
buf := io.NewBufBinWriter()
|
||||||
|
|
||||||
for acc, bs := range cd.balances {
|
for acc, bs := range cd.balances {
|
||||||
err := cd.DAO.putNEP17Balances(acc, bs, buf)
|
err := cd.DAO.putNEP17TransferInfo(acc, bs, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ type DAO interface {
|
||||||
GetCurrentBlockHeight() (uint32, error)
|
GetCurrentBlockHeight() (uint32, error)
|
||||||
GetCurrentHeaderHeight() (i uint32, h util.Uint256, err error)
|
GetCurrentHeaderHeight() (i uint32, h util.Uint256, err error)
|
||||||
GetHeaderHashes() ([]util.Uint256, error)
|
GetHeaderHashes() ([]util.Uint256, error)
|
||||||
GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, error)
|
GetNEP17TransferInfo(acc util.Uint160) (*state.NEP17TransferInfo, error)
|
||||||
GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error)
|
GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error)
|
||||||
GetStorageItem(id int32, key []byte) state.StorageItem
|
GetStorageItem(id int32, key []byte) state.StorageItem
|
||||||
GetStorageItems(id int32) (map[string]state.StorageItem, error)
|
GetStorageItems(id int32) (map[string]state.StorageItem, error)
|
||||||
|
@ -55,7 +55,7 @@ type DAO interface {
|
||||||
PutAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error
|
PutAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error
|
||||||
PutContractID(id int32, hash util.Uint160) error
|
PutContractID(id int32, hash util.Uint160) error
|
||||||
PutCurrentHeader(hashAndIndex []byte) error
|
PutCurrentHeader(hashAndIndex []byte) error
|
||||||
PutNEP17Balances(acc util.Uint160, bs *state.NEP17Balances) error
|
PutNEP17TransferInfo(acc util.Uint160, bs *state.NEP17TransferInfo) error
|
||||||
PutNEP17TransferLog(acc util.Uint160, index uint32, lg *state.NEP17TransferLog) error
|
PutNEP17TransferLog(acc util.Uint160, index uint32, lg *state.NEP17TransferLog) error
|
||||||
PutStorageItem(id int32, key []byte, si state.StorageItem) error
|
PutStorageItem(id int32, key []byte, si state.StorageItem) error
|
||||||
PutVersion(v string) error
|
PutVersion(v string) error
|
||||||
|
@ -63,7 +63,7 @@ type DAO interface {
|
||||||
StoreAsBlock(block *block.Block, buf *io.BufBinWriter) error
|
StoreAsBlock(block *block.Block, buf *io.BufBinWriter) error
|
||||||
StoreAsCurrentBlock(block *block.Block, buf *io.BufBinWriter) error
|
StoreAsCurrentBlock(block *block.Block, buf *io.BufBinWriter) error
|
||||||
StoreAsTransaction(tx *transaction.Transaction, index uint32, buf *io.BufBinWriter) error
|
StoreAsTransaction(tx *transaction.Transaction, index uint32, buf *io.BufBinWriter) error
|
||||||
putNEP17Balances(acc util.Uint160, bs *state.NEP17Balances, buf *io.BufBinWriter) error
|
putNEP17TransferInfo(acc util.Uint160, bs *state.NEP17TransferInfo, buf *io.BufBinWriter) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple is memCached wrapper around DB, simple DAO implementation.
|
// Simple is memCached wrapper around DB, simple DAO implementation.
|
||||||
|
@ -142,12 +142,12 @@ func (dao *Simple) GetContractScriptHash(id int32) (util.Uint160, error) {
|
||||||
return *data, nil
|
return *data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- start nep17 balances.
|
// -- start nep17 transfer info.
|
||||||
|
|
||||||
// GetNEP17Balances retrieves nep17 balances from the cache.
|
// GetNEP17TransferInfo retrieves nep17 transfer info from the cache.
|
||||||
func (dao *Simple) GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, error) {
|
func (dao *Simple) GetNEP17TransferInfo(acc util.Uint160) (*state.NEP17TransferInfo, error) {
|
||||||
key := storage.AppendPrefix(storage.STNEP17Balances, acc.BytesBE())
|
key := storage.AppendPrefix(storage.STNEP17TransferInfo, acc.BytesBE())
|
||||||
bs := state.NewNEP17Balances()
|
bs := state.NewNEP17TransferInfo()
|
||||||
err := dao.GetAndDecode(bs, key)
|
err := dao.GetAndDecode(bs, key)
|
||||||
if err != nil && err != storage.ErrKeyNotFound {
|
if err != nil && err != storage.ErrKeyNotFound {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -155,17 +155,17 @@ func (dao *Simple) GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, err
|
||||||
return bs, nil
|
return bs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutNEP17Balances saves nep17 balances from the cache.
|
// PutNEP17TransferInfo saves nep17 transfer info in the cache.
|
||||||
func (dao *Simple) PutNEP17Balances(acc util.Uint160, bs *state.NEP17Balances) error {
|
func (dao *Simple) PutNEP17TransferInfo(acc util.Uint160, bs *state.NEP17TransferInfo) error {
|
||||||
return dao.putNEP17Balances(acc, bs, io.NewBufBinWriter())
|
return dao.putNEP17TransferInfo(acc, bs, io.NewBufBinWriter())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dao *Simple) putNEP17Balances(acc util.Uint160, bs *state.NEP17Balances, buf *io.BufBinWriter) error {
|
func (dao *Simple) putNEP17TransferInfo(acc util.Uint160, bs *state.NEP17TransferInfo, buf *io.BufBinWriter) error {
|
||||||
key := storage.AppendPrefix(storage.STNEP17Balances, acc.BytesBE())
|
key := storage.AppendPrefix(storage.STNEP17TransferInfo, acc.BytesBE())
|
||||||
return dao.putWithBuffer(bs, key, buf)
|
return dao.putWithBuffer(bs, key, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- end nep17 balances.
|
// -- end nep17 transfer info.
|
||||||
|
|
||||||
// -- start transfer log.
|
// -- start transfer log.
|
||||||
|
|
||||||
|
|
|
@ -713,7 +713,7 @@ func checkFAULTState(t *testing.T, result *state.AppExecResult) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkBalanceOf(t *testing.T, chain *Blockchain, addr util.Uint160, expected int) {
|
func checkBalanceOf(t *testing.T, chain *Blockchain, addr util.Uint160, expected int) {
|
||||||
balance := chain.GetNEP17Balances(addr).Trackers[chain.contracts.GAS.ID]
|
balance := chain.GetNEP17Balances(addr).LastUpdated[chain.contracts.GAS.ID]
|
||||||
require.Equal(t, int64(expected), balance.Balance.Int64())
|
require.Equal(t, int64(expected), balance.Balance.Int64())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,11 @@ func TestGAS_Roundtrip(t *testing.T) {
|
||||||
bc := newTestChain(t)
|
bc := newTestChain(t)
|
||||||
|
|
||||||
getUtilityTokenBalance := func(bc *Blockchain, acc util.Uint160) (*big.Int, uint32) {
|
getUtilityTokenBalance := func(bc *Blockchain, acc util.Uint160) (*big.Int, uint32) {
|
||||||
bs, err := bc.dao.GetNEP17Balances(acc)
|
bs, err := bc.dao.GetNEP17TransferInfo(acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return big.NewInt(0), 0
|
return big.NewInt(0), 0
|
||||||
}
|
}
|
||||||
balance := bs.Trackers[bc.contracts.GAS.ID]
|
balance := bs.LastUpdated[bc.contracts.GAS.ID]
|
||||||
return &balance.Balance, balance.LastUpdatedBlock
|
return &balance.Balance, balance.LastUpdatedBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,25 +44,25 @@ type NEP17Transfer struct {
|
||||||
Tx util.Uint256
|
Tx util.Uint256
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEP17Balances is a map of the NEP17 contract IDs
|
// NEP17TransferInfo is a map of the NEP17 contract IDs
|
||||||
// to the corresponding structures.
|
// to the corresponding structures.
|
||||||
type NEP17Balances struct {
|
type NEP17TransferInfo struct {
|
||||||
Trackers map[int32]NEP17Tracker
|
LastUpdated map[int32]NEP17Tracker
|
||||||
// NextTransferBatch stores an index of the next transfer batch.
|
// NextTransferBatch stores an index of the next transfer batch.
|
||||||
NextTransferBatch uint32
|
NextTransferBatch uint32
|
||||||
// NewBatch is true if batch with the `NextTransferBatch` index should be created.
|
// NewBatch is true if batch with the `NextTransferBatch` index should be created.
|
||||||
NewBatch bool
|
NewBatch bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNEP17Balances returns new NEP17Balances.
|
// NewNEP17TransferInfo returns new NEP17TransferInfo.
|
||||||
func NewNEP17Balances() *NEP17Balances {
|
func NewNEP17TransferInfo() *NEP17TransferInfo {
|
||||||
return &NEP17Balances{
|
return &NEP17TransferInfo{
|
||||||
Trackers: make(map[int32]NEP17Tracker),
|
LastUpdated: make(map[int32]NEP17Tracker),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeBinary implements io.Serializable interface.
|
// DecodeBinary implements io.Serializable interface.
|
||||||
func (bs *NEP17Balances) DecodeBinary(r *io.BinReader) {
|
func (bs *NEP17TransferInfo) DecodeBinary(r *io.BinReader) {
|
||||||
bs.NextTransferBatch = r.ReadU32LE()
|
bs.NextTransferBatch = r.ReadU32LE()
|
||||||
bs.NewBatch = r.ReadBool()
|
bs.NewBatch = r.ReadBool()
|
||||||
lenBalances := r.ReadVarUint()
|
lenBalances := r.ReadVarUint()
|
||||||
|
@ -73,15 +73,15 @@ func (bs *NEP17Balances) DecodeBinary(r *io.BinReader) {
|
||||||
tr.DecodeBinary(r)
|
tr.DecodeBinary(r)
|
||||||
m[key] = tr
|
m[key] = tr
|
||||||
}
|
}
|
||||||
bs.Trackers = m
|
bs.LastUpdated = m
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
func (bs *NEP17Balances) EncodeBinary(w *io.BinWriter) {
|
func (bs *NEP17TransferInfo) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteU32LE(bs.NextTransferBatch)
|
w.WriteU32LE(bs.NextTransferBatch)
|
||||||
w.WriteBool(bs.NewBatch)
|
w.WriteBool(bs.NewBatch)
|
||||||
w.WriteVarUint(uint64(len(bs.Trackers)))
|
w.WriteVarUint(uint64(len(bs.LastUpdated)))
|
||||||
for k, v := range bs.Trackers {
|
for k, v := range bs.LastUpdated {
|
||||||
w.WriteU32LE(uint32(k))
|
w.WriteU32LE(uint32(k))
|
||||||
v.EncodeBinary(w)
|
v.EncodeBinary(w)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,19 @@ import (
|
||||||
|
|
||||||
// KeyPrefix constants.
|
// KeyPrefix constants.
|
||||||
const (
|
const (
|
||||||
DataBlock KeyPrefix = 0x01
|
DataBlock KeyPrefix = 0x01
|
||||||
DataTransaction KeyPrefix = 0x02
|
DataTransaction KeyPrefix = 0x02
|
||||||
DataMPT KeyPrefix = 0x03
|
DataMPT KeyPrefix = 0x03
|
||||||
STAccount KeyPrefix = 0x40
|
STAccount KeyPrefix = 0x40
|
||||||
STNotification KeyPrefix = 0x4d
|
STNotification KeyPrefix = 0x4d
|
||||||
STContractID KeyPrefix = 0x51
|
STContractID KeyPrefix = 0x51
|
||||||
STStorage KeyPrefix = 0x70
|
STStorage KeyPrefix = 0x70
|
||||||
STNEP17Transfers KeyPrefix = 0x72
|
STNEP17Transfers KeyPrefix = 0x72
|
||||||
STNEP17Balances KeyPrefix = 0x73
|
STNEP17TransferInfo KeyPrefix = 0x73
|
||||||
IXHeaderHashList KeyPrefix = 0x80
|
IXHeaderHashList KeyPrefix = 0x80
|
||||||
SYSCurrentBlock KeyPrefix = 0xc0
|
SYSCurrentBlock KeyPrefix = 0xc0
|
||||||
SYSCurrentHeader KeyPrefix = 0xc1
|
SYSCurrentHeader KeyPrefix = 0xc1
|
||||||
SYSVersion KeyPrefix = 0xf0
|
SYSVersion KeyPrefix = 0xf0
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -676,7 +676,7 @@ func (s *Server) getNEP17Balances(ps request.Params) (interface{}, *response.Err
|
||||||
}
|
}
|
||||||
if as != nil {
|
if as != nil {
|
||||||
cache := make(map[int32]util.Uint160)
|
cache := make(map[int32]util.Uint160)
|
||||||
for id, bal := range as.Trackers {
|
for id, bal := range as.LastUpdated {
|
||||||
h, err := s.getHash(id, cache)
|
h, err := s.getHash(id, cache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue