mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-01 04:46:10 +00:00
* mempool: consoldate implementations * update chagelog * fix test * Apply suggestions from code review Co-authored-by: M. J. Fromberger <michael.j.fromberger@gmail.com> * cleanup locking comments * context twiddle * migrate away from deprecated ioutil APIs (#7175) Co-authored-by: Callum Waters <cmwaters19@gmail.com> Co-authored-by: M. J. Fromberger <fromberger@interchain.io> Co-authored-by: M. J. Fromberger <michael.j.fromberger@gmail.com> Co-authored-by: Callum Waters <cmwaters19@gmail.com> Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
50 lines
930 B
Go
50 lines
930 B
Go
package mempool
|
|
|
|
import (
|
|
"context"
|
|
|
|
abciclient "github.com/tendermint/tendermint/abci/client"
|
|
"github.com/tendermint/tendermint/abci/example/kvstore"
|
|
"github.com/tendermint/tendermint/config"
|
|
"github.com/tendermint/tendermint/internal/mempool"
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
)
|
|
|
|
var mp *mempool.TxMempool
|
|
var getMp func() mempool.Mempool
|
|
|
|
func init() {
|
|
app := kvstore.NewApplication()
|
|
cc := abciclient.NewLocalCreator(app)
|
|
appConnMem, _ := cc()
|
|
err := appConnMem.Start()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
cfg := config.DefaultMempoolConfig()
|
|
cfg.Broadcast = false
|
|
|
|
getMp = func() mempool.Mempool {
|
|
if mp == nil {
|
|
mp = mempool.NewTxMempool(
|
|
log.TestingLogger().With("module", "mempool"),
|
|
cfg,
|
|
appConnMem,
|
|
0,
|
|
)
|
|
|
|
}
|
|
return mp
|
|
}
|
|
}
|
|
|
|
func Fuzz(data []byte) int {
|
|
err := getMp().CheckTx(context.Background(), data, nil, mempool.TxInfo{})
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
|
|
return 1
|
|
}
|