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

integrating new loaders and builders into processors #5083

Merged
merged 14 commits into from
Oct 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#4909: removed stub loader Sealed() method for test purposes
sreuland committed Oct 26, 2023

Verified

This commit was signed with the committer’s verified signature.
sreuland shawn
commit 625ce1f5f983a9cebb22e7f3bd9d9810c6a3a4fe
5 changes: 1 addition & 4 deletions services/horizon/internal/db2/history/account_loader.go
Original file line number Diff line number Diff line change
@@ -209,9 +209,6 @@ func NewAccountLoaderStub() AccountLoaderStub {
// Insert updates the wrapped AccountLoader so that the given account
// address is mapped to the provided history account id
func (a AccountLoaderStub) Insert(address string, id int64) {
a.Loader.ids[address] = id
}

func (a AccountLoaderStub) Sealed() {
a.Loader.sealed = true
a.Loader.ids[address] = id
}
5 changes: 1 addition & 4 deletions services/horizon/internal/db2/history/asset_loader.go
Original file line number Diff line number Diff line change
@@ -214,9 +214,6 @@ func NewAssetLoaderStub() AssetLoaderStub {
// Insert updates the wrapped AssetLoaderStub so that the given asset
// address is mapped to the provided history asset id
func (a AssetLoaderStub) Insert(asset AssetKey, id int64) {
a.Loader.ids[asset] = id
}

func (a AssetLoaderStub) Sealed() {
a.Loader.sealed = true
a.Loader.ids[asset] = id
}
Original file line number Diff line number Diff line change
@@ -160,9 +160,6 @@ func NewLiquidityPoolLoaderStub() LiquidityPoolLoaderStub {
// Insert updates the wrapped LiquidityPoolLoader so that the given liquidity pool
// is mapped to the provided history liquidity pool id
func (a LiquidityPoolLoaderStub) Insert(lp string, id int64) {
a.Loader.ids[lp] = id
}

func (a LiquidityPoolLoaderStub) Sealed() {
a.Loader.sealed = true
a.Loader.ids[lp] = id
}
Original file line number Diff line number Diff line change
@@ -727,15 +727,12 @@ func (s *TradeProcessorTestSuiteLedger) mockReadTradeTransactions() []history.In
}

func (s *TradeProcessorTestSuiteLedger) stubLoaders() {
s.accountLoader.Sealed()
for key, id := range s.unmuxedAccountToID {
s.accountLoader.Insert(key, id)
}
s.assetLoader.Sealed()
for key, id := range s.assetToID {
s.assetLoader.Insert(key, id.ID)
}
s.lpLoader.Sealed()
for key, id := range s.lpToID {
s.lpLoader.Insert(PoolIDToString(key), id)
}

Unchanged files with check annotations Beta

txTemplate.Envelope.V1.Tx.Operations[0].Body.Type = xdr.OperationType(typ)
f := func() {
var p StatsLedgerTransactionProcessor
p.ProcessTransaction(lcm, tx)

Check failure on line 32 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor_test.go

GitHub Actions / golangci

Error return value of `p.ProcessTransaction` is not checked (errcheck)
}
assert.NotPanics(t, f, s)
}
txTemplate.Envelope.V1.Tx.Operations[0].Body.Type = 20000
f := func() {
var p StatsLedgerTransactionProcessor
p.ProcessTransaction(lcm, tx)

Check failure on line 42 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor_test.go

GitHub Actions / golangci

Error return value of `p.ProcessTransaction` is not checked (errcheck)
}
assert.Panics(t, f)
}
lcm := xdr.LedgerCloseMeta{}
// Successful
assert.NoError(t, processor.ProcessTransaction(lcm, ingest.LedgerTransaction{

Check failure on line 52 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor_test.go

GitHub Actions / golangci

52-90 lines are duplicate of `services/horizon/internal/ingest/processors/stats_ledger_transaction_processor_test.go:93-131` (dupl)
Result: xdr.TransactionResultPair{
Result: xdr.TransactionResult{
Result: xdr.TransactionResultResult{
}))
// Failed
assert.NoError(t, processor.ProcessTransaction(lcm, ingest.LedgerTransaction{

Check failure on line 93 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor_test.go

GitHub Actions / golangci

93-131 lines are duplicate of `services/horizon/internal/ingest/processors/stats_ledger_transaction_processor_test.go:52-90` (dupl)
Result: xdr.TransactionResultPair{
Result: xdr.TransactionResult{
Result: xdr.TransactionResultResult{
return nil
}
func (p *StatsLedgerTransactionProcessor) ProcessTransaction(lcm xdr.LedgerCloseMeta, transaction ingest.LedgerTransaction) error {

Check failure on line 59 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go

GitHub Actions / golangci

Function 'ProcessTransaction' has too many statements (59 > 50) (funlen)
p.results.Transactions++
ops := int64(len(transaction.Envelope.Operations()))
p.results.Operations += ops
ledgerTransactionStats *processors.StatsLedgerTransactionProcessor,
tradeProcessor *processors.TradeProcessor,
ledgersProcessor *processors.LedgersProcessor,
ledger xdr.LedgerCloseMeta,

Check failure on line 138 in services/horizon/internal/ingest/processor_runner.go

GitHub Actions / golangci

`(*ProcessorRunner).buildTransactionProcessor` - `ledger` is unused (unparam)
) *groupTransactionProcessors {
accountLoader := history.NewAccountLoader()
assetLoader := history.NewAssetLoader()
q := &Q{session}
for _, address := range addresses {
internalId, err := loader.GetNow(address)

Check failure on line 41 in services/horizon/internal/db2/history/account_loader_test.go

GitHub Actions / golangci

ST1003: var internalId should be internalID (stylecheck)
assert.NoError(t, err)
var account Account
assert.NoError(t, q.AccountByAddress(context.Background(), &account, address))
type hungerRow struct {
Name string `db:"name"`
HungerLevel string `db:"hunger_level"`
JsonValue []byte `db:"json_value"`

Check failure on line 16 in support/db/batch_insert_builder_test.go

GitHub Actions / golangci

ST1003: struct field JsonValue should be JSONValue (stylecheck)
}
type invalidHungerRow struct {
type person struct {
Name string `db:"name"`
HungerLevel string `db:"hunger_level"`
JsonValue null.String `db:"json_value"`

Check failure on line 15 in support/db/main_test.go

GitHub Actions / golangci

ST1003: struct field JsonValue should be JSONValue (stylecheck)
SomethingIgnored int `db:"-"`
}