From b94a6a0193884ba2edb8eb38670e51b033893387 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 18 Mar 2015 13:17:39 +0100 Subject: [PATCH] rlp: add DecodeBytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Über-convenience. --- rlp/decode.go | 7 +++++++ 1 file changed, 7 insertions(+) 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