go-ethereum-code-analysis
go-ethereum-code-analysis copied to clipboard
rlp源码解析好像有点问题。
编码器 encode.go 首先定义了空字符串和空List的值,分别是 0x80和0xC0。 注意,整形的0值的对应值也是0x80。这个在黄皮书上面是没有看到有定义的。 然后定义了一个接口类型给别的类型实现 EncodeRLP。
我用go运行了0x80,得到的结果是128而不是0,不知道我有没有理解错误。
是否跟这句话有关,全零数据为非法数据: When interpreting RLP data, if an expected fragment is decoded as a scalar and leading zeroes are found in the byte sequence, clients are required to consider it non-canonical and treat it in the same manner as otherwise invalid RLP data, dismissing it completely. There is no specific canonical encoding format for signed or floating-point values.