From 80ac448d4043d8fbd8466b979f8cc11032a64df7 Mon Sep 17 00:00:00 2001 From: David Terpay Date: Tue, 15 Aug 2023 11:24:18 -0400 Subject: [PATCH] done wit bb --- block/constructor/mempool.go | 13 ++++++------- block/{ => constructor}/priority_nonce.go | 14 +++++++++++++- lanes/free/lane.go | 2 +- lanes/mev/mempool.go | 6 +++--- 4 files changed, 23 insertions(+), 12 deletions(-) rename block/{ => constructor}/priority_nonce.go (94%) diff --git a/block/constructor/mempool.go b/block/constructor/mempool.go index cf0f282..7a9d6e4 100644 --- a/block/constructor/mempool.go +++ b/block/constructor/mempool.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool" - "github.com/skip-mev/pob/block" "github.com/skip-mev/pob/block/utils" ) @@ -25,7 +24,7 @@ type ( // retrieve the priority of a given transaction and to compare the priority // of two transactions. The index utilizes this struct to order transactions // in the mempool. - txPriority block.TxPriority[C] + txPriority TxPriority[C] // txEncoder defines the sdk.Tx encoder that allows us to encode transactions // to bytes. @@ -39,8 +38,8 @@ type ( // DefaultTxPriority returns a default implementation of the TxPriority. It prioritizes // transactions by their fee. -func DefaultTxPriority() block.TxPriority[string] { - return block.TxPriority[string]{ +func DefaultTxPriority() TxPriority[string] { + return TxPriority[string]{ GetTxPriority: func(goCtx context.Context, tx sdk.Tx) string { feeTx, ok := tx.(sdk.FeeTx) if !ok { @@ -81,10 +80,10 @@ func DefaultTxPriority() block.TxPriority[string] { } // NewConstructorMempool returns a new ConstructorMempool. -func NewConstructorMempool[C comparable](txPriority block.TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *ConstructorMempool[C] { +func NewConstructorMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *ConstructorMempool[C] { return &ConstructorMempool[C]{ - index: block.NewPriorityMempool( - block.PriorityNonceMempoolConfig[C]{ + index: NewPriorityMempool( + PriorityNonceMempoolConfig[C]{ TxPriority: txPriority, MaxTx: maxTx, }, diff --git a/block/priority_nonce.go b/block/constructor/priority_nonce.go similarity index 94% rename from block/priority_nonce.go rename to block/constructor/priority_nonce.go index 352428f..c5ee7bd 100644 --- a/block/priority_nonce.go +++ b/block/constructor/priority_nonce.go @@ -1,4 +1,16 @@ -package block +package constructor + +// ------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------ // +// NOTE: THIS IS A COPY OF THE PRIORITY NONCE MEMPOOL FROM COSMOS-SDK. IT HAS BEEN +// MODIFIED FOR OUR USE CASE. THIS CODE WILL BE DEPRECATED ONCE THE COSMOS-SDK +// CUTS A FINAL v0.50.0 RELEASE. +// ------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------ // import ( "context" diff --git a/lanes/free/lane.go b/lanes/free/lane.go index 2054462..1608524 100644 --- a/lanes/free/lane.go +++ b/lanes/free/lane.go @@ -23,7 +23,7 @@ type FreeLane struct { // NewFreeLane returns a new free lane. func NewFreeLane( cfg block.LaneConfig, - txPriority block.TxPriority[string], + txPriority constructor.TxPriority[string], matchFn block.MatchHandler, ) *FreeLane { lane := constructor.NewLaneConstructor[string]( diff --git a/lanes/mev/mempool.go b/lanes/mev/mempool.go index 4f4d89c..d130770 100644 --- a/lanes/mev/mempool.go +++ b/lanes/mev/mempool.go @@ -4,13 +4,13 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/skip-mev/pob/block" + "github.com/skip-mev/pob/block/constructor" ) // TxPriority returns a TxPriority over mev lane transactions only. It // is to be used in the mev index only. -func TxPriority(config Factory) block.TxPriority[string] { - return block.TxPriority[string]{ +func TxPriority(config Factory) constructor.TxPriority[string] { + return constructor.TxPriority[string]{ GetTxPriority: func(goCtx context.Context, tx sdk.Tx) string { bidInfo, err := config.GetAuctionBidInfo(tx) if err != nil {