forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nop_mempool.go
107 lines (79 loc) · 2.8 KB
/
nop_mempool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package mempool
import (
"errors"
abci "github.com/KYVENetwork/cometbft/v38/abci/types"
"github.com/KYVENetwork/cometbft/v38/libs/service"
"github.com/KYVENetwork/cometbft/v38/p2p"
"github.com/KYVENetwork/cometbft/v38/types"
)
// NopMempool is a mempool that does nothing.
//
// The ABCI app is responsible for storing, disseminating, and proposing transactions.
// See [ADR-111](../docs/architecture/adr-111-nop-mempool.md).
type NopMempool struct{}
// errNotAllowed indicates that the operation is not allowed with `nop` mempool.
var errNotAllowed = errors.New("not allowed with `nop` mempool")
var _ Mempool = &NopMempool{}
// CheckTx always returns an error.
func (*NopMempool) CheckTx(types.Tx, func(*abci.ResponseCheckTx), TxInfo) error {
return errNotAllowed
}
// RemoveTxByKey always returns an error.
func (*NopMempool) RemoveTxByKey(types.TxKey) error { return errNotAllowed }
// ReapMaxBytesMaxGas always returns nil.
func (*NopMempool) ReapMaxBytesMaxGas(int64, int64) types.Txs { return nil }
// ReapMaxTxs always returns nil.
func (*NopMempool) ReapMaxTxs(int) types.Txs { return nil }
// Lock does nothing.
func (*NopMempool) Lock() {}
// Unlock does nothing.
func (*NopMempool) Unlock() {}
// Update does nothing.
func (*NopMempool) Update(
int64,
types.Txs,
[]*abci.ExecTxResult,
PreCheckFunc,
PostCheckFunc,
) error {
return nil
}
// FlushAppConn does nothing.
func (*NopMempool) FlushAppConn() error { return nil }
// Flush does nothing.
func (*NopMempool) Flush() {}
// TxsAvailable always returns nil.
func (*NopMempool) TxsAvailable() <-chan struct{} {
return nil
}
// EnableTxsAvailable does nothing.
func (*NopMempool) EnableTxsAvailable() {}
// SetTxRemovedCallback does nothing.
func (*NopMempool) SetTxRemovedCallback(func(txKey types.TxKey)) {}
// Size always returns 0.
func (*NopMempool) Size() int { return 0 }
// SizeBytes always returns 0.
func (*NopMempool) SizeBytes() int64 { return 0 }
// NopMempoolReactor is a mempool reactor that does nothing.
type NopMempoolReactor struct {
service.BaseService
}
// NewNopMempoolReactor returns a new `nop` reactor.
//
// To be used only in RPC.
func NewNopMempoolReactor() *NopMempoolReactor {
return &NopMempoolReactor{*service.NewBaseService(nil, "NopMempoolReactor", nil)}
}
var _ p2p.Reactor = &NopMempoolReactor{}
// GetChannels always returns nil.
func (*NopMempoolReactor) GetChannels() []*p2p.ChannelDescriptor { return nil }
// AddPeer does nothing.
func (*NopMempoolReactor) AddPeer(p2p.Peer) {}
// InitPeer always returns nil.
func (*NopMempoolReactor) InitPeer(p2p.Peer) p2p.Peer { return nil }
// RemovePeer does nothing.
func (*NopMempoolReactor) RemovePeer(p2p.Peer, interface{}) {}
// Receive does nothing.
func (*NopMempoolReactor) Receive(p2p.Envelope) {}
// SetSwitch does nothing.
func (*NopMempoolReactor) SetSwitch(*p2p.Switch) {}