aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorBJ4 <bojie@dexon.org>2018-11-15 16:02:19 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:18 +0800
commitd945ea451bece3c8e230ae017dd443266633d634 (patch)
tree1f5f47f05639d42e836f47eaccaa90773261db7d /core/blockchain.go
parentdbb3d8fd30bd33df37f13048dc334ead8d335ddc (diff)
downloadgo-tangerine-d945ea451bece3c8e230ae017dd443266633d634.tar
go-tangerine-d945ea451bece3c8e230ae017dd443266633d634.tar.gz
go-tangerine-d945ea451bece3c8e230ae017dd443266633d634.tar.bz2
go-tangerine-d945ea451bece3c8e230ae017dd443266633d634.tar.lz
go-tangerine-d945ea451bece3c8e230ae017dd443266633d634.tar.xz
go-tangerine-d945ea451bece3c8e230ae017dd443266633d634.tar.zst
go-tangerine-d945ea451bece3c8e230ae017dd443266633d634.zip
app: add cache to reuse same tx address which has already recovered (#26)
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 4f3eefc1d..c364e57d2 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -249,6 +249,7 @@ func (bc *BlockChain) GetVMConfig() *vm.Config {
type blockInfo struct {
addresses map[common.Address]struct{}
block *coreTypes.Block
+ txs types.Transactions
}
func (bc *BlockChain) AddConfirmedBlock(block *coreTypes.Block) error {
@@ -298,6 +299,7 @@ func (bc *BlockChain) AddConfirmedBlock(block *coreTypes.Block) error {
bc.confirmedBlocks[chainID][block.Hash] = &blockInfo{
addresses: addressMap,
block: block,
+ txs: transactions,
}
bc.chainLastHeight[chainID] = block.Position.Height
return nil
@@ -317,8 +319,8 @@ func (bc *BlockChain) RemoveConfirmedBlock(chainID uint32, hash coreCommon.Hash)
delete(bc.confirmedBlocks[chainID], hash)
}
-func (bc *BlockChain) GetConfirmedBlockByHash(chainID uint32, hash coreCommon.Hash) *coreTypes.Block {
- return bc.confirmedBlocks[chainID][hash].block
+func (bc *BlockChain) GetConfirmedBlockByHash(chainID uint32, hash coreCommon.Hash) (*coreTypes.Block, types.Transactions) {
+ return bc.confirmedBlocks[chainID][hash].block, bc.confirmedBlocks[chainID][hash].txs
}
func (bc *BlockChain) GetLastNonceInConfirmedBlocks(chainID uint32, address common.Address) (uint64, bool) {