Bug Fix on memory leak when doing send tx, block etc to peers (#212)

* resolve conflict

* update version number
This commit is contained in:
Liam 2022-12-09 14:54:27 +08:00 committed by GitHub
parent 78e30c2637
commit f57e2c3577
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 5 deletions

2
.gitignore vendored
View file

@ -49,4 +49,4 @@ profile.cov
**/yarn-error.log
coverage.txt
go.sum
go.sum

View file

@ -160,6 +160,9 @@ func (p *peer) MarkLendingTransaction(hash common.Hash) {
// SendTransactions sends transactions to the peer and includes the hashes
// in its transaction hash set for future reference.
func (p *peer) SendTransactions(txs types.Transactions) error {
for p.knownTxs.Cardinality() >= maxKnownTxs {
p.knownTxs.Pop()
}
for _, tx := range txs {
p.knownTxs.Add(tx.Hash())
}
@ -169,6 +172,10 @@ func (p *peer) SendTransactions(txs types.Transactions) error {
// SendTransactions sends transactions to the peer and includes the hashes
// in its transaction hash set for future reference.
func (p *peer) SendOrderTransactions(txs types.OrderTransactions) error {
for p.knownOrderTxs.Cardinality() >= maxKnownOrderTxs {
p.knownOrderTxs.Pop()
}
for _, tx := range txs {
p.knownOrderTxs.Add(tx.Hash())
}
@ -178,6 +185,10 @@ func (p *peer) SendOrderTransactions(txs types.OrderTransactions) error {
// SendTransactions sends transactions to the peer and includes the hashes
// in its transaction hash set for future reference.
func (p *peer) SendLendingTransactions(txs types.LendingTransactions) error {
for p.knownLendingTxs.Cardinality() >= maxKnownLendingTxs {
p.knownLendingTxs.Pop()
}
for _, tx := range txs {
p.knownLendingTxs.Add(tx.Hash())
}
@ -187,6 +198,10 @@ func (p *peer) SendLendingTransactions(txs types.LendingTransactions) error {
// SendNewBlockHashes announces the availability of a number of blocks through
// a hash notification.
func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error {
for p.knownBlocks.Cardinality() >= maxKnownBlocks {
p.knownBlocks.Pop()
}
for _, hash := range hashes {
p.knownBlocks.Add(hash)
}
@ -200,6 +215,10 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error
// SendNewBlock propagates an entire block to a remote peer.
func (p *peer) SendNewBlock(block *types.Block, td *big.Int) error {
for p.knownBlocks.Cardinality() >= maxKnownBlocks {
p.knownBlocks.Pop()
}
p.knownBlocks.Add(block.Hash())
if p.pairRw != nil {
return p2p.Send(p.pairRw, NewBlockMsg, []interface{}{block, td})

View file

@ -96,7 +96,7 @@ var Flags = []cli.Flag{
//pprofPortFlag,
//memprofilerateFlag,
//blockprofilerateFlag,
//cpuprofileFlag,
cpuprofileFlag,
//traceFlag,
}

View file

@ -21,9 +21,9 @@ import (
)
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 4 // Minor version component of the current release
VersionPatch = 5 // Patch version component of the current release
VersionMajor = 1 // Major version component of the current release
VersionMinor = 4 // Minor version component of the current release
VersionPatch = 6 // Patch version component of the current release
VersionMeta = "stable" // Version metadata to append to the version string
)