Skip to content

Commit

Permalink
refactor: merge poi mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Dec 11, 2023
1 parent 1342c7b commit 59254e0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 73 deletions.
2 changes: 1 addition & 1 deletion graph-gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::Deserialize;
use serde_with::{serde_as, DeserializeAs, DisplayFromStr, FromInto};
use toolshed::url::Url;

use crate::poi::ProofOfIndexingInfo;
use crate::indexers::public_poi::ProofOfIndexingInfo;

#[serde_as]
#[derive(Debug, Deserialize)]
Expand Down
26 changes: 24 additions & 2 deletions graph-gateway/src/indexers/public_poi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ use serde_with::{serde_as, DisplayFromStr};
use thegraph::types::DeploymentId;
use toolshed::url::Url;

pub type ProofOfIndexing = B256;

#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
pub struct ProofOfIndexingInfo {
/// Proof of indexing (POI).
pub proof_of_indexing: ProofOfIndexing,
/// POI deployment ID (the IPFS Hash in the Graph Network Subgraph).
pub deployment_id: DeploymentId,
/// POI block number.
pub block_number: BlockNumber,
}

impl ProofOfIndexingInfo {
/// Get the POI bytes.
pub fn poi(&self) -> ProofOfIndexing {
self.proof_of_indexing
}

/// Get the POI metadata.
pub fn meta(&self) -> (DeploymentId, BlockNumber) {
(self.deployment_id, self.block_number)
}
}

pub async fn query(
client: reqwest::Client,
status_url: Url,
Expand Down Expand Up @@ -66,8 +90,6 @@ pub async fn merge_queries(

pub const MAX_REQUESTS_PER_QUERY: usize = 10;

pub type ProofOfIndexing = B256;

pub(super) const PUBLIC_PROOF_OF_INDEXING_QUERY_DOCUMENT: &str = indoc! {
r#"query ($requests: [PublicProofOfIndexingRequest!]!) {
publicProofsOfIndexing(requests: $requests) {
Expand Down
4 changes: 2 additions & 2 deletions graph-gateway/src/indexings_blocklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use std::sync::Arc;
use std::time::Duration;

use alloy_primitives::Address;
use itertools::Itertools;
use itertools::Itertools as _;
use thegraph::types::DeploymentId;
use tokio::sync::Mutex;
use toolshed::url::Url;

use indexer_selection::Indexing;

use crate::indexers::public_poi;
use crate::poi::ProofOfIndexingInfo;
use crate::indexers::public_poi::ProofOfIndexingInfo;
use crate::topology::{Deployment, Indexer};

pub const DEFAULT_UPDATE_INTERVAL: Duration = Duration::from_secs(20 * 60); // 20 minutes
Expand Down
1 change: 0 additions & 1 deletion graph-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub mod indexings_blocklist;
pub mod ipfs;
pub mod metrics;
pub mod network_subgraph;
pub mod poi;
pub mod receipts;
pub mod reports;
pub mod subgraph_studio;
Expand Down
66 changes: 0 additions & 66 deletions graph-gateway/src/poi.rs

This file was deleted.

2 changes: 1 addition & 1 deletion graph-gateway/tests/it_indexings_blocklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use alloy_primitives::Address;
use thegraph::types::DeploymentId;
use tokio::time::timeout;

use graph_gateway::indexers::public_poi::{ProofOfIndexing, ProofOfIndexingInfo};
use graph_gateway::indexings_blocklist::check_indexer_pois;
use graph_gateway::poi::{ProofOfIndexing, ProofOfIndexingInfo};

/// Test utility function to create a valid `ProofOfIndexingInfo` with an zeros POI.
fn zero_poi() -> ProofOfIndexing {
Expand Down

0 comments on commit 59254e0

Please sign in to comment.