Skip to content

Commit

Permalink
revert context header changes in favor of new HeaderForwarder
Browse files Browse the repository at this point in the history
  • Loading branch information
potterbm-cb committed Nov 13, 2024
1 parent 3b8e2b0 commit 064b44c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 44 deletions.
29 changes: 0 additions & 29 deletions headers/headers.go

This file was deleted.

13 changes: 0 additions & 13 deletions services/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
package services

import (
"context"
"net/http"

"github.com/coinbase/rosetta-geth-sdk/configuration"
"github.com/coinbase/rosetta-geth-sdk/headers"
AssetTypes "github.com/coinbase/rosetta-geth-sdk/types"
"github.com/coinbase/rosetta-sdk-go/types"

Expand All @@ -37,51 +35,40 @@ func NewBlockchainRouter(
client construction.Client,
asserter *asserter.Asserter,
) http.Handler {
var contextFromRequest func(r *http.Request) context.Context = nil
if config.RosettaCfg.SupportHeaderForwarding {
contextFromRequest = headers.ContextWithHeaders
}

networkAPIService := NewNetworkAPIService(config, types, errors, client)
networkAPIController := server.NewNetworkAPIController(
networkAPIService,
asserter,
contextFromRequest,
)

accountAPIService := NewAccountAPIService(config, types, errors, client)
accountAPIController := server.NewAccountAPIController(
accountAPIService,
asserter,
contextFromRequest,
)

blockAPIService := NewBlockAPIService(config, client)
blockAPIController := server.NewBlockAPIController(
blockAPIService,
asserter,
contextFromRequest,
)

constructionAPIService := construction.NewAPIService(config, types, errors, client)
constructionAPIController := server.NewConstructionAPIController(
constructionAPIService,
asserter,
contextFromRequest,
)

// mempoolAPIService := NewMempoolAPIService()
// mempoolAPIController := server.NewMempoolAPIController(
// mempoolAPIService,
// asserter,
// contextFromRequest,
// )

// callAPIService := NewCallAPIService(config, client)
// callAPIController := server.NewCallAPIController(
// callAPIService,
// asserter,
// contextFromRequest,
// )

return server.NewRouter(
Expand Down
7 changes: 5 additions & 2 deletions utils/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ func BootStrap(
return fmt.Errorf("SupportHeaderForwarding enabled, but client does not implement ReplaceableRPCClient")
}

headerForwarder = headerforwarder.NewHeaderForwarder(
headerForwarder, err = headerforwarder.NewHeaderForwarder(
cfg.RosettaCfg.ForwardHeaders,
gethSdkClient.NewDefaultHTTPTransport(),
)
if err != nil {
return fmt.Errorf("SupportHeaderForwarding enabled, but header forwarder creation failed: %w", err)
}

replacedClient, err := replaceableClient.WithRPCTransport(cfg.GethURL, headerForwarder)
if err != nil {
return fmt.Errorf("SupportHeaderForwarding enabled, but client replacement failed: %e", err)
return fmt.Errorf("SupportHeaderForwarding enabled, but client replacement failed: %w", err)
}

convertedClient, ok := replacedClient.(construction.Client)
Expand Down

0 comments on commit 064b44c

Please sign in to comment.