Updated on 2026-08-14
This commit is contained in:
parent
91200c4973
commit
0693835f07
9 changed files with 99 additions and 13 deletions
|
|
@ -2,7 +2,7 @@
|
|||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "c0f8e7d958a8852440a5bdec5a989f0e",
|
||||
"identityHash": "1ddc01e929ea21940e7f1e9e35810691",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "express_provider",
|
||||
|
|
@ -271,15 +271,16 @@
|
|||
"createSql": "CREATE INDEX IF NOT EXISTS `index_express_exchange_from_address_from_network_from_contract_address_created_at` ON `${TABLE_NAME}` (`from_address`, `from_network`, `from_contract_address`, `created_at`)"
|
||||
},
|
||||
{
|
||||
"name": "index_express_exchange_to_network_to_contract_address_created_at",
|
||||
"name": "index_express_exchange_payout_address_to_network_to_contract_address_created_at",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"payout_address",
|
||||
"to_network",
|
||||
"to_contract_address",
|
||||
"created_at"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_express_exchange_to_network_to_contract_address_created_at` ON `${TABLE_NAME}` (`to_network`, `to_contract_address`, `created_at`)"
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_express_exchange_payout_address_to_network_to_contract_address_created_at` ON `${TABLE_NAME}` (`payout_address`, `to_network`, `to_contract_address`, `created_at`)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -650,7 +651,7 @@
|
|||
],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c0f8e7d958a8852440a5bdec5a989f0e')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1ddc01e929ea21940e7f1e9e35810691')"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -62,20 +62,21 @@ interface ExpressHistoryDao {
|
|||
): Flow<List<ExpressExchangeEntity>>
|
||||
|
||||
/**
|
||||
* Incoming swaps: the viewed currency is the swap's `to` side. Such a deal was initiated from a
|
||||
* different coin, so the row is stored under that coin's `from_address` — hence this query is
|
||||
* cross-address, matched by the `to` asset. Join to on-chain by `payout_hash`.
|
||||
* Incoming swaps: the viewed currency is the swap's `to` side, so the row is looked up by its `payout_address`
|
||||
* (where the target assets landed = this currency's address). Join to on-chain by `payout_hash`.
|
||||
*/
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM express_exchange
|
||||
WHERE to_network = :network
|
||||
WHERE payout_address = :payoutAddress
|
||||
AND to_network = :network
|
||||
AND to_contract_address = :contract
|
||||
AND (created_at >= :fromCreatedAtIso OR status IN (:activeStatuses))
|
||||
ORDER BY created_at DESC
|
||||
""",
|
||||
)
|
||||
fun observeIncomingSwaps(
|
||||
payoutAddress: String,
|
||||
network: String,
|
||||
contract: String,
|
||||
fromCreatedAtIso: String,
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@ import androidx.room.*
|
|||
indices = [
|
||||
// Outgoing swaps lookup (observeOutgoingSwaps): from-address + from-asset equality, created_at range/sort.
|
||||
Index(value = ["from_address", "from_network", "from_contract_address", "created_at"]),
|
||||
// Incoming (cross-owner) swaps lookup (observeIncomingSwaps): to-asset equality, created_at range/sort.
|
||||
// No owner filter here, so to_contract_address in the index is what keeps a popular to-network selective.
|
||||
Index(value = ["to_network", "to_contract_address", "created_at"]),
|
||||
// Incoming swaps lookup (observeIncomingSwaps): payout-address + to-asset equality, created_at range/sort.
|
||||
Index(value = ["payout_address", "to_network", "to_contract_address", "created_at"]),
|
||||
],
|
||||
)
|
||||
data class ExpressExchangeEntity(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue