aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-31 18:21:55 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:49:55 +0800
commita199c7511aae821cd42710f7ae0c849fee18abae (patch)
treef38def9ea2fc3ce2f3922792e0fceba200d65000 /core/blockchain.go
parentcbfe0ea7bf7308c864794247fbb551a930b204b7 (diff)
downloaddexon-a199c7511aae821cd42710f7ae0c849fee18abae.tar.gz
dexon-a199c7511aae821cd42710f7ae0c849fee18abae.tar.zst
dexon-a199c7511aae821cd42710f7ae0c849fee18abae.zip
core: tx_pool: remove transactions on BlockConfirmed event
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 0e86f2b59..264617857 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -104,14 +104,15 @@ type BlockChain struct {
triegc *prque.Prque // Priority queue mapping block numbers to tries to gc
gcproc time.Duration // Accumulates canonical block processing for trie dumping
- hc *HeaderChain
- rmLogsFeed event.Feed
- chainFeed event.Feed
- chainSideFeed event.Feed
- chainHeadFeed event.Feed
- logsFeed event.Feed
- scope event.SubscriptionScope
- genesisBlock *types.Block
+ hc *HeaderChain
+ rmLogsFeed event.Feed
+ chainFeed event.Feed
+ chainSideFeed event.Feed
+ chainHeadFeed event.Feed
+ blockConfirmedFeed event.Feed
+ logsFeed event.Feed
+ scope event.SubscriptionScope
+ genesisBlock *types.Block
mu sync.RWMutex // global mutex for locking chain operations
chainmu sync.RWMutex // blockchain insertion lock
@@ -1610,6 +1611,7 @@ func (bc *BlockChain) processPendingBlock(block *types.Block, witness *coreTypes
// add into pending blocks
bc.addPendingBlock(newPendingBlock, receipts)
+ events = append(events, BlockConfirmedEvent{newPendingBlock})
// start insert available pending blocks into db
for pendingHeight := bc.CurrentBlock().NumberU64() + 1; pendingHeight <= witness.Height; pendingHeight++ {
@@ -1852,6 +1854,9 @@ func (bc *BlockChain) PostChainEvents(events []interface{}, logs []*types.Log) {
case ChainHeadEvent:
bc.chainHeadFeed.Send(ev)
+ case BlockConfirmedEvent:
+ bc.blockConfirmedFeed.Send(ev)
+
case ChainSideEvent:
bc.chainSideFeed.Send(ev)
}
@@ -2044,6 +2049,11 @@ func (bc *BlockChain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Su
return bc.scope.Track(bc.chainHeadFeed.Subscribe(ch))
}
+// SubscribeBlockConfirmedEvent registers a subscription of ChainHeadEvent.
+func (bc *BlockChain) SubscribeBlockConfirmedEvent(ch chan<- BlockConfirmedEvent) event.Subscription {
+ return bc.scope.Track(bc.blockConfirmedFeed.Subscribe(ch))
+}
+
// SubscribeChainSideEvent registers a subscription of ChainSideEvent.
func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Subscription {
return bc.scope.Track(bc.chainSideFeed.Subscribe(ch))