mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-01 14:26:02 +00:00
fix issue about missing mempool config
This commit is contained in:
parent
4ff1ab24d1
commit
9b171dbd4c
@ -129,7 +129,7 @@ func (ac appCreator) newApp(
|
||||
)
|
||||
|
||||
mempool := app.NewPriorityMempool(
|
||||
app.PriorityNonceWithMaxTx(cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs))),
|
||||
app.PriorityNonceWithMaxTx(fixMempoolSize(appOpts)),
|
||||
app.PriorityNonceWithTxReplacedCallback(func(ctx context.Context, oldTx, newTx sdk.Tx) {
|
||||
bApp.RegisterMempoolTxReplacedEvent(ctx, oldTx, newTx)
|
||||
}),
|
||||
@ -259,3 +259,23 @@ func extractTxInfo(ctx sdk.Context, tx sdk.Tx) (*sdk.TxInfo, error) {
|
||||
TxType: txType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func fixMempoolSize(appOpts servertypes.AppOptions) int {
|
||||
val1 := appOpts.Get("mempool.size")
|
||||
val2 := appOpts.Get(server.FlagMempoolMaxTxs)
|
||||
|
||||
if val1 != nil && val2 != nil {
|
||||
size1 := cast.ToInt(val1)
|
||||
size2 := cast.ToInt(val2)
|
||||
if size1 != size2 {
|
||||
panic("the value of mempool.size and mempool.max-txs are different")
|
||||
}
|
||||
return size1
|
||||
} else if val1 == nil && val2 == nil {
|
||||
panic("not found mempool size in config")
|
||||
} else if val1 == nil {
|
||||
return cast.ToInt(val2)
|
||||
} else { //if val2 == nil {
|
||||
return cast.ToInt(val1)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user