Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
447 commits
Select commit Hold shift + click to select a range
360d38e
Use ContractBalanceFromContractData function to parse balanc eentry c…
aditya1702 Jan 14, 2026
57d0bf5
Update token_transfer.go
aditya1702 Jan 15, 2026
6c742eb
change TrustLines -> Trustlines
aditya1702 Jan 15, 2026
9c84ccf
Create trustlines_test.go
aditya1702 Jan 15, 2026
ed819f2
Update internal/data/account_tokens.go
aditya1702 Jan 15, 2026
93f7116
Update internal/data/account_tokens.go
aditya1702 Jan 15, 2026
afac0ed
Update internal/data/trustline_assets.go
aditya1702 Jan 15, 2026
26e92fa
Update internal/db/migrations/2025-12-14.0-trustline_assets.sql
aditya1702 Jan 15, 2026
40ea015
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
a06b341
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 15, 2026
6e856dc
Update mocks.go
aditya1702 Jan 15, 2026
c8e54e9
Remove tokenCacheReader interface
aditya1702 Jan 15, 2026
f7389d1
rename files and remove unused method
aditya1702 Jan 15, 2026
9c5e47a
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 15, 2026
8201c58
Add GetNativeBalance method
aditya1702 Jan 15, 2026
55394f8
insert native balances within same batch during checkpoint population
aditya1702 Jan 15, 2026
973bb0e
Add TrustlineBalanceModel for focused trustline balance operations
aditya1702 Jan 15, 2026
d7fa1a7
Add AccountContractTokensModel for focused contract mapping operations
aditya1702 Jan 15, 2026
e40679e
Consolidate migrations: rename table to account_trustline_balances
aditya1702 Jan 15, 2026
35673ae
Update Models struct to use new focused model interfaces
aditya1702 Jan 15, 2026
a0eea75
Split migrations into separate files per model
aditya1702 Jan 15, 2026
0cba06b
Update TokenIngestionService to use new focused models
aditya1702 Jan 15, 2026
1c81707
Update GraphQL resolvers to use new focused models
aditya1702 Jan 15, 2026
872b72d
Update serve.go dependency injection for new model interfaces
aditya1702 Jan 15, 2026
c928381
Update ingest.go to use new model interfaces
aditya1702 Jan 15, 2026
02cd9c6
Update first two test cases to use new model interfaces
aditya1702 Jan 15, 2026
2fae304
Update success test cases (SAC, SEP-41, mixed, contract, trustline V0)
aditya1702 Jan 15, 2026
e83f4dd
Update error and edge case tests to use new model interfaces
aditya1702 Jan 15, 2026
74953e2
Update BalancesByAccountAddresses tests to use new model interfaces
aditya1702 Jan 15, 2026
9e40e7d
Fix error message assertion in partial failure test
aditya1702 Jan 15, 2026
ae99455
Delete old account_tokens.go file (replaced by focused models)
aditya1702 Jan 15, 2026
3e3a427
Delete old account_tokens_test.go (tests for deleted AccountTokensModel)
aditya1702 Jan 15, 2026
32660e4
Update token_ingestion_test.go to use new focused model interfaces
aditya1702 Jan 15, 2026
48b3633
Fix wrapcheck lint error in balance_reader.go
aditya1702 Jan 15, 2026
2b4626b
fix make check
aditya1702 Jan 15, 2026
20e74ef
rename migration files and tables
aditya1702 Jan 15, 2026
99710d5
Update account_contract_tokens.go
aditya1702 Jan 15, 2026
f0c76af
Update trustline_balance.go
aditya1702 Jan 15, 2026
4eaf754
fix typo
aditya1702 Jan 15, 2026
596ca7a
remove unused methods from contract tokens data model
aditya1702 Jan 15, 2026
c4c8b69
fix tests
aditya1702 Jan 15, 2026
713f89b
directly use token changes from buffer
aditya1702 Jan 15, 2026
dbc891c
Add tests for trustline_balances
aditya1702 Jan 15, 2026
651ce2f
Use BatchCopy for inserting new trustlines
aditya1702 Jan 15, 2026
c6a49c8
Integrate proper DB transaction lifecycle during ingestion (#448)
aditya1702 Jan 15, 2026
ac2fa47
Revert "Use BatchCopy for inserting new trustlines"
aditya1702 Jan 15, 2026
c95f36e
Properly process token changes during optimized catchup (#449)
aditya1702 Jan 15, 2026
d52d2ec
Merge main_balances_postgres with PostgreSQL-only storage
aditya1702 Jan 15, 2026
c42a2d4
Remove redis container setup from integration tests
aditya1702 Jan 15, 2026
4a5576a
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
fb3a7da
Update ingest_test.go
aditya1702 Jan 15, 2026
975bcef
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
0edb007
Update ingest_backfill.go
aditya1702 Jan 15, 2026
e8b5dd8
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
8c129dc
Directly call buffer to get trustline and contract changes
aditya1702 Jan 15, 2026
c6e9422
fix make check
aditya1702 Jan 15, 2026
d8b3337
fix failing test
aditya1702 Jan 15, 2026
3fab5a5
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
353b162
Merge calculate-balances-using-changes into store-native-balance
aditya1702 Jan 15, 2026
8a0a37c
Update account_balances_test.go
aditya1702 Jan 15, 2026
7868a7f
Update ingest_backfill.go
aditya1702 Jan 15, 2026
baa47b6
Fix failing tests
aditya1702 Jan 15, 2026
f175e75
Add unit tests for AccountsProcessor
aditya1702 Jan 15, 2026
ca68a5d
Add unit tests for NativeBalanceModel
aditya1702 Jan 15, 2026
490dbbc
Fix NativeBalanceModel test expectations for not-found case
aditya1702 Jan 15, 2026
708a568
store only the latest trustline balance change
aditya1702 Jan 16, 2026
b9ad300
Change token ingestion flow to directly insert without sorting
aditya1702 Jan 16, 2026
d964fce
Update mocks.go
aditya1702 Jan 16, 2026
dfc9689
make check
aditya1702 Jan 16, 2026
2d78bbb
update backfill logic for catchup
aditya1702 Jan 16, 2026
b40a663
merge trustline changes properly
aditya1702 Jan 16, 2026
0d46ae1
merge unique assets and contract ID maps
aditya1702 Jan 16, 2026
ca2e4c1
process batch changes within same txn
aditya1702 Jan 16, 2026
dea1053
Merge calculate-balances-using-changes into store-native-balance
aditya1702 Jan 16, 2026
c5fd0dd
refactor: change accountChanges from slice to map in IndexerBuffer
aditya1702 Jan 16, 2026
845778f
refactor: update IndexerBufferInterface for map-based account changes
aditya1702 Jan 16, 2026
59a5c78
refactor: update ingest_backfill.go for map-based account changes
aditya1702 Jan 16, 2026
ddc0c58
refactor: simplify ProcessTokenChanges for pre-deduplicated account c…
aditya1702 Jan 16, 2026
3b5420d
refactor: update TokenIngestionServiceMock for map-based account changes
aditya1702 Jan 16, 2026
3666981
fix make check
aditya1702 Jan 16, 2026
c7ca787
Add minimum_balance column
aditya1702 Jan 16, 2026
866d7ce
Add minimum balance, buying L, selling L to graphql native balance re…
aditya1702 Jan 16, 2026
cace424
fix make check
aditya1702 Jan 16, 2026
46c9065
Add NativeBalance fragment to GraphQL client queries
aditya1702 Jan 16, 2026
b29189c
Add missing fields to NativeBalance client type
aditya1702 Jan 16, 2026
c5b7263
Fix checkpoint population to calculate MinimumBalance
aditya1702 Jan 16, 2026
77d6e37
Update integration tests to verify native balance updates
aditya1702 Jan 16, 2026
c0a4ac8
Update account_balances_test.go
aditya1702 Jan 16, 2026
a379bec
Merge store-native-balance into store-sep41-balance with SAC balance …
aditya1702 Jan 16, 2026
36d2aa2
Merge branch 'store-native-balance' into store-sep41-balance
aditya1702 Jan 16, 2026
65a2bbe
streamline SAC balance entry processing
aditya1702 Jan 16, 2026
3d9fee9
store all contract tokens at the end during checkpointing
aditya1702 Jan 16, 2026
1ccec34
fix failing tests
aditya1702 Jan 16, 2026
1fdd6e8
update balance resolver to read SAC balances from DB
aditya1702 Jan 16, 2026
2ab56d0
copilot review changes
aditya1702 Jan 16, 2026
e87f854
Update account_balances_test.go
aditya1702 Jan 16, 2026
6a54d5f
fix error comparison
aditya1702 Jan 16, 2026
b1fada6
fix issues - 1
aditya1702 Jan 16, 2026
469ad8f
Use BIGINT for last modified ledger
aditya1702 Jan 16, 2026
b152f69
change last modified ledger to BIGINT
aditya1702 Jan 16, 2026
9855e2d
update table name
aditya1702 Jan 16, 2026
d70ccfd
Add tests for SAC processors
aditya1702 Jan 17, 2026
4fda222
Refactor: Replace GetAllContractIDs with GetExisting for scalability
aditya1702 Jan 19, 2026
5d3ca3f
Remove dead mock methods from TokenCacheWriterMock
aditya1702 Jan 19, 2026
94ec655
Update stale Redis references in test comments and error messages
aditya1702 Jan 19, 2026
e0ebc97
Fix prepareNewContracts call in ingest_backfill.go
aditya1702 Jan 19, 2026
4f47e72
Add deferred FK constraints on account tokens tables
aditya1702 Jan 19, 2026
6d7efba
Merge redis-to-postgres into calculate-balances-using-changes
aditya1702 Jan 19, 2026
d4e393c
Add deferred FK constraints on account tokens tables
aditya1702 Jan 19, 2026
8392d4a
Clean up minor code issues in token ingestion
aditya1702 Jan 19, 2026
8118c64
Update stellar_rpc_config.toml
aditya1702 Jan 19, 2026
36e8e7e
Update backfill_helpers.go
aditya1702 Jan 19, 2026
671a781
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 19, 2026
9ce0d30
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 19, 2026
6adcd48
Use uint32 in graphql for last modified ledger
aditya1702 Jan 19, 2026
77dea34
Merge store-native-balance into store-sep41-balance
aditya1702 Jan 19, 2026
6fcffe8
Add FK constraint to sac_balances table
aditya1702 Jan 19, 2026
9ca90a6
Add error logging in GraphQL balance resolver
aditya1702 Jan 19, 2026
e1772f5
Add buffer test coverage for SAC balance operations
aditya1702 Jan 19, 2026
7953ee3
Add balance validation and define constants for SAC balance fields
aditya1702 Jan 19, 2026
abe267a
Fix test addresses to use valid 56-character format
aditya1702 Jan 19, 2026
a83055e
refactor SAC entries processing
aditya1702 Jan 20, 2026
75c9902
Only insert sep41 token relationships for accounts
aditya1702 Jan 20, 2026
45e1746
Only insert sep41 account token relationships - 2
aditya1702 Jan 20, 2026
47e3d28
Add SACInstanceProcessor to extract SAC contract metadata
aditya1702 Jan 20, 2026
cb3ae04
Add SAC contract tracking to IndexerBuffer
aditya1702 Jan 20, 2026
a30aa40
Wire SACInstanceProcessor in indexer
aditya1702 Jan 20, 2026
0f7591b
change function name
aditya1702 Jan 20, 2026
d44f988
Extend prepareNewContractTokens to include SAC contracts
aditya1702 Jan 20, 2026
9fe307c
Add tests for SACInstanceProcessor
aditya1702 Jan 20, 2026
fdaa8f5
Process SAC instances to extract new assets
aditya1702 Jan 20, 2026
cf75e84
Add proper logging for inserted items in DB
aditya1702 Jan 20, 2026
148603f
Update ingest_live.go
aditya1702 Jan 20, 2026
98b0312
fix failing unit tests
aditya1702 Jan 20, 2026
7d8a110
Update token_ingestion.go
aditya1702 Jan 20, 2026
1c05dc3
Update token_ingestion.go
aditya1702 Jan 20, 2026
ab8c062
fetch missing SAC metadata using RPC
aditya1702 Jan 20, 2026
49cad15
return error for metadata fetching failures
aditya1702 Jan 20, 2026
7957b46
Reduce batch size and set synchronous commit = off
aditya1702 Jan 20, 2026
cb38365
Add loadtest run command for synthetic ledger ingestion
aditya1702 Jan 21, 2026
61684fd
Register loadtest command in root CLI
aditya1702 Jan 21, 2026
131c5e8
Add loadtest runner for synthetic ledger ingestion
aditya1702 Jan 21, 2026
1793631
Add LoadtestLedgerBackend for synthetic ledger ingestion
aditya1702 Jan 21, 2026
a82ce64
Add GetLedgerTransactions and ProcessLedger to indexer package
aditya1702 Jan 21, 2026
d622aaa
Refactor ingest service to use indexer.ProcessLedger
aditya1702 Jan 21, 2026
81e8c9f
Add xdrpp/goxdr dependency for loadtest backend
aditya1702 Jan 21, 2026
e91e0c8
Add wallet_backend_loadtest schema to postgres init
aditya1702 Jan 21, 2026
d318e37
Add load test ledgers data file
aditya1702 Jan 21, 2026
dff6541
fix tests
aditya1702 Jan 21, 2026
31839a2
Add NewTokenIngestionServiceForLoadtest constructor for loadtest runner
aditya1702 Jan 21, 2026
7c4844b
Add SeedDataPath field to loadtest RunConfig
aditya1702 Jan 21, 2026
e275e59
Add loadSeedData function to loadtest runner
aditya1702 Jan 21, 2026
6e83534
Add token change processing to persistLedgerData using TokenIngestion…
aditya1702 Jan 21, 2026
5f3d60d
Update Run() and runIngestionLoop to use TokenIngestionService and se…
aditya1702 Jan 21, 2026
0bf266b
Add --seed-data-path CLI flag to loadtest command
aditya1702 Jan 21, 2026
62b9d1f
Add loadtest seed data SQL file with native XLM SAC contract
aditya1702 Jan 21, 2026
b8a0fe5
Use COPY format for seed data for fast bulk loading
aditya1702 Jan 21, 2026
2cb324b
Use psql to load seed data with COPY format support
aditya1702 Jan 21, 2026
b6a90e3
Update runner.go
aditya1702 Jan 21, 2026
ab1971a
use the last expected ledger to end the loop
aditya1702 Jan 21, 2026
7eb7672
Update docker-compose.yaml
aditya1702 Jan 21, 2026
0471170
fix make check
aditya1702 Jan 21, 2026
6bfc401
Update runner.go
aditya1702 Jan 22, 2026
6e99936
use CopyFromSlice for better type checking
aditya1702 Jan 28, 2026
ca586f7
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 28, 2026
c677dd7
Use CopyFromSlice for strict checking
aditya1702 Jan 28, 2026
62e3b0e
remove unused network passphrase
aditya1702 Jan 28, 2026
9e5008d
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 28, 2026
e2532e9
remove unused network passphrase
aditya1702 Jan 28, 2026
e615ce5
make check
aditya1702 Jan 28, 2026
c206a1d
Use Greater instead of GreaterOrEqual
aditya1702 Jan 28, 2026
6927bc7
Add assertion for minimum balance
aditya1702 Jan 28, 2026
7175785
Merge branch 'store-native-balance' into store-sep41-balance
aditya1702 Jan 28, 2026
35ee238
use utils isContractAddress function
aditya1702 Jan 28, 2026
2ba6bf1
Update sac_balances.go
aditya1702 Jan 28, 2026
ab6a54d
simplify balance fields extraction for SAC balances
aditya1702 Jan 28, 2026
c258cbd
Merge branch 'store-sep41-balance' into load-test-2
aditya1702 Jan 28, 2026
4a77335
fix review comments - 1
aditya1702 Jan 28, 2026
4c84956
Update runner.go
aditya1702 Jan 28, 2026
d42bd0e
fix make check issues
aditya1702 Jan 28, 2026
084ec12
Use normalized `(accountID, tokenID)` tables for storing account trus…
aditya1702 Jan 28, 2026
1ac7985
Process trustline entry changes and store trustline balances (#452)
aditya1702 Jan 28, 2026
faf853b
Process account entry changes and store XLM balances and minimum XLM …
aditya1702 Jan 28, 2026
45d3e48
Process SAC balance entry changes and store SAC balances (#454)
aditya1702 Jan 28, 2026
7f96022
Update runner.go
aditya1702 Jan 28, 2026
e35a5b3
dont print database URL
aditya1702 Jan 28, 2026
d904c85
Merge branch 'main_balances_postgres' into load-test-2
aditya1702 Jan 28, 2026
655e40b
rearrange test functions
aditya1702 Jan 28, 2026
4596785
Merge branch 'main' into load-test-2
aditya1702 Jan 28, 2026
0c21ca8
Update indexer.go
aditya1702 Jan 28, 2026
ea41ba6
Use latest ledger seq to end the FOR loop
aditya1702 Jan 29, 2026
d319319
Replace result_xdr with fee_charged and result_code in transactions t…
aditya1702 Jan 29, 2026
266a05a
Update tests and client types for fee_charged and result_code fields
aditya1702 Jan 29, 2026
85f5209
Regenerate GraphQL code with feeCharged and resultCode fields
aditya1702 Jan 29, 2026
ab3cccb
Fix XDR field access and update test expectations
aditya1702 Jan 29, 2026
0e2a9fd
Use the SDK functions to get the code and fee charged
aditya1702 Jan 29, 2026
3518140
Fix remaining test SQL INSERT statements for tx3 rows
aditya1702 Jan 30, 2026
51201e1
Add isFeeBump column to transactions table
aditya1702 Jan 30, 2026
ac9d6f8
Merge branch 'main' into result-xdr
aditya1702 Jan 30, 2026
daabaed
Add result_code and successful columns to operations table
aditya1702 Jan 30, 2026
4a1c49b
Add codes.go helper for extracting operation result codes
aditya1702 Jan 30, 2026
1b98c32
Update ConvertOperation to extract result codes
aditya1702 Jan 30, 2026
fc291e9
Process ALL operations regardless of transaction success
aditya1702 Jan 30, 2026
54ff539
Pass operation results to ConvertOperation
aditya1702 Jan 30, 2026
0b3c35e
Update data layer for new operation columns
aditya1702 Jan 30, 2026
a65c511
Update GraphQL schema with new Operation fields
aditya1702 Jan 30, 2026
7af5f84
Update tests for new operation result_code and successful columns
aditya1702 Jan 30, 2026
4743242
Fix lint error: rename stringForExtendFootprintTtlResult to stringFor…
aditya1702 Jan 30, 2026
eb6ef8b
Update codes_test.go
aditya1702 Jan 30, 2026
c45f43f
Update client
aditya1702 Jan 30, 2026
be4730f
Make method private
aditya1702 Jan 30, 2026
4ee82be
Update data_validation_test.go
aditya1702 Jan 30, 2026
046c21d
Add tests for test coverage
aditya1702 Jan 30, 2026
a649a77
Update internal/integrationtests/data_validation_test.go
aditya1702 Jan 30, 2026
70560a4
Update internal/indexer/processors/codes.go
aditya1702 Jan 30, 2026
efc523b
Update internal/indexer/processors/codes.go
aditya1702 Jan 30, 2026
4bf73d1
fix tests
aditya1702 Jan 30, 2026
6474758
Update 2025-06-10.3-create_indexer_table_operations.sql
aditya1702 Jan 30, 2026
00f02ad
refactor: replace JSONB columns with explicit typed columns in state_…
aditya1702 Jan 30, 2026
266433a
refactor: update StateChange struct to use explicit typed fields
aditya1702 Jan 30, 2026
2f1c2ae
refactor: update StateChangeBuilder for new typed schema
aditya1702 Jan 30, 2026
b153a37
refactor: update processors to use new typed schema
aditya1702 Jan 30, 2026
325becd
refactor: update data layer for new typed state_changes schema
aditya1702 Jan 30, 2026
6a46a31
refactor: update GraphQL resolvers and tests for new typed schema
aditya1702 Jan 30, 2026
3c0acf5
Update types.go
aditya1702 Jan 30, 2026
8bfdebc
change typ0
aditya1702 Jan 30, 2026
b8cdb5d
Add resolvers for cb id and lp id
aditya1702 Jan 30, 2026
3027c5a
Update queries.go
aditya1702 Jan 30, 2026
625b900
Update statechange.go
aditya1702 Jan 30, 2026
e48c293
Update types.go
aditya1702 Jan 30, 2026
409835c
remove offer ID
aditya1702 Jan 30, 2026
13f2368
Change ID -> Id
aditya1702 Jan 30, 2026
f712167
Update data_validation_test.go
aditya1702 Jan 30, 2026
1ab6a1e
Add sponsored data field for reserves change
aditya1702 Jan 30, 2026
5ba65c2
Fix batch copy
aditya1702 Jan 30, 2026
83e05e5
Add LP ID for balance auth change
aditya1702 Jan 30, 2026
72ce607
remove keyValue from balance auth change
aditya1702 Jan 30, 2026
7e3cd12
Update statechange.graphqls
aditya1702 Jan 30, 2026
28e8ed1
Add liquidity pool ID field to trustline change
aditya1702 Jan 31, 2026
a5c7b65
Update effects_horizon.go
aditya1702 Jan 31, 2026
b834e24
fix failing test
aditya1702 Jan 31, 2026
5a953de
fix test
aditya1702 Feb 1, 2026
b07c821
remove keyvalue for reserves change
aditya1702 Feb 1, 2026
72ac8b0
fix failing test - 2
aditya1702 Feb 1, 2026
31d9c57
Update effects.go
aditya1702 Feb 1, 2026
b5981ba
Update internal/indexer/types/types.go
aditya1702 Feb 20, 2026
d733215
Update internal/serve/graphql/resolvers/statechange.resolvers.go
aditya1702 Feb 20, 2026
ec629f6
Update internal/serve/graphql/resolvers/statechange.resolvers.go
aditya1702 Feb 20, 2026
a19e646
Update internal/indexer/types/types.go
aditya1702 Feb 20, 2026
6e9cd44
Update effects.go
aditya1702 Feb 20, 2026
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
10 changes: 5 additions & 5 deletions internal/data/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func TestAccountModelBatchGetByTxHashes(t *testing.T) {
require.NoError(t, err)

// Insert test transactions first
_, err = m.DB.ExecContext(ctx, "INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at) VALUES ($1, 1, 'env1', 'res1', 'meta1', 1, NOW()), ($2, 2, 'env2', 'res2', 'meta2', 2, NOW())", txHash1, txHash2)
_, err = m.DB.ExecContext(ctx, "INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at) VALUES ($1, 1, 'env1', 100, 'TransactionResultCodeTxSuccess', 'meta1', 1, NOW()), ($2, 2, 'env2', 200, 'TransactionResultCodeTxSuccess', 'meta2', 2, NOW())", txHash1, txHash2)
require.NoError(t, err)

// Insert test transactions_accounts links
Expand Down Expand Up @@ -309,11 +309,11 @@ func TestAccountModelBatchGetByOperationIDs(t *testing.T) {
require.NoError(t, err)

// Insert test transactions first
_, err = m.DB.ExecContext(ctx, "INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at) VALUES ('tx1', 1, 'env1', 'res1', 'meta1', 1, NOW()), ('tx2', 2, 'env2', 'res2', 'meta2', 2, NOW())")
_, err = m.DB.ExecContext(ctx, "INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at) VALUES ('tx1', 1, 'env1', 100, 'TransactionResultCodeTxSuccess', 'meta1', 1, NOW()), ('tx2', 2, 'env2', 200, 'TransactionResultCodeTxSuccess', 'meta2', 2, NOW())")
require.NoError(t, err)

// Insert test operations first
_, err = m.DB.ExecContext(ctx, "INSERT INTO operations (id, tx_hash, operation_type, operation_xdr, ledger_number, ledger_created_at) VALUES ($1, 'tx1', 'payment', 'xdr1', 1, NOW()), ($2, 'tx2', 'payment', 'xdr2', 2 , NOW())", operationID1, operationID2)
_, err = m.DB.ExecContext(ctx, "INSERT INTO operations (id, tx_hash, operation_type, operation_xdr, result_code, successful, ledger_number, ledger_created_at) VALUES ($1, 'tx1', 'payment', 'xdr1', 'op_success', true, 1, NOW()), ($2, 'tx2', 'payment', 'xdr2', 'op_success', true, 2, NOW())", operationID1, operationID2)
require.NoError(t, err)

// Insert test operations_accounts links
Expand Down Expand Up @@ -400,11 +400,11 @@ func TestAccountModelBatchGetByStateChangeIDs(t *testing.T) {
require.NoError(t, err)

// Insert test transactions first
_, err = m.DB.ExecContext(ctx, "INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at) VALUES ('tx1', 1, 'env1', 'res1', 'meta1', 1, NOW()), ('tx2', 2, 'env2', 'res2', 'meta2', 2, NOW())")
_, err = m.DB.ExecContext(ctx, "INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at) VALUES ('tx1', 1, 'env1', 100, 'TransactionResultCodeTxSuccess', 'meta1', 1, NOW()), ('tx2', 2, 'env2', 200, 'TransactionResultCodeTxSuccess', 'meta2', 2, NOW())")
require.NoError(t, err)

// Insert test operations first
_, err = m.DB.ExecContext(ctx, "INSERT INTO operations (id, tx_hash, operation_type, operation_xdr, ledger_number, ledger_created_at) VALUES (1, 'tx1', 'payment', 'xdr1', 1, NOW()), (2, 'tx2', 'payment', 'xdr2', 2, NOW())")
_, err = m.DB.ExecContext(ctx, "INSERT INTO operations (id, tx_hash, operation_type, operation_xdr, result_code, successful, ledger_number, ledger_created_at) VALUES (1, 'tx1', 'payment', 'xdr1', 'op_success', true, 1, NOW()), (2, 'tx2', 'payment', 'xdr2', 'op_success', true, 2, NOW())")
require.NoError(t, err)

// Insert test state changes that reference the accounts
Expand Down
16 changes: 8 additions & 8 deletions internal/data/ingest_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ func Test_IngestStoreModel_GetLedgerGaps(t *testing.T) {
// Insert consecutive ledgers: 100, 101, 102
for i, ledger := range []uint32{100, 101, 102} {
_, err := dbConnectionPool.ExecContext(ctx,
`INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 'res', 'meta', $3, NOW())`,
`INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 100, 'TransactionResultCodeTxSuccess', 'meta', $3, NOW())`,
fmt.Sprintf("hash%d", i), i+1, ledger)
require.NoError(t, err)
}
Expand All @@ -245,8 +245,8 @@ func Test_IngestStoreModel_GetLedgerGaps(t *testing.T) {
// Insert ledgers 100 and 105, creating gap 101-104
for i, ledger := range []uint32{100, 105} {
_, err := dbConnectionPool.ExecContext(ctx,
`INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 'res', 'meta', $3, NOW())`,
`INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 100, 'TransactionResultCodeTxSuccess', 'meta', $3, NOW())`,
fmt.Sprintf("hash%d", i), i+1, ledger)
require.NoError(t, err)
}
Expand All @@ -261,8 +261,8 @@ func Test_IngestStoreModel_GetLedgerGaps(t *testing.T) {
// Insert ledgers 100, 105, 110, creating gaps 101-104 and 106-109
for i, ledger := range []uint32{100, 105, 110} {
_, err := dbConnectionPool.ExecContext(ctx,
`INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 'res', 'meta', $3, NOW())`,
`INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 100, 'TransactionResultCodeTxSuccess', 'meta', $3, NOW())`,
fmt.Sprintf("hash%d", i), i+1, ledger)
require.NoError(t, err)
}
Expand All @@ -278,8 +278,8 @@ func Test_IngestStoreModel_GetLedgerGaps(t *testing.T) {
// Insert ledgers 100 and 102, creating gap of just 101
for i, ledger := range []uint32{100, 102} {
_, err := dbConnectionPool.ExecContext(ctx,
`INSERT INTO transactions (hash, to_id, envelope_xdr, result_xdr, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 'res', 'meta', $3, NOW())`,
`INSERT INTO transactions (hash, to_id, envelope_xdr, fee_charged, result_code, meta_xdr, ledger_number, ledger_created_at)
VALUES ($1, $2, 'env', 100, 'TransactionResultCodeTxSuccess', 'meta', $3, NOW())`,
fmt.Sprintf("hash%d", i), i+1, ledger)
require.NoError(t, err)
}
Expand Down
24 changes: 17 additions & 7 deletions internal/data/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ func (m *OperationModel) BatchInsert(
txHashes := make([]string, len(operations))
operationTypes := make([]string, len(operations))
operationXDRs := make([]string, len(operations))
resultCodes := make([]string, len(operations))
successfulFlags := make([]bool, len(operations))
ledgerNumbers := make([]uint32, len(operations))
ledgerCreatedAts := make([]time.Time, len(operations))

Expand All @@ -263,6 +265,8 @@ func (m *OperationModel) BatchInsert(
txHashes[i] = op.TxHash
operationTypes[i] = string(op.OperationType)
operationXDRs[i] = op.OperationXDR
resultCodes[i] = op.ResultCode
successfulFlags[i] = op.Successful
ledgerNumbers[i] = op.LedgerNumber
ledgerCreatedAts[i] = op.LedgerCreatedAt
}
Expand All @@ -283,17 +287,19 @@ func (m *OperationModel) BatchInsert(
-- Insert operations
inserted_operations AS (
INSERT INTO operations
(id, tx_hash, operation_type, operation_xdr, ledger_number, ledger_created_at)
(id, tx_hash, operation_type, operation_xdr, result_code, successful, ledger_number, ledger_created_at)
SELECT
o.id, o.tx_hash, o.operation_type, o.operation_xdr, o.ledger_number, o.ledger_created_at
o.id, o.tx_hash, o.operation_type, o.operation_xdr, o.result_code, o.successful, o.ledger_number, o.ledger_created_at
FROM (
SELECT
UNNEST($1::bigint[]) AS id,
UNNEST($2::text[]) AS tx_hash,
UNNEST($3::text[]) AS operation_type,
UNNEST($4::text[]) AS operation_xdr,
UNNEST($5::bigint[]) AS ledger_number,
UNNEST($6::timestamptz[]) AS ledger_created_at
UNNEST($5::text[]) AS result_code,
UNNEST($6::boolean[]) AS successful,
UNNEST($7::bigint[]) AS ledger_number,
UNNEST($8::timestamptz[]) AS ledger_created_at
) o
ON CONFLICT (id) DO NOTHING
RETURNING id
Expand All @@ -307,8 +313,8 @@ func (m *OperationModel) BatchInsert(
oa.op_id, oa.account_id
FROM (
SELECT
UNNEST($7::bigint[]) AS op_id,
UNNEST($8::text[]) AS account_id
UNNEST($9::bigint[]) AS op_id,
UNNEST($10::text[]) AS account_id
) oa
ON CONFLICT DO NOTHING
)
Expand All @@ -324,6 +330,8 @@ func (m *OperationModel) BatchInsert(
pq.Array(txHashes),
pq.Array(operationTypes),
pq.Array(operationXDRs),
pq.Array(resultCodes),
pq.Array(successfulFlags),
pq.Array(ledgerNumbers),
pq.Array(ledgerCreatedAts),
pq.Array(opIDs),
Expand Down Expand Up @@ -373,14 +381,16 @@ func (m *OperationModel) BatchCopy(
copyCount, err := pgxTx.CopyFrom(
ctx,
pgx.Identifier{"operations"},
[]string{"id", "tx_hash", "operation_type", "operation_xdr", "ledger_number", "ledger_created_at"},
[]string{"id", "tx_hash", "operation_type", "operation_xdr", "result_code", "successful", "ledger_number", "ledger_created_at"},
pgx.CopyFromSlice(len(operations), func(i int) ([]any, error) {
op := operations[i]
return []any{
pgtype.Int8{Int64: op.ID, Valid: true},
pgtype.Text{String: op.TxHash, Valid: true},
pgtype.Text{String: string(op.OperationType), Valid: true},
pgtype.Text{String: op.OperationXDR, Valid: true},
pgtype.Text{String: op.ResultCode, Valid: true},
pgtype.Bool{Bool: op.Successful, Valid: true},
pgtype.Int4{Int32: int32(op.LedgerNumber), Valid: true},
pgtype.Timestamptz{Time: op.LedgerCreatedAt, Valid: true},
}, nil
Expand Down
Loading
Loading