aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-06-04 19:09:16 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-06-05 16:03:55 +0800
commit2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384 (patch)
treeff4442a8da2b097e804a14b1255fee8ba3376b72 /core/blockchain.go
parent400332b99d4eacb6aa509339fa39460b68f76ee7 (diff)
downloadgo-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.tar
go-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.tar.gz
go-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.tar.bz2
go-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.tar.lz
go-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.tar.xz
go-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.tar.zst
go-tangerine-2ab24a2a8f864e8c2f3c7ad2d494ccf02ffd8384.zip
core: concurrent background transaction sender ecrecover
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 3eee75df7..bf1bbe6cb 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -1005,6 +1005,10 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
// only reason this method exists as a separate one is to make locking cleaner
// with deferred statements.
func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*types.Log, error) {
+ // Sanity check that we have something meaningful to import
+ if len(chain) == 0 {
+ return 0, nil, nil, nil
+ }
// Do a sanity check that the provided chain is actually ordered and linked
for i := 1; i < len(chain); i++ {
if chain[i].NumberU64() != chain[i-1].NumberU64()+1 || chain[i].ParentHash() != chain[i-1].Hash() {
@@ -1043,6 +1047,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
abort, results := bc.engine.VerifyHeaders(bc, headers, seals)
defer close(abort)
+ // Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss)
+ senderCacher.recoverFromBlocks(types.MakeSigner(bc.chainConfig, chain[0].Number()), chain)
+
// Iterate over the blocks and insert when the verifier permits
for i, block := range chain {
// If the chain is terminating, stop processing blocks