Skip to content

Commit f57e2c3

Browse files
authored
Bug Fix on memory leak when doing send tx, block etc to peers (ethereum#212)
* resolve conflict * update version number
1 parent 78e30c2 commit f57e2c3

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ profile.cov
4949

5050
**/yarn-error.log
5151
coverage.txt
52-
go.sum
52+
go.sum

eth/peer.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ func (p *peer) MarkLendingTransaction(hash common.Hash) {
160160
// SendTransactions sends transactions to the peer and includes the hashes
161161
// in its transaction hash set for future reference.
162162
func (p *peer) SendTransactions(txs types.Transactions) error {
163+
for p.knownTxs.Cardinality() >= maxKnownTxs {
164+
p.knownTxs.Pop()
165+
}
163166
for _, tx := range txs {
164167
p.knownTxs.Add(tx.Hash())
165168
}
@@ -169,6 +172,10 @@ func (p *peer) SendTransactions(txs types.Transactions) error {
169172
// SendTransactions sends transactions to the peer and includes the hashes
170173
// in its transaction hash set for future reference.
171174
func (p *peer) SendOrderTransactions(txs types.OrderTransactions) error {
175+
for p.knownOrderTxs.Cardinality() >= maxKnownOrderTxs {
176+
p.knownOrderTxs.Pop()
177+
}
178+
172179
for _, tx := range txs {
173180
p.knownOrderTxs.Add(tx.Hash())
174181
}
@@ -178,6 +185,10 @@ func (p *peer) SendOrderTransactions(txs types.OrderTransactions) error {
178185
// SendTransactions sends transactions to the peer and includes the hashes
179186
// in its transaction hash set for future reference.
180187
func (p *peer) SendLendingTransactions(txs types.LendingTransactions) error {
188+
for p.knownLendingTxs.Cardinality() >= maxKnownLendingTxs {
189+
p.knownLendingTxs.Pop()
190+
}
191+
181192
for _, tx := range txs {
182193
p.knownLendingTxs.Add(tx.Hash())
183194
}
@@ -187,6 +198,10 @@ func (p *peer) SendLendingTransactions(txs types.LendingTransactions) error {
187198
// SendNewBlockHashes announces the availability of a number of blocks through
188199
// a hash notification.
189200
func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error {
201+
for p.knownBlocks.Cardinality() >= maxKnownBlocks {
202+
p.knownBlocks.Pop()
203+
}
204+
190205
for _, hash := range hashes {
191206
p.knownBlocks.Add(hash)
192207
}
@@ -200,6 +215,10 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error
200215

201216
// SendNewBlock propagates an entire block to a remote peer.
202217
func (p *peer) SendNewBlock(block *types.Block, td *big.Int) error {
218+
for p.knownBlocks.Cardinality() >= maxKnownBlocks {
219+
p.knownBlocks.Pop()
220+
}
221+
203222
p.knownBlocks.Add(block.Hash())
204223
if p.pairRw != nil {
205224
return p2p.Send(p.pairRw, NewBlockMsg, []interface{}{block, td})

internal/debug/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var Flags = []cli.Flag{
9696
//pprofPortFlag,
9797
//memprofilerateFlag,
9898
//blockprofilerateFlag,
99-
//cpuprofileFlag,
99+
cpuprofileFlag,
100100
//traceFlag,
101101
}
102102

params/version.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
)
2222

2323
const (
24-
VersionMajor = 1 // Major version component of the current release
25-
VersionMinor = 4 // Minor version component of the current release
26-
VersionPatch = 5 // Patch version component of the current release
24+
VersionMajor = 1 // Major version component of the current release
25+
VersionMinor = 4 // Minor version component of the current release
26+
VersionPatch = 6 // Patch version component of the current release
2727
VersionMeta = "stable" // Version metadata to append to the version string
2828
)
2929

0 commit comments

Comments
 (0)