move Mempool interface into mempool package

Refs #2659

Breaking changes in the mempool package:

- Mempool now an interface
- old Mempool renamed to CListMempool

Breaking changes to state package:

- MockMempool moved to mempool/mock package and renamed to Mempool
- Mempool interface moved to mempool package
This commit is contained in:
Anton Kaliaev
2019-04-04 12:48:16 +02:00
parent f965a4db15
commit 5dff5eb012
22 changed files with 958 additions and 895 deletions
+5 -4
View File
@@ -249,7 +249,8 @@ func TestAppCalls(t *testing.T) {
func TestBroadcastTxSync(t *testing.T) {
require := require.New(t)
mempool := node.MempoolReactor().Mempool
// TODO (melekes): use mempool which is set on RPC rather than getting it from node
mempool := node.Mempool()
initMempoolSize := mempool.Size()
for i, c := range GetClients() {
@@ -269,7 +270,7 @@ func TestBroadcastTxSync(t *testing.T) {
func TestBroadcastTxCommit(t *testing.T) {
require := require.New(t)
mempool := node.MempoolReactor().Mempool
mempool := node.Mempool()
for i, c := range GetClients() {
_, _, tx := MakeTxKV()
bres, err := c.BroadcastTxCommit(tx)
@@ -284,7 +285,7 @@ func TestBroadcastTxCommit(t *testing.T) {
func TestUnconfirmedTxs(t *testing.T) {
_, _, tx := MakeTxKV()
mempool := node.MempoolReactor().Mempool
mempool := node.Mempool()
_ = mempool.CheckTx(tx, nil)
for i, c := range GetClients() {
@@ -305,7 +306,7 @@ func TestUnconfirmedTxs(t *testing.T) {
func TestNumUnconfirmedTxs(t *testing.T) {
_, _, tx := MakeTxKV()
mempool := node.MempoolReactor().Mempool
mempool := node.Mempool()
_ = mempool.CheckTx(tx, nil)
mempoolSize := mempool.Size()
+10 -2
View File
@@ -49,6 +49,14 @@ type peers interface {
Peers() p2p.IPeerSet
}
// Mempool extends the standard Mempool interface to allow getting
// total txs size. ReapMaxTxs is used by UnconfirmedTxs to reap N transactions.
type Mempool interface {
mempl.Mempool
ReapMaxTxs(n int) types.Txs
TxsBytes() int64
}
//----------------------------------------------
// These package level globals come with setters
// that are expected to be called only once, on startup
@@ -72,7 +80,7 @@ var (
txIndexer txindex.TxIndexer
consensusReactor *consensus.ConsensusReactor
eventBus *types.EventBus // thread safe
mempool *mempl.Mempool
mempool Mempool
logger log.Logger
@@ -87,7 +95,7 @@ func SetBlockStore(bs sm.BlockStore) {
blockStore = bs
}
func SetMempool(mem *mempl.Mempool) {
func SetMempool(mem Mempool) {
mempool = mem
}