diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-18 20:17:39 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-18 20:17:39 +0800 |
commit | b94a6a0193884ba2edb8eb38670e51b033893387 (patch) | |
tree | 32e62cd3dfb2a22ac1994b23b5198c40aa942cc1 /rlp | |
parent | cb009a5c4da40e1987b9dfcffa4d52bcae41e4e1 (diff) | |
download | go-tangerine-b94a6a0193884ba2edb8eb38670e51b033893387.tar.gz go-tangerine-b94a6a0193884ba2edb8eb38670e51b033893387.tar.zst go-tangerine-b94a6a0193884ba2edb8eb38670e51b033893387.zip |
rlp: add DecodeBytes
Über-convenience.
Diffstat (limited to 'rlp')
-rw-r--r-- | rlp/decode.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/rlp/decode.go b/rlp/decode.go index 55f7187a3..6d7e670c2 100644 --- a/rlp/decode.go +++ b/rlp/decode.go @@ -2,6 +2,7 @@ package rlp import ( "bufio" + "bytes" "encoding/binary" "errors" "fmt" @@ -73,6 +74,12 @@ func Decode(r io.Reader, val interface{}) error { return NewStream(r).Decode(val) } +// DecodeBytes parses RLP data from b into val. +// Please see the documentation of Decode for the decoding rules. +func DecodeBytes(b []byte, val interface{}) error { + return NewStream(bytes.NewReader(b)).Decode(val) +} + type decodeError struct { msg string typ reflect.Type |