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: consistent naming for resolving payloads #90

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NikolasHaimerl
Copy link
Contributor

@NikolasHaimerl NikolasHaimerl commented Feb 10, 2025

We want consistent naming for resolving payload CIDs:
The action is resolving the state is resolved or unresolved.

Closes #87

Copy link

sentry-io bot commented Feb 10, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: backend/lib/piece-indexer-service.js

Function Unhandled Issue
getDealPayloadCid Error: Failed to make RPC request. getDealPayload...
Event Count: 40 Affected Users: 0

Did you find this useful? React with a 👍 or 👎

export const lookUpPayloadCidsLoop = async (makeRpcRequest, getDealPayloadCid, pgPool) => {
const LOOP_NAME = 'Look up payload CIDs'
export const resolvePayloadCidsLoop = async (makeRpcRequest, resolvePayloadCid, pgPool) => {
const LOOP_NAME = 'Resolve payload CIDs'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have to change the Grafana query after this change.

const numOfUnresolvedPayloadCids = await countStoredActiveDealsWithUnresolvedPayloadCid(pgPool)
if (INFLUXDB_TOKEN) {
recordTelemetry('look_up_payload_cids_stats', point => {
recordTelemetry('resolve_payload_cids_stats', point => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to change the Grafana query after this change

@NikolasHaimerl NikolasHaimerl marked this pull request as ready for review February 10, 2025 09:06
Copy link
Contributor

@pyropy pyropy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! 👏🏻

backend/lib/piece-indexer-service.js Show resolved Hide resolved
import { findAndSubmitUnsubmittedDeals, submitDealsToSparkApi } from '../lib/spark-api-submit-deals.js'
import { getDealPayloadCid } from '../lib/piece-indexer-service.js'
import { resolvePayloadCid } from '../lib/piece-indexer-service.js'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing: One function is called resolvePayloadCids, the other resolvePayloadCid. Looking at the name, I would expect the 1st to do the same as the 2nd, only for multiple payload CIDs.

It's different from that though: The 1st looks up what to resolve, calls the look up function, and also saves the state in the DB.

I don't have a solution on the top of my head. @bajtos wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're using "to resolve" for two things here:

  1. Content resolution (similar to name resolution)
  2. Marking a task as resolved

We should use different terms for these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NikolasHaimerl do you have a suggestion? Let's use "resolve" for one of the two cases from the previous comment, and another term for the other

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are suggesting we use two different verbs, one for the action of fetching the payloads via HTTP and another for the overall process of filling payload CIDs in the database that are currently set to NULL. Did I understand that correctly?

Copy link
Member

@juliangruber juliangruber Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm saying is that this is currently inconsistent naming. Consistent naming means to give the same thing the same name, but in turn, to give different things different names.

Here we have two processes (currently called resolvePayloadCid and resolvePayloadCids), that are different (in more ways than their multitude). Therefore at least one of them needs a different name.

backend/lib/piece-indexer-service.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistent naming for resolving payload CIDs
3 participants