diff options
author | Felix Lange <fjl@twurst.com> | 2015-08-13 17:10:26 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-08-13 17:10:26 +0800 |
commit | 0b0b31c7d2572a9ea9d88056b1951d6a2162ef23 (patch) | |
tree | 7ca11784e810dfab9fa9770fa9957bfe452bdb35 /rlp/encode.go | |
parent | 0dd6911c6222ce65d6aa0760f7c322246464b2d0 (diff) | |
parent | 1d2420323ca555f8ac45969bd39415c5e619e4e0 (diff) | |
download | dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.tar dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.tar.gz dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.tar.bz2 dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.tar.lz dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.tar.xz dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.tar.zst dexon-0b0b31c7d2572a9ea9d88056b1951d6a2162ef23.zip |
Merge pull request #1651 from karalabe/rlp-boolean-support
rlp: boolean support
Diffstat (limited to 'rlp/encode.go')
-rw-r--r-- | rlp/encode.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rlp/encode.go b/rlp/encode.go index 0ddef7bbb..b525ae4e7 100644 --- a/rlp/encode.go +++ b/rlp/encode.go @@ -361,6 +361,8 @@ func makeWriter(typ reflect.Type) (writer, error) { return writeBigIntNoPtr, nil case isUint(kind): return writeUint, nil + case kind == reflect.Bool: + return writeBool, nil case kind == reflect.String: return writeString, nil case kind == reflect.Slice && isByte(typ.Elem()): @@ -398,6 +400,15 @@ func writeUint(val reflect.Value, w *encbuf) error { return nil } +func writeBool(val reflect.Value, w *encbuf) error { + if val.Bool() { + w.str = append(w.str, 0x01) + } else { + w.str = append(w.str, 0x80) + } + return nil +} + func writeBigIntPtr(val reflect.Value, w *encbuf) error { ptr := val.Interface().(*big.Int) if ptr == nil { |