core: kill off managed state, use own tiny noncer for txpool

This commit is contained in:
Péter Szilágyi
2019-07-09 10:34:35 +03:00
parent 5873c01c3d
commit a966425a1d
6 changed files with 77 additions and 289 deletions

View File

@@ -109,7 +109,7 @@ func validateTxPoolInternals(pool *TxPool) error {
last = nonce
}
}
if nonce := pool.pendingState.GetNonce(addr); nonce != last+1 {
if nonce := pool.Nonce(addr); nonce != last+1 {
return fmt.Errorf("pending nonce mismatch: have %v, want %v", nonce, last+1)
}
}
@@ -195,14 +195,14 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain)
defer pool.Stop()
nonce := pool.State().GetNonce(address)
nonce := pool.Nonce(address)
if nonce != 0 {
t.Fatalf("Invalid nonce, want 0, got %d", nonce)
}
pool.addRemotesSync([]*types.Transaction{tx0, tx1})
nonce = pool.State().GetNonce(address)
nonce = pool.Nonce(address)
if nonce != 2 {
t.Fatalf("Invalid nonce, want 2, got %d", nonce)
}
@@ -215,7 +215,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
if err != nil {
t.Fatalf("Could not fetch pending transactions: %v", err)
}
nonce = pool.State().GetNonce(address)
nonce = pool.Nonce(address)
if nonce != 2 {
t.Fatalf("Invalid nonce, want 2, got %d", nonce)
}
@@ -451,7 +451,7 @@ func TestTransactionNonceRecovery(t *testing.T) {
// simulate some weird re-order of transactions and missing nonce(s)
pool.currentState.SetNonce(addr, n-1)
<-pool.requestReset(nil, nil)
if fn := pool.pendingState.GetNonce(addr); fn != n-1 {
if fn := pool.Nonce(addr); fn != n-1 {
t.Errorf("expected nonce to be %d, got %d", n-1, fn)
}
}