github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/tendermint/mock/mempool.go (about)

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