@@ -160,6 +160,9 @@ func (p *peer) MarkLendingTransaction(hash common.Hash) {
160
160
// SendTransactions sends transactions to the peer and includes the hashes
161
161
// in its transaction hash set for future reference.
162
162
func (p * peer ) SendTransactions (txs types.Transactions ) error {
163
+ for p .knownTxs .Cardinality () >= maxKnownTxs {
164
+ p .knownTxs .Pop ()
165
+ }
163
166
for _ , tx := range txs {
164
167
p .knownTxs .Add (tx .Hash ())
165
168
}
@@ -169,6 +172,10 @@ func (p *peer) SendTransactions(txs types.Transactions) error {
169
172
// SendTransactions sends transactions to the peer and includes the hashes
170
173
// in its transaction hash set for future reference.
171
174
func (p * peer ) SendOrderTransactions (txs types.OrderTransactions ) error {
175
+ for p .knownOrderTxs .Cardinality () >= maxKnownOrderTxs {
176
+ p .knownOrderTxs .Pop ()
177
+ }
178
+
172
179
for _ , tx := range txs {
173
180
p .knownOrderTxs .Add (tx .Hash ())
174
181
}
@@ -178,6 +185,10 @@ func (p *peer) SendOrderTransactions(txs types.OrderTransactions) error {
178
185
// SendTransactions sends transactions to the peer and includes the hashes
179
186
// in its transaction hash set for future reference.
180
187
func (p * peer ) SendLendingTransactions (txs types.LendingTransactions ) error {
188
+ for p .knownLendingTxs .Cardinality () >= maxKnownLendingTxs {
189
+ p .knownLendingTxs .Pop ()
190
+ }
191
+
181
192
for _ , tx := range txs {
182
193
p .knownLendingTxs .Add (tx .Hash ())
183
194
}
@@ -187,6 +198,10 @@ func (p *peer) SendLendingTransactions(txs types.LendingTransactions) error {
187
198
// SendNewBlockHashes announces the availability of a number of blocks through
188
199
// a hash notification.
189
200
func (p * peer ) SendNewBlockHashes (hashes []common.Hash , numbers []uint64 ) error {
201
+ for p .knownBlocks .Cardinality () >= maxKnownBlocks {
202
+ p .knownBlocks .Pop ()
203
+ }
204
+
190
205
for _ , hash := range hashes {
191
206
p .knownBlocks .Add (hash )
192
207
}
@@ -200,6 +215,10 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error
200
215
201
216
// SendNewBlock propagates an entire block to a remote peer.
202
217
func (p * peer ) SendNewBlock (block * types.Block , td * big.Int ) error {
218
+ for p .knownBlocks .Cardinality () >= maxKnownBlocks {
219
+ p .knownBlocks .Pop ()
220
+ }
221
+
203
222
p .knownBlocks .Add (block .Hash ())
204
223
if p .pairRw != nil {
205
224
return p2p .Send (p .pairRw , NewBlockMsg , []interface {}{block , td })
0 commit comments