diff --git a/services/horizon/internal/action.go b/services/horizon/internal/action.go index 145a33cd57..5eae6a4d67 100644 --- a/services/horizon/internal/action.go +++ b/services/horizon/internal/action.go @@ -9,7 +9,6 @@ import ( "github.com/stellar/go/services/horizon/internal/actions" "github.com/stellar/go/services/horizon/internal/db2" - "github.com/stellar/go/services/horizon/internal/db2/core" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/services/horizon/internal/httpx" "github.com/stellar/go/services/horizon/internal/ledger" @@ -28,16 +27,6 @@ type Action struct { Log *log.Entry hq *history.Q - cq *core.Q -} - -// CoreQ provides access to queries that access the stellar core database. -func (action *Action) CoreQ() *core.Q { - if action.cq == nil { - action.cq = &core.Q{Session: action.App.CoreSession(action.R.Context())} - } - - return action.cq } // HistoryQ provides access to queries that access the history portion of diff --git a/services/horizon/internal/action_test.go b/services/horizon/internal/action_test.go index 02dd024c99..b59b068d27 100644 --- a/services/horizon/internal/action_test.go +++ b/services/horizon/internal/action_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/stellar/go/services/horizon/internal/db2" - "github.com/stellar/go/services/horizon/internal/db2/core" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/services/horizon/internal/test" "github.com/stellar/go/support/render/hal" @@ -23,7 +22,7 @@ func TestGetTransactionPage(t *testing.T) { defer tt.Finish() ctx := context.Background() - w := mustInitWeb(ctx, &history.Q{tt.HorizonSession()}, &core.Q{tt.CoreSession()}, time.Duration(5), 0, true) + w := mustInitWeb(ctx, &history.Q{tt.HorizonSession()}, time.Duration(5), 0, true) // filter by account params := &indexActionQueryParams{ diff --git a/services/horizon/internal/app.go b/services/horizon/internal/app.go index 02a24c9fee..a682a51f3d 100644 --- a/services/horizon/internal/app.go +++ b/services/horizon/internal/app.go @@ -472,7 +472,7 @@ func (a *App) init() { a.reaper = reap.New(a.config.HistoryRetentionCount, a.HorizonSession(context.Background())) // web.init - a.web = mustInitWeb(a.ctx, a.historyQ, a.coreQ, a.config.SSEUpdateFrequency, a.config.StaleThreshold, a.config.IngestFailedTransactions) + a.web = mustInitWeb(a.ctx, a.historyQ, a.config.SSEUpdateFrequency, a.config.StaleThreshold, a.config.IngestFailedTransactions) // web.rate-limiter a.web.rateLimiter = maybeInitWebRateLimiter(a.config.RateQuota) diff --git a/services/horizon/internal/resourceadapter/account_entry.go b/services/horizon/internal/resourceadapter/account_entry.go index c47d17d00b..b504da171b 100644 --- a/services/horizon/internal/resourceadapter/account_entry.go +++ b/services/horizon/internal/resourceadapter/account_entry.go @@ -46,7 +46,7 @@ func PopulateAccountEntry( // populate balances dest.Balances = make([]protocol.Balance, len(trustLines)+1) for i, tl := range trustLines { - err := PopulateHistoryBalance(&dest.Balances[i], tl) + err := PopulateBalance(&dest.Balances[i], tl) if err != nil { return errors.Wrap(err, "populating balance") } diff --git a/services/horizon/internal/resourceadapter/account_flags.go b/services/horizon/internal/resourceadapter/account_flags.go deleted file mode 100644 index 9480821f83..0000000000 --- a/services/horizon/internal/resourceadapter/account_flags.go +++ /dev/null @@ -1,12 +0,0 @@ -package resourceadapter - -import ( - protocol "github.com/stellar/go/protocols/horizon" - "github.com/stellar/go/services/horizon/internal/db2/core" -) - -func PopulateAccountFlags(dest *protocol.AccountFlags, row core.Account) { - dest.AuthRequired = row.IsAuthRequired() - dest.AuthRevocable = row.IsAuthRevocable() - dest.AuthImmutable = row.IsAuthImmutable() -} diff --git a/services/horizon/internal/resourceadapter/account_thresholds.go b/services/horizon/internal/resourceadapter/account_thresholds.go deleted file mode 100644 index bdd83bcc9c..0000000000 --- a/services/horizon/internal/resourceadapter/account_thresholds.go +++ /dev/null @@ -1,12 +0,0 @@ -package resourceadapter - -import ( - protocol "github.com/stellar/go/protocols/horizon" - "github.com/stellar/go/services/horizon/internal/db2/core" -) - -func PopulateAccountThresholds(dest *protocol.AccountThresholds, row core.Account) { - dest.LowThreshold = row.Thresholds[1] - dest.MedThreshold = row.Thresholds[2] - dest.HighThreshold = row.Thresholds[3] -} diff --git a/services/horizon/internal/resourceadapter/balance.go b/services/horizon/internal/resourceadapter/balance.go index 7711be3f03..73f5193971 100644 --- a/services/horizon/internal/resourceadapter/balance.go +++ b/services/horizon/internal/resourceadapter/balance.go @@ -4,36 +4,12 @@ import ( "github.com/stellar/go/amount" protocol "github.com/stellar/go/protocols/horizon" "github.com/stellar/go/services/horizon/internal/assets" - "github.com/stellar/go/services/horizon/internal/db2/core" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/support/errors" "github.com/stellar/go/xdr" ) -func PopulateBalance(dest *protocol.Balance, row core.Trustline) (err error) { - dest.Type, err = assets.String(row.Assettype) - if err != nil { - return errors.Wrap(err, "getting the string representation from the provided xdr asset type") - } - - dest.Balance = amount.String(row.Balance) - dest.BuyingLiabilities = amount.String(row.BuyingLiabilities) - dest.SellingLiabilities = amount.String(row.SellingLiabilities) - dest.Limit = amount.String(row.Tlimit) - dest.Issuer = row.Issuer - dest.Code = row.Assetcode - dest.LastModifiedLedger = row.LastModified - isAuthorized := row.IsAuthorized() - dest.IsAuthorized = &isAuthorized - dest.IsAuthorizedToMaintainLiabilities = &isAuthorized - isAuthorizedToMaintainLiabilities := row.IsAuthorizedToMaintainLiabilities() - if isAuthorizedToMaintainLiabilities { - dest.IsAuthorizedToMaintainLiabilities = &isAuthorizedToMaintainLiabilities - } - return -} - -func PopulateHistoryBalance(dest *protocol.Balance, row history.TrustLine) (err error) { +func PopulateBalance(dest *protocol.Balance, row history.TrustLine) (err error) { dest.Type, err = assets.String(row.AssetType) if err != nil { return errors.Wrap(err, "getting the string representation from the provided xdr asset type") diff --git a/services/horizon/internal/resourceadapter/balance_test.go b/services/horizon/internal/resourceadapter/balance_test.go index 397bb0c33c..e3ab93763a 100644 --- a/services/horizon/internal/resourceadapter/balance_test.go +++ b/services/horizon/internal/resourceadapter/balance_test.go @@ -4,78 +4,12 @@ import ( "testing" . "github.com/stellar/go/protocols/horizon" - "github.com/stellar/go/services/horizon/internal/db2/core" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/xdr" "github.com/stretchr/testify/assert" ) func TestPopulateBalance(t *testing.T) { - testAssetCode1 := "TEST_ASSET_1" - testAssetCode2 := "TEST_ASSET_2" - authorizedTrustline := core.Trustline{ - Accountid: "testID", - Assettype: xdr.AssetTypeAssetTypeCreditAlphanum12, - Issuer: "", - Assetcode: testAssetCode1, - Tlimit: 100, - Balance: 10, - Flags: 1, - } - authorizedToMaintainLiabilitiesTrustline := core.Trustline{ - Accountid: "testID", - Assettype: xdr.AssetTypeAssetTypeCreditAlphanum12, - Issuer: "", - Assetcode: testAssetCode1, - Tlimit: 100, - Balance: 10, - Flags: 2, - } - unauthorizedTrustline := core.Trustline{ - Accountid: "testID", - Assettype: xdr.AssetTypeAssetTypeCreditAlphanum12, - Issuer: "", - Assetcode: testAssetCode2, - Tlimit: 100, - Balance: 10, - Flags: 0, - } - - want := Balance{} - err := PopulateBalance(&want, authorizedTrustline) - assert.NoError(t, err) - assert.Equal(t, "credit_alphanum12", want.Type) - assert.Equal(t, "0.0000010", want.Balance) - assert.Equal(t, "0.0000100", want.Limit) - assert.Equal(t, "", want.Issuer) - assert.Equal(t, testAssetCode1, want.Code) - assert.Equal(t, true, *want.IsAuthorized) - assert.Equal(t, true, *want.IsAuthorizedToMaintainLiabilities) - - want = Balance{} - err = PopulateBalance(&want, authorizedToMaintainLiabilitiesTrustline) - assert.NoError(t, err) - assert.Equal(t, "credit_alphanum12", want.Type) - assert.Equal(t, "0.0000010", want.Balance) - assert.Equal(t, "0.0000100", want.Limit) - assert.Equal(t, "", want.Issuer) - assert.Equal(t, testAssetCode1, want.Code) - assert.Equal(t, false, *want.IsAuthorized) - assert.Equal(t, true, *want.IsAuthorizedToMaintainLiabilities) - - want = Balance{} - err = PopulateBalance(&want, unauthorizedTrustline) - assert.NoError(t, err) - assert.Equal(t, "credit_alphanum12", want.Type) - assert.Equal(t, "0.0000010", want.Balance) - assert.Equal(t, "0.0000100", want.Limit) - assert.Equal(t, "", want.Issuer) - assert.Equal(t, testAssetCode2, want.Code) - assert.Equal(t, false, *want.IsAuthorized) - assert.Equal(t, false, *want.IsAuthorizedToMaintainLiabilities) -} - -func TestPopulateHistoryBalance(t *testing.T) { testAssetCode1 := "TEST_ASSET_1" testAssetCode2 := "TEST_ASSET_2" authorizedTrustline := history.TrustLine{ @@ -107,7 +41,7 @@ func TestPopulateHistoryBalance(t *testing.T) { } want := Balance{} - err := PopulateHistoryBalance(&want, authorizedTrustline) + err := PopulateBalance(&want, authorizedTrustline) assert.NoError(t, err) assert.Equal(t, "credit_alphanum12", want.Type) assert.Equal(t, "0.0000010", want.Balance) @@ -118,7 +52,7 @@ func TestPopulateHistoryBalance(t *testing.T) { assert.Equal(t, true, *want.IsAuthorizedToMaintainLiabilities) want = Balance{} - err = PopulateHistoryBalance(&want, authorizedToMaintainLiabilitiesTrustline) + err = PopulateBalance(&want, authorizedToMaintainLiabilitiesTrustline) assert.NoError(t, err) assert.Equal(t, "credit_alphanum12", want.Type) assert.Equal(t, "0.0000010", want.Balance) @@ -129,7 +63,7 @@ func TestPopulateHistoryBalance(t *testing.T) { assert.Equal(t, true, *want.IsAuthorizedToMaintainLiabilities) want = Balance{} - err = PopulateHistoryBalance(&want, unauthorizedTrustline) + err = PopulateBalance(&want, unauthorizedTrustline) assert.NoError(t, err) assert.Equal(t, "credit_alphanum12", want.Type) assert.Equal(t, "0.0000010", want.Balance) diff --git a/services/horizon/internal/resourceadapter/signer.go b/services/horizon/internal/resourceadapter/signer.go deleted file mode 100644 index 2dd74ac41f..0000000000 --- a/services/horizon/internal/resourceadapter/signer.go +++ /dev/null @@ -1,24 +0,0 @@ -package resourceadapter - -import ( - "context" - - protocol "github.com/stellar/go/protocols/horizon" - "github.com/stellar/go/services/horizon/internal/db2/core" -) - -// Populate fills out the fields of the signer, using one of an account's -// secondary signers. -func PopulateSigner(ctx context.Context, dest *protocol.Signer, row core.Signer) { - dest.Weight = row.Weight - dest.Key = row.Publickey - dest.Type = protocol.MustKeyTypeFromAddress(dest.Key) -} - -// PopulateMasterSigner fills out the fields of the signer, using a stellar account to -// provide the data. -func PopulateMasterSigner(dest *protocol.Signer, row core.Account) { - dest.Weight = int32(row.Thresholds[0]) - dest.Key = row.Accountid - dest.Type = protocol.MustKeyTypeFromAddress(dest.Key) -} diff --git a/services/horizon/internal/web.go b/services/horizon/internal/web.go index 8d2d6d63e3..f553d0cc8a 100644 --- a/services/horizon/internal/web.go +++ b/services/horizon/internal/web.go @@ -17,7 +17,6 @@ import ( "github.com/stellar/go/services/horizon/internal/actions" "github.com/stellar/go/services/horizon/internal/db2" - "github.com/stellar/go/services/horizon/internal/db2/core" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/services/horizon/internal/ledger" "github.com/stellar/go/services/horizon/internal/paths" @@ -47,7 +46,6 @@ type web struct { ingestFailedTx bool historyQ *history.Q - coreQ *core.Q requestTimer metrics.Timer failureMeter metrics.Meter @@ -68,20 +66,16 @@ func init() { } // mustInitWeb installed a new Web instance onto the provided app object. -func mustInitWeb(ctx context.Context, hq *history.Q, cq *core.Q, updateFreq time.Duration, threshold uint, ingestFailedTx bool) *web { +func mustInitWeb(ctx context.Context, hq *history.Q, updateFreq time.Duration, threshold uint, ingestFailedTx bool) *web { if hq == nil { log.Fatal("missing history DB for installing the web instance") } - if cq == nil { - log.Fatal("missing core DB for installing the web instance") - } return &web{ appCtx: ctx, router: chi.NewRouter(), internalRouter: chi.NewRouter(), historyQ: hq, - coreQ: cq, sseUpdateFrequency: updateFreq, staleThreshold: threshold, ingestFailedTx: ingestFailedTx,