aboutsummaryrefslogtreecommitdiffstats
path: root/rlp/decode.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-09-09 09:34:15 +0800
committerFelix Lange <fjl@twurst.com>2015-09-11 01:41:51 +0800
commit24bb68e7cf546153436f1d38a7227fdf75d73343 (patch)
treefa85e497a639af7aa8ad1cc83dc09fe104fbd7df /rlp/decode.go
parentbc17dba8fba0f3007398f231f07916a95ed963ac (diff)
downloaddexon-24bb68e7cf546153436f1d38a7227fdf75d73343.tar
dexon-24bb68e7cf546153436f1d38a7227fdf75d73343.tar.gz
dexon-24bb68e7cf546153436f1d38a7227fdf75d73343.tar.bz2
dexon-24bb68e7cf546153436f1d38a7227fdf75d73343.tar.lz
dexon-24bb68e7cf546153436f1d38a7227fdf75d73343.tar.xz
dexon-24bb68e7cf546153436f1d38a7227fdf75d73343.tar.zst
dexon-24bb68e7cf546153436f1d38a7227fdf75d73343.zip
rlp: add RawValue
Diffstat (limited to 'rlp/decode.go')
-rw-r--r--rlp/decode.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/rlp/decode.go b/rlp/decode.go
index 1381f5274..c4d42c6fc 100644
--- a/rlp/decode.go
+++ b/rlp/decode.go
@@ -173,6 +173,8 @@ var (
func makeDecoder(typ reflect.Type, tags tags) (dec decoder, err error) {
kind := typ.Kind()
switch {
+ case typ == rawValueType:
+ return decodeRawValue, nil
case typ.Implements(decoderInterface):
return decodeDecoder, nil
case kind != reflect.Ptr && reflect.PtrTo(typ).Implements(decoderInterface):
@@ -203,6 +205,15 @@ func makeDecoder(typ reflect.Type, tags tags) (dec decoder, err error) {
}
}
+func decodeRawValue(s *Stream, val reflect.Value) error {
+ r, err := s.Raw()
+ if err != nil {
+ return err
+ }
+ val.SetBytes(r)
+ return nil
+}
+
func decodeUint(s *Stream, val reflect.Value) error {
typ := val.Type()
num, err := s.uint(typ.Bits())