mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-17 08:08:45 +00:00
parse p2p pkg
This commit is contained in:
parent
3f660970ce
commit
a892707c19
@ -181,11 +181,6 @@ func ParsePooledTransactions65(payload []byte, pos int, ctx *TxParseContext, txS
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range txSlots.txs {
|
|
||||||
if txSlots.txs[i] == nil {
|
|
||||||
txSlots.txs[i] = &TxSlot{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i := 0; pos != len(payload); i++ {
|
for i := 0; pos != len(payload); i++ {
|
||||||
txSlots.Growth(i)
|
txSlots.Growth(i)
|
||||||
pos, err = ctx.ParseTransaction(payload, pos, txSlots.txs[i], txSlots.senders.At(i))
|
pos, err = ctx.ParseTransaction(payload, pos, txSlots.txs[i], txSlots.senders.At(i))
|
||||||
@ -210,11 +205,6 @@ func ParsePooledTransactions66(payload []byte, pos int, ctx *TxParseContext, txS
|
|||||||
return requestID, 0, err
|
return requestID, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range txSlots.txs {
|
|
||||||
if txSlots.txs[i] == nil {
|
|
||||||
txSlots.txs[i] = &TxSlot{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i := 0; pos != len(payload); i++ {
|
for i := 0; pos != len(payload); i++ {
|
||||||
txSlots.Growth(i)
|
txSlots.Growth(i)
|
||||||
pos, err = ctx.ParseTransaction(payload, pos, txSlots.txs[i], txSlots.senders.At(i))
|
pos, err = ctx.ParseTransaction(payload, pos, txSlots.txs[i], txSlots.senders.At(i))
|
||||||
|
@ -115,6 +115,9 @@ func (s *TxSlots) Growth(targetSize int) {
|
|||||||
for s.senders.Len() < targetSize {
|
for s.senders.Len() < targetSize {
|
||||||
s.senders = append(s.senders, addressesGrowth...)
|
s.senders = append(s.senders, addressesGrowth...)
|
||||||
}
|
}
|
||||||
|
for i := len(s.txs) - 1; i >= 0 && s.txs[i] == nil; i-- {
|
||||||
|
s.txs[i] = &TxSlot{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -97,15 +97,19 @@ func TestTxSlotsGrowth(t *testing.T) {
|
|||||||
s.Growth(11)
|
s.Growth(11)
|
||||||
assert.Equal(11, len(s.txs))
|
assert.Equal(11, len(s.txs))
|
||||||
assert.Equal(11, s.senders.Len())
|
assert.Equal(11, s.senders.Len())
|
||||||
|
assert.NotNil(s.txs[0])
|
||||||
s.Growth(23)
|
s.Growth(23)
|
||||||
assert.Equal(23, len(s.txs))
|
assert.Equal(23, len(s.txs))
|
||||||
assert.Equal(23, s.senders.Len())
|
assert.Equal(23, s.senders.Len())
|
||||||
|
assert.NotNil(s.txs[12])
|
||||||
|
|
||||||
s = &TxSlots{txs: make([]*TxSlot, 20), senders: make(Addresses, 20*20)}
|
s = &TxSlots{txs: make([]*TxSlot, 20), senders: make(Addresses, 20*20)}
|
||||||
s.Growth(20)
|
s.Growth(20)
|
||||||
assert.Equal(20, len(s.txs))
|
assert.Equal(20, len(s.txs))
|
||||||
assert.Equal(20, s.senders.Len())
|
assert.Equal(20, s.senders.Len())
|
||||||
|
assert.NotNil(s.txs[0])
|
||||||
s.Growth(23)
|
s.Growth(23)
|
||||||
assert.Equal(23, len(s.txs))
|
assert.Equal(23, len(s.txs))
|
||||||
assert.Equal(23, s.senders.Len())
|
assert.Equal(23, s.senders.Len())
|
||||||
|
assert.NotNil(s.txs[21])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user