Skip to content

Commit

Permalink
refactor: 🚚 mev: rename bundle sender -> client
Browse files Browse the repository at this point in the history
Signed-off-by: thanhpp <[email protected]>
  • Loading branch information
thanhpp committed Jan 4, 2024
1 parent 3ab3673 commit 0c70f51
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions pkg/mev/bloxroute_submit_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ const (
BuilderAll BlxrBuilder = "all"
)

type BloxrouteBundleSender struct {
type BloxrouteClient struct {
c *http.Client
endpoint string
auth string
flashbotKey *ecdsa.PrivateKey
enabledBuilders []BlxrBuilder
}

// NewBloxrouteBundleSender set flashbotKey to nil if you don't want to send to flashbot builders
// NewBloxrouteClient set flashbotKey to nil if you don't want to send to flashbot builders
// With BuilderAll still need to add the flashbot key & the flashbot builder separately
// https://docs.bloxroute.com/apis/mev-solution/bundle-submission
func NewBloxrouteBundleSender(
func NewBloxrouteClient(
c *http.Client,
endpoint, auth string,
flashbotKey *ecdsa.PrivateKey,
enabledBuilders ...BlxrBuilder,
) *BloxrouteBundleSender {
return &BloxrouteBundleSender{
) *BloxrouteClient {
return &BloxrouteClient{
c: c,
endpoint: endpoint,
auth: auth,
Expand All @@ -50,7 +50,7 @@ func NewBloxrouteBundleSender(
}
}

func (s *BloxrouteBundleSender) Send(
func (s *BloxrouteClient) SendBundle(
ctx context.Context, blockNumber uint64, txs ...*types.Transaction,
) (SendBundleResponse, error) {
p := new(BLXRSubmitBundleParams).SetBlockNumber(blockNumber).SetTransactions(txs...)
Expand Down
6 changes: 3 additions & 3 deletions pkg/mev/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const (
)

type IBundleSender interface {
Send(ctx context.Context, blockNumber uint64, tx ...*types.Transaction) (SendBundleResponse, error)
SendBundle(ctx context.Context, blockNumber uint64, tx ...*types.Transaction) (SendBundleResponse, error)
}

var (
_ IBundleSender = &BundleSender{}
_ IBundleSender = &BloxrouteBundleSender{}
_ IBundleSender = &MEVClient{}
_ IBundleSender = &BloxrouteClient{}
)

var defaultHeaders = [][2]string{ // nolint: gochecknoglobals
Expand Down
12 changes: 6 additions & 6 deletions pkg/mev/send_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)

// BundleSender https://beaverbuild.org/docs.html; https://rsync-builder.xyz/docs;
// MEVClient https://beaverbuild.org/docs.html; https://rsync-builder.xyz/docs;
// https://docs.flashbots.net/flashbots-auction/advanced/rpc-endpoint#eth_sendbundle
type BundleSender struct {
type MEVClient struct {

Check warning on line 19 in pkg/mev/send_bundle.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

exported: type name will be used as mev.MEVClient by other packages, and that stutters; consider calling this Client (revive)
c *http.Client
endpoint string
flashbotKey *ecdsa.PrivateKey
}

// NewBundlerSender set the flashbotKey to nil will skip adding the signature header.
func NewBundlerSender(c *http.Client, endpoint string, flashbotKey *ecdsa.PrivateKey) *BundleSender {
return &BundleSender{
// NewMEVClient set the flashbotKey to nil will skip adding the signature header.
func NewMEVClient(c *http.Client, endpoint string, flashbotKey *ecdsa.PrivateKey) *MEVClient {
return &MEVClient{
c: c,
endpoint: endpoint,
flashbotKey: flashbotKey,
}
}

func (s *BundleSender) Send(
func (s *MEVClient) SendBundle(
ctx context.Context, blockNumber uint64, txs ...*types.Transaction,
) (SendBundleResponse, error) {
req := SendBundleRequest{
Expand Down
4 changes: 2 additions & 2 deletions pkg/mev/send_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func TestSendBundle(t *testing.T) {

t.Log("new tx", signedTx.Hash().String())

sender := mev.NewBundlerSender(client, endpoint, privateKey)
resp, err := sender.Send(ctx, blockNumber+12, signedTx)
sender := mev.NewMEVClient(client, endpoint, privateKey)
resp, err := sender.SendBundle(ctx, blockNumber+12, signedTx)
require.NoError(t, err) // sepolia: code: [-32000], message: [internal server error]

t.Log("send bundle response", resp)
Expand Down

0 comments on commit 0c70f51

Please sign in to comment.