You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log.Err(err).Msg("Error getting transactions for stellar account")
select {
case<-ctx.Done():
returnctx.Err()
case<-time.After(5*time.Second):
continue
}
}
for_, tx:=rangeresponse.Embedded.Records {
mintEvents, err:=w.processTransaction(tx)
iferr!=nil {
returnerr
}
mintChan<-MintEventSubscription{
Events: mintEvents,
}
opRequest.Cursor=tx.PagingToken()
}
iflen(response.Embedded.Records) ==0 {
select {
case<-ctx.Done():
returnctx.Err()
case<-time.After(10*time.Second):
}
}
}
Instead of using a for loop to send requests and wait for 10 seconds when no new transactions are found, we can use the Stellar SDK stream mode to subscribe to an event-stream that gives us the latest payment information for the bridge account. When no more transactions are found, the stream stays open and new payments are sent as they are made.
Some benefits of this approach are:
We can get real-time updates on the status of payments.
We can avoid sending too many requests to the stellar network.
We can save resources (cpu time, network traffic) by not sending unnecessary requests.
tfchain/bridge/tfchain_bridge/pkg/stellar/stellar.go
Lines 351 to 386 in 9d56a80
Instead of using a for loop to send requests and wait for 10 seconds when no new transactions are found, we can use the Stellar SDK stream mode to subscribe to an event-stream that gives us the latest payment information for the bridge account. When no more transactions are found, the stream stays open and new payments are sent as they are made.
Some benefits of this approach are:
See the client stream methods that can be used:
https://github.com/stellar/go/blob/master/clients/horizonclient/client.go#L603
The text was updated successfully, but these errors were encountered: