This commit is contained in:
alex.sharov 2021-07-27 12:49:03 +07:00
parent f6d9c5cc00
commit f21c9e9ab2
2 changed files with 11 additions and 11 deletions

View File

@ -57,7 +57,7 @@ func ParsePrefix(payload []byte, pos int) (dataPos int, dataLen int, isList bool
return
}
func ParseListPrefix(payload []byte, pos int) (dataPos int, dataLen int, err error) {
func ListPrefix(payload []byte, pos int) (dataPos int, dataLen int, err error) {
dataPos, dataLen, isList, err := ParsePrefix(payload, pos)
if err != nil {
return 0, 0, err
@ -68,7 +68,7 @@ func ParseListPrefix(payload []byte, pos int) (dataPos int, dataLen int, err err
return
}
func ParseStringPrefix(payload []byte, pos int) (dataPos int, dataLen int, err error) {
func StringPrefix(payload []byte, pos int) (dataPos int, dataLen int, err error) {
dataPos, dataLen, isList, err := ParsePrefix(payload, pos)
if err != nil {
return 0, 0, err

View File

@ -122,7 +122,7 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int) (*TxSlot, i
if p >= len(payload) {
return nil, 0, fmt.Errorf("%s: unexpected end of payload after txType", ParseTransactionErrorPrefix)
}
dataPos, dataLen, err = rlp.ParseListPrefix(payload, p)
dataPos, dataLen, err = rlp.ListPrefix(payload, p)
if err != nil {
return nil, 0, fmt.Errorf("%s: envelope ParsePrefix: %v", ParseTransactionErrorPrefix, err)
}
@ -136,7 +136,7 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int) (*TxSlot, i
sigHashPos := p
// If it is non-legacy tx, chainId follows, but we skip it
if !legacy {
dataPos, dataLen, err = rlp.ParseStringPrefix(payload, p)
dataPos, dataLen, err = rlp.StringPrefix(payload, p)
if err != nil {
return nil, 0, fmt.Errorf("%s: chainId len: %w", ParseTransactionErrorPrefix, err)
}
@ -170,7 +170,7 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int) (*TxSlot, i
return nil, 0, fmt.Errorf("%s: gas: %w", ParseTransactionErrorPrefix, err)
}
// Next follows the destrination address (if present)
dataPos, dataLen, err = rlp.ParseStringPrefix(payload, p)
dataPos, dataLen, err = rlp.StringPrefix(payload, p)
if err != nil {
return nil, 0, fmt.Errorf("%s: to len: %w", ParseTransactionErrorPrefix, err)
}
@ -186,7 +186,7 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int) (*TxSlot, i
return nil, 0, fmt.Errorf("%s: value: %w", ParseTransactionErrorPrefix, err)
}
// Next goes data, but we are only interesting in its length
dataPos, dataLen, err = rlp.ParseStringPrefix(payload, p)
dataPos, dataLen, err = rlp.StringPrefix(payload, p)
if err != nil {
return nil, 0, fmt.Errorf("%s: data len: %w", ParseTransactionErrorPrefix, err)
}
@ -194,19 +194,19 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int) (*TxSlot, i
p = dataPos + dataLen
// Next follows access list for non-legacy transactions, we are only interesting in number of addresses and storage keys
if !legacy {
dataPos, dataLen, err = rlp.ParseListPrefix(payload, p)
dataPos, dataLen, err = rlp.ListPrefix(payload, p)
if err != nil {
return nil, 0, fmt.Errorf("%s: access list len: %w", ParseTransactionErrorPrefix, err)
}
tuplePos := dataPos
var tupleLen int
for tuplePos < dataPos+dataLen {
tuplePos, tupleLen, err = rlp.ParseListPrefix(payload, tuplePos)
tuplePos, tupleLen, err = rlp.ListPrefix(payload, tuplePos)
if err != nil {
return nil, 0, fmt.Errorf("%s: tuple len: %w", ParseTransactionErrorPrefix, err)
}
var addrPos, addrLen int
addrPos, addrLen, err = rlp.ParseStringPrefix(payload, tuplePos)
addrPos, addrLen, err = rlp.StringPrefix(payload, tuplePos)
if err != nil {
return nil, 0, fmt.Errorf("%s: tuple addr len: %w", ParseTransactionErrorPrefix, err)
}
@ -215,14 +215,14 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int) (*TxSlot, i
}
slot.alAddrCount++
var storagePos, storageLen int
storagePos, storageLen, err = rlp.ParseListPrefix(payload, addrPos+addrLen)
storagePos, storageLen, err = rlp.ListPrefix(payload, addrPos+addrLen)
if err != nil {
return nil, 0, fmt.Errorf("%s: storage key list len: %w", ParseTransactionErrorPrefix, err)
}
skeyPos := storagePos
var skeyLen int
for skeyPos < storagePos+storageLen {
skeyPos, skeyLen, err = rlp.ParseStringPrefix(payload, skeyPos)
skeyPos, skeyLen, err = rlp.StringPrefix(payload, skeyPos)
if err != nil {
return nil, 0, fmt.Errorf("%s: tuple storage key len: %w", ParseTransactionErrorPrefix, err)
}