Implemented Map Stack Item:

1) Added new file map.go, map_test.go
2) Added Map, Hash Method to Item interface
3) Implemented Hash Method for every stack items (Boolean, Array, Int, ...)
This commit is contained in:
DauTT 2019-04-02 22:38:41 +02:00
parent 7bf4d691a9
commit c6cd0e0c21
9 changed files with 393 additions and 1 deletions

View file

@ -3,6 +3,7 @@ package stack
import (
"bytes"
"errors"
"fmt"
"math/big"
"strconv"
)
@ -69,3 +70,14 @@ func reverse(b []byte) []byte {
return dest
}
//Value returns the underlying ByteArray's value.
func (ba *ByteArray) Value() []byte {
return ba.val
}
// Hash overrides the default abstract hash method.
func (ba *ByteArray) Hash() (string, error) {
data := fmt.Sprintf("%T %v", ba, ba.Value())
return KeyGenerator([]byte(data))
}