Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Kim <[email protected]>
  • Loading branch information
joshua-kim committed Dec 20, 2023
1 parent bab6738 commit 2a8befb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vms/platformvm/block/builder/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func newEnvironment(t *testing.T) *environment {
res.sender,
p2pNetwork,
validators,
gossip.NoOpAccumulator[*txs.Tx]{},
gossip.NoOpAccumulator[*network.Tx]{},
gossip.NoOpGossiper{},
p2p.NoOpHandler{},
txGossipHandlerID,
Expand Down
10 changes: 10 additions & 0 deletions vms/platformvm/network/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package network

import (
"context"
"errors"
"fmt"
"sync"
"time"

Expand All @@ -21,6 +23,8 @@ var (
_ gossip.Gossipable = (*Tx)(nil)
_ gossip.Marshaller[*Tx] = (*TxMarshaller)(nil)
_ gossip.Set[*Tx] = (*VerifierMempool)(nil)

ErrTxPending = errors.New("tx pending")
)

// txGossipHandler is the handler called when serving gossip messages
Expand Down Expand Up @@ -81,6 +85,12 @@ type VerifierMempool struct {
}

func (v *VerifierMempool) Add(tx *Tx) error {
if v.Mempool.Has(tx.ID()) {
err := fmt.Errorf("tx %s dropped: %w", tx.ID(), ErrTxPending)
v.Mempool.MarkDropped(tx.ID(), err)
return err
}

if err := v.verifier.VerifyTx(tx.Tx); err != nil {
v.Mempool.MarkDropped(tx.ID(), err)
return err
Expand Down

0 comments on commit 2a8befb

Please sign in to comment.