-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TxVerifier interface to network (#2542)
Signed-off-by: Joshua Kim <[email protected]>
- Loading branch information
1 parent
c950f0f
commit 5888ac3
Showing
5 changed files
with
63 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package network | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/ava-labs/avalanchego/vms/platformvm/txs" | ||
) | ||
|
||
var _ TxVerifier = (*LockedTxVerifier)(nil) | ||
|
||
type TxVerifier interface { | ||
// VerifyTx verifies that the transaction should be issued into the mempool. | ||
VerifyTx(tx *txs.Tx) error | ||
} | ||
|
||
type LockedTxVerifier struct { | ||
lock sync.Locker | ||
txVerifier TxVerifier | ||
} | ||
|
||
func (l *LockedTxVerifier) VerifyTx(tx *txs.Tx) error { | ||
l.lock.Lock() | ||
defer l.lock.Unlock() | ||
|
||
return l.txVerifier.VerifyTx(tx) | ||
} | ||
|
||
func NewLockedTxVerifier(lock sync.Locker, txVerifier TxVerifier) *LockedTxVerifier { | ||
return &LockedTxVerifier{ | ||
lock: lock, | ||
txVerifier: txVerifier, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters