mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 03:06:16 +00:00
vm/encoding: move bigint from vm to encoding package
This commit is contained in:
parent
783f5ecb01
commit
7ca2807875
16 changed files with 55 additions and 47 deletions
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
)
|
||||
|
||||
// SerializeItem encodes given Item into the byte slice.
|
||||
|
@ -43,7 +43,7 @@ func serializeItemTo(item Item, w *io.BinWriter, seen map[Item]bool) {
|
|||
w.WriteBool(t.Value().(bool))
|
||||
case *BigInteger:
|
||||
w.WriteBytes([]byte{byte(IntegerT)})
|
||||
w.WriteVarBytes(emit.IntToBytes(t.Value().(*big.Int)))
|
||||
w.WriteVarBytes(bigint.ToBytes(t.Value().(*big.Int)))
|
||||
case *Interop:
|
||||
w.Err = errors.New("interop item can't be serialized")
|
||||
case *Array, *Struct:
|
||||
|
@ -102,7 +102,7 @@ func DecodeBinaryStackItem(r *io.BinReader) Item {
|
|||
return NewBool(b)
|
||||
case IntegerT:
|
||||
data := r.ReadVarBytes()
|
||||
num := emit.BytesToInt(data)
|
||||
num := bigint.FromBytes(data)
|
||||
return NewBigInteger(num)
|
||||
case ArrayT, StructT:
|
||||
size := int(r.ReadVarUint())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue