From bc6d6e58bc9c405dfe1d4e7a9fce4bfe0c8ced9d Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 14 Jan 2022 19:51:04 +0300 Subject: [PATCH] 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. --- pkg/network/server.go | 6 +++--- pkg/network/server_test.go | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/network/server.go b/pkg/network/server.go index 0f6fa1629..98815b8af 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -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() diff --git a/pkg/network/server_test.go b/pkg/network/server_test.go index 70173e97e..6a6d290da 100644 --- a/pkg/network/server_test.go +++ b/pkg/network/server_test.go @@ -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. }) }