Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Add simple wait mode
Browse files Browse the repository at this point in the history
  • Loading branch information
m4ksio committed Sep 25, 2021
1 parent 67ca044 commit b46aef2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/flow-rosetta-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func run() int {
flagPort uint16
flagTransactions uint
flagSmart bool
flagWait bool
)

pflag.StringVarP(&flagDPS, "dps-api", "a", "127.0.0.1:5005", "host address for GRPC API endpoint")
Expand All @@ -78,6 +79,7 @@ func run() int {
pflag.Uint16VarP(&flagPort, "port", "p", 8080, "port to host Rosetta API on")
pflag.UintVarP(&flagTransactions, "transaction-limit", "t", 200, "maximum amount of transactions to include in a block response")
pflag.BoolVar(&flagSmart, "smart-status-codes", false, "enable smart non-500 HTTP status codes for Rosetta API errors")
pflag.BoolVarP(&flagWait, "wait-for-index", "w", false, "wait for index to be available instead of quitting right away, useful when DPS Live index bootstraps")

pflag.Parse()

Expand Down Expand Up @@ -105,10 +107,15 @@ func run() int {
dpsAPI := api.NewAPIClient(conn)
index := api.IndexFromAPI(dpsAPI, codec)

wait:
// Deduce chain ID from DPS API to configure parameters for script exec.
first, err := index.First()
if err != nil {
log.Error().Err(err).Msg("could not get first height from DPS API")
if flagWait {
time.Sleep(30 * time.Second)
goto wait
}
return failure
}
root, err := index.Header(first)
Expand Down

0 comments on commit b46aef2

Please sign in to comment.