Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add LimitMempoolSize logic for mempool #179

Merged
merged 1 commit into from
Oct 31, 2018
Merged

add LimitMempoolSize logic for mempool #179

merged 1 commit into from
Oct 31, 2018

Conversation

wolfstudy
Copy link
Contributor

@wolfstudy wolfstudy commented Oct 31, 2018

@wolfstudy wolfstudy added help wanted Extra attention is needed mempool mempool development labels Oct 31, 2018
@jjz jjz merged commit 08e1b0d into master Oct 31, 2018
@@ -72,6 +73,16 @@ func (coinsCache *CoinsLruCache) HaveCoin(point *outpoint.OutPoint) bool {
return coin != nil && !coin.IsSpent()
}

func (coinsCache *CoinsLruCache) RemoveCoins(point *outpoint.OutPoint) error {
coinsCache.cacheCoins.Remove(*point)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check whether point exists in cache and do a log before removing it?

coinsTipHash, _ := coinsTip.GetBestBlock()
coinsTipHash, err := coinsTip.GetBestBlock()
if err != nil {
log.Error("get best block error:%s", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return an error on error?

@@ -164,6 +164,7 @@ func RemoveForReorg(nMemPoolHeight int32, flag int) {
pool.CalculateDescendants(it, allRemoves)
}
pool.RemoveStaged(allRemoves, false, mempool.REORG)
pool.LimitMempoolSize(conf.Cfg.Mempool.MaxPoolSize, int64(conf.Cfg.Mempool.MaxPoolExpiry)*60*60)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to do trim when a TX is evicted from pool. Whey should we trim it after removing some?

@@ -128,6 +128,7 @@ func (m *TxMempool) AddTx(txEntry *TxEntry, ancestors map[*TxEntry]struct{}) err
if txEntry.SumTxCountWithAncestors == 1 {
m.rootTx[txEntry.Tx.GetHash()] = txEntry
}
m.LimitMempoolSize(conf.Cfg.Mempool.MaxPoolSize, int64(conf.Cfg.Mempool.MaxPoolExpiry)*60*60)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newly added tx may be evicted. We should check whether it still exists to return different error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed mempool mempool development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants