Skip to content

Commit

Permalink
productionalize api
Browse files Browse the repository at this point in the history
  • Loading branch information
bd21 committed Oct 2, 2023
1 parent 8f65ed8 commit a9bb0aa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/ethereum/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *t
}

logger.Info(fmt.Sprintf(
"Starting listener at block %d looking back %d blocks",
"Starting Ethereum listener at block %d looking back %d blocks",
cfg.Networks.Source.Ethereum.StartBlock,
cfg.Networks.Source.Ethereum.LookbackPeriod))

Expand Down
8 changes: 8 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ func init() {
}

func startApi() {
gin.SetMode(gin.ReleaseMode)
router := gin.Default()

err := router.SetTrustedProxies(Cfg.Api.TrustedProxies) // vpn.primary.strange.love
if err != nil {
Logger.Error("unable to set trusted proxies on API server: " + err.Error())
os.Exit(1)
}

router.GET("/tx/:txHash", getTxByHash)
router.Run("localhost:8000")
}
Expand Down
4 changes: 3 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ type Config struct {
FetchRetries int `yaml:"fetch-retries"`
FetchRetryInterval int `yaml:"fetch-retry-interval"`
} `yaml:"circle"`

ProcessorWorkerCount uint32 `yaml:"processor-worker-count"`
Api struct {
TrustedProxies []string `yaml:"trusted-proxies"`
} `yaml:"api"`
}

func Parse(file string) (cfg Config) {
Expand Down
3 changes: 3 additions & 0 deletions config/sample-app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ circle:
fetch-retries: 10 # additional times to fetch an attestation
fetch-retry-interval: 10 # time between retries in seconds
processor-worker-count: 16
api:
trusted-proxies:
- "1.2.3.4" # add trusted proxy IPs here

0 comments on commit a9bb0aa

Please sign in to comment.