Skip to content

Commit

Permalink
go/byzantine: Filter out duplicate transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Sep 4, 2020
1 parent 625f4b2 commit 07ea935
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/oasis-node/cmd/debug/byzantine/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 07ea935

Please sign in to comment.