network: always pass transactions to consensus process

Consensus can require conflicting transactions and it can require more
transactions than mempool can fit, all of this should work. Transactions will
be checked anyway using its secondary mempool. See the scenario from #668.
This commit is contained in:
Roman Khimov 2022-01-14 19:51:04 +03:00
parent 746644a4eb
commit bc6d6e58bc
2 changed files with 4 additions and 6 deletions

View file

@ -965,10 +965,10 @@ func (s *Server) handleTxCmd(tx *transaction.Transaction) error {
}
s.txInMap[tx.Hash()] = struct{}{}
s.txInLock.Unlock()
if s.txCallback != nil {
s.txCallback(tx)
}
if s.verifyAndPoolTX(tx) == nil {
if s.txCallback != nil {
s.txCallback(tx)
}
s.broadcastTX(tx, nil)
}
s.txInLock.Lock()

View file

@ -474,9 +474,7 @@ func TestTransaction(t *testing.T) {
tx := newDummyTx()
s.chain.(*fakechain.FakeChain).PoolTxF = func(*transaction.Transaction) error { return core.ErrInsufficientFunds }
s.testHandleMessage(t, nil, CMDTX, tx)
for _, ftx := range s.services[0].(*fakeConsensus).txs {
require.NotEqual(t, ftx, tx)
}
require.Contains(t, s.services[0].(*fakeConsensus).txs, tx) // Consensus receives everything.
})
}