diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 42d529b..67f4b72 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -230,7 +230,7 @@ func Blockchain_Start(params map[string]interface{}) (*Blockchain, error) { // logger.Fatalf("Testing complete quitting") - //go clean_up_valid_cache() // clean up valid cache + go clean_up_valid_cache() // clean up valid cache /* txlist := chain.Mempool.Mempool_List_TX() for i := range txlist { @@ -1501,7 +1501,7 @@ func (chain *Blockchain) Rewind_Chain(rewind_count int) (result bool) { panic(err) } - if chain.IsBlockSyncBlockHeight(r.BLOCK_ID) || r.Height == 0 { + if chain.IsBlockSyncBlockHeight(r.BLOCK_ID) || r.Height == 1 { break } diff --git a/blockchain/transaction_verify.go b/blockchain/transaction_verify.go index 80a7b7b..53dd1be 100644 --- a/blockchain/transaction_verify.go +++ b/blockchain/transaction_verify.go @@ -105,14 +105,14 @@ func (chain *Blockchain) Verify_Transaction_Coinbase(cbl *block.Complete_Block, if _, err := balance_tree.Get(minertx.MinerAddress[:]); err != nil { //logger.Infof("balance not obtained err %s\n",err) - return false + //return false } else { return true } } - return true + return false } // all non miner tx must be non-coinbase tx @@ -137,8 +137,17 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase(hf_version int64, tx *tr return false } + tx_hash = tx.GetHash() + if tx.TransactionType == transaction.REGISTRATION { + if _, ok := transaction_valid_cache.Load(tx_hash); ok { + return true //logger.Infof("Found in cache %s ",tx_hash) + } else { + //logger.Infof("TX not found in cache %s len %d ",tx_hash, len(tmp_buffer)) + } + if tx.IsRegistrationValid() { + transaction_valid_cache.Store(tx_hash, time.Now()) // signature got verified, cache it return true } return false @@ -230,6 +239,12 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase(hf_version int64, tx *tr panic("mentioned balance tree not found, cannot verify TX") } + if _, ok := transaction_valid_cache.Load(tx_hash); ok { + return true //logger.Infof("Found in cache %s ",tx_hash) + } else { + //logger.Infof("TX not found in cache %s len %d ",tx_hash, len(tmp_buffer)) + } + //logger.Infof("dTX state tree has been found") // now lets calculate CLn and CRn @@ -251,6 +266,7 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase(hf_version int64, tx *tr if tx.Proof.Verify(&tx.Statement, tx.GetHash()) { //logger.Infof("dTX verified with proof successfuly") + transaction_valid_cache.Store(tx_hash, time.Now()) // signature got verified, cache it return true } logger.Infof("transaction verification failed\n") diff --git a/config/version.go b/config/version.go index 9fefb1c..60f370a 100644 --- a/config/version.go +++ b/config/version.go @@ -20,4 +20,4 @@ import "github.com/blang/semver" // right now it has to be manually changed // do we need to include git commitsha?? -var Version = semver.MustParse("3.0.0-24.DEROHE.alpha+30122020") +var Version = semver.MustParse("3.0.0-25.DEROHE.alpha+30122020")