diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-12-04 14:54:28 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:54 +0800 |
commit | 6de8d29263b2c184ddd0506d05a18d33554d9788 (patch) | |
tree | e2422fa3bac698e6232dcad4f4434d06aad5f559 /core | |
parent | 114a67a1e4f70e186617b01e766fb49793b73b60 (diff) | |
download | dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.tar dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.tar.gz dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.tar.bz2 dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.tar.lz dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.tar.xz dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.tar.zst dexon-6de8d29263b2c184ddd0506d05a18d33554d9788.zip |
core, dex: Timeout for prepare payload (#72)
* Timeout on prepare payload
* Leave 2 CPU for others
* Add hardLimit and softLimit to PreparePayload
Diffstat (limited to 'core')
-rw-r--r-- | core/blockchain.go | 16 | ||||
-rw-r--r-- | core/types/transaction_signing.go | 5 |
2 files changed, 13 insertions, 8 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 470f7ae28..1b3b22e5e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -270,13 +270,15 @@ func (bc *BlockChain) AddConfirmedBlock(block *coreTypes.Block) error { bc.confirmedBlockInitMu.Unlock() var transactions types.Transactions - err := rlp.Decode(bytes.NewReader(block.Payload), &transactions) - if err != nil { - return err - } - _, err = types.GlobalSigCache.Add(types.NewEIP155Signer(bc.Config().ChainID), transactions) - if err != nil { - return err + if len(block.Payload) != 0 { + err := rlp.Decode(bytes.NewReader(block.Payload), &transactions) + if err != nil { + return err + } + _, err = types.GlobalSigCache.Add(types.NewEIP155Signer(bc.Config().ChainID), transactions) + if err != nil { + return err + } } addressMap := map[common.Address]struct{}{} diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 99e0c7896..1a13e3e3d 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -60,7 +60,10 @@ type resultEntry struct { // Add adds a list of transactions into sig cache. func (c *globalSigCache) Add(signer Signer, txs Transactions) (errorTx *Transaction, err error) { - num := runtime.NumCPU() + num := runtime.NumCPU() - 2 + if num < 1 { + num = 1 + } batchSize := len(txs) / num wg := sync.WaitGroup{} wg.Add(num) |