aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <aitjcize@gmail.com>2018-11-13 15:26:21 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:18 +0800
commitaec90eae15b9ad106e3443fc5c5ab6f285e131a0 (patch)
tree0e94fd18c8f3667d36a5b29587c98e1d105968aa /core
parent74111db752635adcfe39cb309b8335aa50a1e90a (diff)
downloadgo-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.tar
go-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.tar.gz
go-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.tar.bz2
go-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.tar.lz
go-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.tar.xz
go-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.tar.zst
go-tangerine-aec90eae15b9ad106e3443fc5c5ab6f285e131a0.zip
dex: return correct pending nonce (#14)
We need to return the correct pending nonce (include those in the tx pool). Also, StateAndHeaderByNumber is also fixed to use pending block.
Diffstat (limited to 'core')
-rw-r--r--core/blockchain.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index dce1c276a..3c9e9701d 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -1779,20 +1779,29 @@ func (bc *BlockChain) addPendingBlock(block *types.Block, receipts types.Receipt
bc.lastPendingHeight = block.NumberU64()
}
-func (bc *BlockChain) GetLastPendingHeight() uint64 {
+func (bc *BlockChain) GetPendingHeight() uint64 {
bc.pendingBlockMu.RLock()
defer bc.pendingBlockMu.RUnlock()
return bc.lastPendingHeight
}
-func (bc *BlockChain) GetLastPendingBlock() *types.Block {
+func (bc *BlockChain) GetPendingBlock() *types.Block {
bc.pendingBlockMu.RLock()
defer bc.pendingBlockMu.RUnlock()
return bc.pendingBlocks[bc.lastPendingHeight].block
}
+func (bc *BlockChain) GetPending() (*types.Block, *state.StateDB) {
+ block := bc.GetPendingBlock()
+ s, err := state.New(block.Header().Root, bc.stateCache)
+ if err != nil {
+ panic(err)
+ }
+ return block, s
+}
+
// reorg takes two blocks, an old chain and a new chain and will reconstruct the
// blocks and inserts them to be part of the new canonical chain and accumulates
// potential missing transactions and post an event about them.