diff --git a/txpool/pool.go b/txpool/pool.go index 90ec2b64c..685945016 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -295,7 +295,7 @@ func (p *TxPool) OnNewBlock(unwindTxs, minedTxs TxSlots, protocolBaseFee, blockB } func setTxSenderID(senderIDs map[string]uint64, senderInfo map[uint64]*senderInfo, txs TxSlots) { for i := range txs.txs { - id, ok := senderIDs[string(txs.senders[i*20:(i+1)*20])] + id, ok := senderIDs[string(txs.senders.At(i))] if !ok { for i := range senderInfo { //TODO: create field for it? if id < i { @@ -303,7 +303,7 @@ func setTxSenderID(senderIDs map[string]uint64, senderInfo map[uint64]*senderInf } } id++ - senderIDs[string(txs.senders[i*20:(i+1)*20])] = id + senderIDs[string(txs.senders.At(i))] = id } txs.txs[i].senderID = id } diff --git a/txpool/types.go b/txpool/types.go index e2c3b1fb5..5ec45dcb4 100644 --- a/txpool/types.go +++ b/txpool/types.go @@ -37,6 +37,11 @@ type Hashes []byte // flatten list of 32-byte hashes func (h Hashes) At(i int) []byte { return h[i*32 : (i+1)*32] } func (h Hashes) Len() int { return len(h) / 32 } +type Addresses []byte // flatten list of 20-byte addresses + +func (h Addresses) At(i int) []byte { return h[i*20 : (i+1)*20] } +func (h Addresses) Len() int { return len(h) / 20 } + // TxContext is object that is required to parse transactions and turn transaction payload into TxSlot objects // usage of TxContext helps avoid extra memory allocations type TxParseContext struct { @@ -87,7 +92,7 @@ type TxSlot struct { type TxSlots struct { txs []*TxSlot - senders []byte // plain 20-byte addresses + senders Addresses isLocal []bool }