mirror of https://github.com/ethereum/go-ethereum
core/types: transaction and receipt encoding/decoding optimizations (#27976)
Just some minor optimizations I figured out a while ago. By using ReadBytes instead of Bytes on the rlp stream, we can save the allocation of a temporary buffer for the typed tx payload. If kind == rlp.Byte, the size reported by Stream.Kind will be zero, but we need a buffer of size 1 for ReadBytes. Since typed txs always have to be longer than 1 byte, we can just return an error for kind == rlp.Byte. There is a also a small change for Log: since the first three fields of Log are the ones that should appear in the canon encoding, we can simply ignore the remaining fields via struct tag. Doing this removes an indirection through the rlpLog type. --------- Co-authored-by: Martin Holst Swende <martin@swende.se>pull/27511/head
parent
6b98d18789
commit
9bbb9df185
Loading…
Reference in new issue