Skip to content

Commit b94a6a0

Browse files
committed
rlp: add DecodeBytes
Über-convenience.
1 parent cb009a5 commit b94a6a0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎rlp/decode.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rlp
22

33
import (
44
"bufio"
5+
"bytes"
56
"encoding/binary"
67
"errors"
78
"fmt"
@@ -73,6 +74,12 @@ func Decode(r io.Reader, val interface{}) error {
7374
return NewStream(r).Decode(val)
7475
}
7576

77+
// DecodeBytes parses RLP data from b into val.
78+
// Please see the documentation of Decode for the decoding rules.
79+
func DecodeBytes(b []byte, val interface{}) error {
80+
return NewStream(bytes.NewReader(b)).Decode(val)
81+
}
82+
7683
type decodeError struct {
7784
msg string
7885
typ reflect.Type

0 commit comments

Comments
 (0)