cmd/faucet: clear reqs list when reorg to lower nonce (#1458)

This commit is contained in:
Leon 2023-04-14 09:52:15 +08:00 committed by GitHub
parent b4f1cdffd5
commit e4b6ab9ba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -667,6 +667,9 @@ func (f *faucet) refresh(head *types.Header) error {
f.lock.Lock()
f.head, f.balance = head, balance
f.price, f.nonce = price, nonce
if len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() > f.nonce {
f.reqs = f.reqs[:0]
}
for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
f.reqs = f.reqs[1:]
}