github.com/okex/exchain@v1.8.0/libs/tendermint/mock/mempool.go (about)

     1  package mock
     2  
     3  import (
     4  	"crypto/sha256"
     5  	"fmt"
     6  
     7  	"github.com/okex/exchain/libs/system/trace"
     8  
     9  	abci "github.com/okex/exchain/libs/tendermint/abci/types"
    10  	cfg "github.com/okex/exchain/libs/tendermint/config"
    11  	"github.com/okex/exchain/libs/tendermint/libs/clist"
    12  	mempl "github.com/okex/exchain/libs/tendermint/mempool"
    13  	"github.com/okex/exchain/libs/tendermint/types"
    14  )
    15  
    16  // Mempool is an empty implementation of a Mempool, useful for testing.
    17  type Mempool struct{}
    18  
    19  func (m Mempool) GetAddressList() []string {
    20  	return nil
    21  }
    22  
    23  func (m Mempool) GetTxByHash(hash [sha256.Size]byte) (types.Tx, error) {
    24  	return nil, mempl.ErrNoSuchTx
    25  }
    26  
    27  var _ mempl.Mempool = Mempool{}
    28  
    29  func (Mempool) Lock()     {}
    30  func (Mempool) Unlock()   {}
    31  func (Mempool) Size() int { return 0 }
    32  func (Mempool) CheckTx(_ types.Tx, _ func(*abci.Response), _ mempl.TxInfo) error {
    33  	return nil
    34  }
    35  func (Mempool) ReapMaxBytesMaxGas(_, _ int64) []types.Tx      { return nil }
    36  func (Mempool) ReapEssentialTx(tx types.Tx) abci.TxEssentials { return nil }
    37  func (Mempool) ReapMaxTxs(n int) types.Txs                    { return types.Txs{} }
    38  func (Mempool) ReapUserTxsCnt(address string) int             { return 0 }
    39  func (Mempool) GetUserPendingTxsCnt(address string) int       { return 0 }
    40  func (Mempool) ReapUserTxs(address string, max int) types.Txs { return types.Txs{} }
    41  func (Mempool) GetPendingNonce(address string) (uint64, bool) { return 0, true }
    42  func (Mempool) Update(
    43  	_ int64,
    44  	txs types.Txs,
    45  	deliverTxResponses []*abci.ResponseDeliverTx,
    46  	_ mempl.PreCheckFunc,
    47  	_ mempl.PostCheckFunc,
    48  ) error {
    49  	var gasUsed uint64
    50  	for i := range txs {
    51  		gasUsed += uint64(deliverTxResponses[i].GasUsed)
    52  	}
    53  	trace.GetElapsedInfo().AddInfo(trace.GasUsed, fmt.Sprintf("%d", gasUsed))
    54  	return nil
    55  }
    56  func (Mempool) Flush()                        {}
    57  func (Mempool) FlushAppConn() error           { return nil }
    58  func (Mempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) }
    59  func (Mempool) EnableTxsAvailable()           {}
    60  func (Mempool) TxsBytes() int64               { return 0 }
    61  
    62  func (Mempool) TxsFront() *clist.CElement    { return nil }
    63  func (Mempool) TxsWaitChan() <-chan struct{} { return nil }
    64  
    65  func (Mempool) InitWAL() error                              { return nil }
    66  func (Mempool) CloseWAL()                                   {}
    67  func (Mempool) SetEventBus(eventBus types.TxEventPublisher) {}
    68  
    69  func (Mempool) GetConfig() *cfg.MempoolConfig {
    70  	return cfg.DefaultMempoolConfig()
    71  }
    72  
    73  func (Mempool) SetAccountRetriever(_ mempl.AccountRetriever) {
    74  }
    75  
    76  func (Mempool) SetTxInfoParser(_ mempl.TxInfoParser) {
    77  
    78  }
    79  
    80  func (Mempool) GetTxSimulateGas(txHash string) int64 { return 0 }
    81  
    82  func (Mempool) SetEnableDeleteMinGPTx(enable bool) {
    83  
    84  }
    85  
    86  func (Mempool) GetEnableDeleteMinGPTx() bool {
    87  	return false
    88  }
    89  
    90  func (Mempool) GetPendingPoolTxsBytes() map[string]map[string]types.WrappedMempoolTx {
    91  	return make(map[string]map[string]types.WrappedMempoolTx)
    92  }