mirror of
https://github.com/luxfi/proto.git
synced 2026-10-30 15:21:09 +00:00
37 lines
745 B
Go
37 lines
745 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package network
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/luxfi/proto/p/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,
|
|
}
|
|
}
|