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 21:32:52 +0800
commit2b99b89e5af0cf9feca3ab532629f8fab3858edc (patch)
treef02dbbb15fac9703d6d29230a89b0bab572c23ca /core/blockchain.go
parent48cd626abe5169e87e6a7f264f4f6cfda71c8e1f (diff)
downloaddexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.tar
dexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.tar.gz
dexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.tar.bz2
dexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.tar.lz
dexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.tar.xz
dexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.tar.zst
dexon-2b99b89e5af0cf9feca3ab532629f8fab3858edc.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))