From 07ea93558983fdf3ecbd0f8dd93fa0100ad96b1c Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Fri, 4 Sep 2020 22:17:45 +0200 Subject: [PATCH] go/byzantine: Filter out duplicate transactions --- go/oasis-node/cmd/debug/byzantine/executor.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/go/oasis-node/cmd/debug/byzantine/executor.go b/go/oasis-node/cmd/debug/byzantine/executor.go index a822ecab589..c041e44c03c 100644 --- a/go/oasis-node/cmd/debug/byzantine/executor.go +++ b/go/oasis-node/cmd/debug/byzantine/executor.go @@ -46,6 +46,7 @@ func newComputeBatchContext() *computeBatchContext { func (cbc *computeBatchContext) receiveTransactions(ph *p2pHandle, timeout time.Duration) []*api.Tx { var req p2pReqRes txs := []*api.Tx{} + existing := make(map[hash.Hash]bool) ReceiveTransactions: for { @@ -55,7 +56,13 @@ ReceiveTransactions: if req.msg.Tx == nil { continue } + txHash := hash.NewFromBytes(req.msg.Tx.Data) + if existing[txHash] { + continue + } + txs = append(txs, req.msg.Tx) + existing[txHash] = true case <-time.After(timeout): break ReceiveTransactions }