Skip to content

Commit

Permalink
clean up txnPool logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Sep 12, 2022
1 parent 4ab2153 commit 7f7c27e
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,21 @@ func (s *Service) maintainTransactionPool(block *types.Block) {
s.transactionState.RemoveExtrinsic(ext)
}

//// get the best block corresponding runtime
bestBlockHash := s.blockState.BestBlockHash()
stateRoot, err := s.storageState.GetStateRootFromBlock(&bestBlockHash)
if err != nil {
logger.Errorf("could not get state root from block %s: %w", bestBlockHash, err)
}

ts, err := s.storageState.TrieState(stateRoot)
if err != nil {
logger.Errorf(err.Error())
}

// re-validate transactions in the pool and move them to the queue
txs := s.transactionState.PendingInPool()
for _, tx := range txs {
//// get the best block corresponding runtime
bestBlockHash := s.blockState.BestBlockHash()
stateRoot, err := s.storageState.GetStateRootFromBlock(&bestBlockHash)
if err != nil {
logger.Errorf("could not get state root from block %s: %w", bestBlockHash, err)
}

ts, err := s.storageState.TrieState(stateRoot)
if err != nil {
logger.Errorf(err.Error())
}

rt, err := s.blockState.GetRuntime(&bestBlockHash)
if err != nil {
logger.Warnf("failed to get runtime to re-validate transactions in pool: %s", err)
Expand All @@ -411,7 +411,6 @@ func (s *Service) maintainTransactionPool(block *types.Block) {
txnValidity, err := rt.ValidateTransaction(externalExt)
if err != nil {
// hitting this case on old runtime
fmt.Println(err.Error())
s.transactionState.RemoveExtrinsic(tx.Extrinsic)
continue
}
Expand Down

0 comments on commit 7f7c27e

Please sign in to comment.