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

fix: lastInsertedDeal wrong field #40

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion backend/bin/deal-observer-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const dealObserverLoop = async (makeRpcRequest, pgPool) => {
const currentFinalizedChainHead = currentChainHead.Height - finalityEpochs
// If the storage is empty we start 2000 blocks into the past as that is the furthest we can go with the public glif rpc endpoints.
const lastInsertedDeal = await fetchDealWithHighestActivatedEpoch(pgPool)
const lastEpochStored = lastInsertedDeal ? lastInsertedDeal.height : currentChainHead.Height - maxPastEpochs
const lastEpochStored = lastInsertedDeal ? lastInsertedDeal.activated_at_epoch : currentChainHead.Height - maxPastEpochs
for (let epoch = lastEpochStored + 1; epoch <= currentFinalizedChainHead; epoch++) {
await observeBuiltinActorEvents(epoch, pgPool, makeRpcRequest)
}
Expand Down
4 changes: 2 additions & 2 deletions backend/lib/deal-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function observeBuiltinActorEvents (blockHeight, pgPool, makeRpcReq

/**
* @param {Queryable} pgPool
* @returns {Promise<ActiveDealDbEntry | null>}
* @returns {Promise<Static<typeof ActiveDealDbEntry> | null>}
*/
export async function fetchDealWithHighestActivatedEpoch (pgPool) {
const query = 'SELECT * FROM active_deals ORDER BY activated_at_epoch DESC LIMIT 1'
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function storeActiveDeals (activeDeals, pgPool) {
/**
* @param {Queryable} pgPool
* @param {string} query
* @returns {Promise<Array<ActiveDealDbEntry>>}
* @returns {Promise<Array<Static<typeof ActiveDealDbEntry>>>}
*/
async function loadDeals (pgPool, query) {
const result = (await pgPool.query(query)).rows.map(deal => {
Expand Down