Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get core latest ledger from http end-point instead of core db. #2725

Closed
abuiles opened this issue Jun 22, 2020 · 0 comments · Fixed by #2726
Closed

Get core latest ledger from http end-point instead of core db. #2725

abuiles opened this issue Jun 22, 2020 · 0 comments · Fixed by #2726
Assignees

Comments

@abuiles
Copy link
Contributor

abuiles commented Jun 22, 2020

We are in the process of removing Horizon's dependency on Stellar Core database. This is one of the places where we still use it.

func (a *App) UpdateLedgerState() {
var next ledger.State
logErr := func(err error, msg string) {
log.WithStack(err).WithField("err", err.Error()).Error(msg)
}
err := a.CoreQ().LatestLedger(&next.CoreLatest)
if err != nil {
logErr(err, "failed to load the latest known ledger state from core DB")
return
}
err = a.HistoryQ().LatestLedger(&next.HistoryLatest)
if err != nil {
logErr(err, "failed to load the latest known ledger state from history DB")
return
}
err = a.HistoryQ().ElderLedger(&next.HistoryElder)
if err != nil {
logErr(err, "failed to load the oldest known ledger state from history DB")
return
}
next.ExpHistoryLatest, err = a.HistoryQ().GetLastLedgerExpIngestNonBlocking()
if err != nil {
logErr(err, "failed to load the oldest known exp ledger state from history DB")
return
}
ledger.SetState(next)
}

In the code above, instead of reading from core's database, we should fetch this value from Horizon's DB - we discuss the possibility of adding this value to the key_value_store and have the front-end instances fetch the value from there.

We'll put the responsibility of updating this value in the ingesting instances. We can take the following approach:

  1. Use core's http end-point if Horizon if Horizon is still syncing/ingesting.
  2. Once Horizon has catched up with core, update the value every time a new ledger is processed instead of reading from core's http end-point.

What alternatives are there?

Remove this field from Horizon's root resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants