mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 03:58:06 +00:00
core/state: add Size() method to NEP5TransferLog
This commit is contained in:
parent
df2598c8dc
commit
3c6d9653b0
2 changed files with 7 additions and 0 deletions
|
@ -106,6 +106,11 @@ func (lg *NEP5TransferLog) ForEach(f func(*NEP5Transfer) error) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Size returns an amount of transfer written in log.
|
||||||
|
func (lg *NEP5TransferLog) Size() int {
|
||||||
|
return len(lg.Raw) / NEP5TransferSize
|
||||||
|
}
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
func (t *NEP5Tracker) EncodeBinary(w *io.BinWriter) {
|
func (t *NEP5Tracker) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteU64LE(uint64(t.Balance))
|
w.WriteU64LE(uint64(t.Balance))
|
||||||
|
|
|
@ -25,6 +25,8 @@ func TestNEP5TransferLog_Append(t *testing.T) {
|
||||||
require.NoError(t, lg.Append(tr))
|
require.NoError(t, lg.Append(tr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require.Equal(t, len(expected), lg.Size())
|
||||||
|
|
||||||
i := 0
|
i := 0
|
||||||
err := lg.ForEach(func(tr *NEP5Transfer) error {
|
err := lg.ForEach(func(tr *NEP5Transfer) error {
|
||||||
require.Equal(t, expected[i], tr)
|
require.Equal(t, expected[i], tr)
|
||||||
|
|
Loading…
Reference in a new issue