aboutsummaryrefslogtreecommitdiffstats
path: root/rlp/decode.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-01-16 06:21:41 +0800
committerFelix Lange <fjl@twurst.com>2015-01-16 06:35:26 +0800
commitfc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e (patch)
treef8ba38e7c5ad3be52fc22c09600b619e1f968c53 /rlp/decode.go
parent29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7 (diff)
downloadgo-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.gz
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.bz2
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.lz
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.xz
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.zst
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.zip
rlp: allow encoding non-empty interface values
This needs to be supported because []someInterface does occur sometimes. Funny enough, the fix involves changes to the decoder. makeDecoder cannot return an error for non-empty interfaces anymore because the type cache builds both decoder and writer. Do the check at 'runtime' instead.
Diffstat (limited to 'rlp/decode.go')
-rw-r--r--rlp/decode.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/rlp/decode.go b/rlp/decode.go
index 972e662c2..55f7187a3 100644
--- a/rlp/decode.go
+++ b/rlp/decode.go
@@ -137,7 +137,7 @@ func makeDecoder(typ reflect.Type) (dec decoder, err error) {
return makeStructDecoder(typ)
case kind == reflect.Ptr:
return makePtrDecoder(typ)
- case kind == reflect.Interface && typ.NumMethod() == 0:
+ case kind == reflect.Interface:
return decodeInterface, nil
default:
return nil, fmt.Errorf("rlp: type %v is not RLP-serializable", typ)
@@ -378,6 +378,9 @@ func makePtrDecoder(typ reflect.Type) (decoder, error) {
var ifsliceType = reflect.TypeOf([]interface{}{})
func decodeInterface(s *Stream, val reflect.Value) error {
+ if val.Type().NumMethod() != 0 {
+ return fmt.Errorf("rlp: type %v is not RLP-serializable", val.Type())
+ }
kind, _, err := s.Kind()
if err != nil {
return err