Skip to content

Commit 8929c43

Browse files
authored
all: clean up some dead_code annotations (#6103)
* graph: Move 'struct PoI' into tests module Otherwise, we get warnings about unused code * runtime: Remove unused enum AscSubgraphEntityOp * store: Remove unused struct CopyVid * graph: remove unused UnresolvedDataSource.resolve * all: remove unnecessary dead_code annotation in a few places * store: Remove unused deployment::features
1 parent b8ee392 commit 8929c43

File tree

12 files changed

+32
-115
lines changed

12 files changed

+32
-115
lines changed

graph/src/components/subgraph/proof_of_indexing/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl SharedProofOfIndexing {
8181
#[cfg(test)]
8282
mod tests {
8383
use super::*;
84+
use crate::util::stable_hash_glue::{impl_stable_hash, AsBytes};
8485
use crate::{
8586
data::store::Id,
8687
prelude::{BlockPtr, DeploymentHash, Value},
@@ -97,6 +98,33 @@ mod tests {
9798
use std::convert::TryInto;
9899
use web3::types::{Address, H256};
99100

101+
/// The PoI is the StableHash of this struct. This reference implementation is
102+
/// mostly here just to make sure that the online implementation is
103+
/// well-implemented (without conflicting sequence numbers, or other oddities).
104+
/// It's just way easier to check that this works, and serves as a kind of
105+
/// documentation as a side-benefit.
106+
pub struct PoI<'a> {
107+
pub causality_regions: HashMap<String, PoICausalityRegion<'a>>,
108+
pub subgraph_id: DeploymentHash,
109+
pub block_hash: H256,
110+
pub indexer: Option<Address>,
111+
}
112+
113+
fn h256_as_bytes(val: &H256) -> AsBytes<&[u8]> {
114+
AsBytes(val.as_bytes())
115+
}
116+
117+
fn indexer_opt_as_bytes(val: &Option<Address>) -> Option<AsBytes<&[u8]>> {
118+
val.as_ref().map(|v| AsBytes(v.as_bytes()))
119+
}
120+
121+
impl_stable_hash!(PoI<'_> {
122+
causality_regions,
123+
subgraph_id,
124+
block_hash: h256_as_bytes,
125+
indexer: indexer_opt_as_bytes
126+
});
127+
100128
/// Verify that the stable hash of a reference and online implementation match
101129
fn check(case: Case, cache: &mut HashMap<String, &str>) {
102130
let logger = Logger::root(Discard, o!());

graph/src/components/subgraph/proof_of_indexing/reference.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
11
use super::ProofOfIndexingEvent;
2-
use crate::prelude::DeploymentHash;
3-
use crate::util::stable_hash_glue::{impl_stable_hash, AsBytes};
4-
use std::collections::HashMap;
5-
use web3::types::{Address, H256};
6-
7-
/// The PoI is the StableHash of this struct. This reference implementation is
8-
/// mostly here just to make sure that the online implementation is
9-
/// well-implemented (without conflicting sequence numbers, or other oddities).
10-
/// It's just way easier to check that this works, and serves as a kind of
11-
/// documentation as a side-benefit.
12-
#[allow(dead_code)]
13-
pub struct PoI<'a> {
14-
pub causality_regions: HashMap<String, PoICausalityRegion<'a>>,
15-
pub subgraph_id: DeploymentHash,
16-
pub block_hash: H256,
17-
pub indexer: Option<Address>,
18-
}
19-
20-
#[allow(dead_code)]
21-
fn h256_as_bytes(val: &H256) -> AsBytes<&[u8]> {
22-
AsBytes(val.as_bytes())
23-
}
24-
25-
#[allow(dead_code)]
26-
fn indexer_opt_as_bytes(val: &Option<Address>) -> Option<AsBytes<&[u8]>> {
27-
val.as_ref().map(|v| AsBytes(v.as_bytes()))
28-
}
29-
30-
impl_stable_hash!(PoI<'_> {
31-
causality_regions,
32-
subgraph_id,
33-
block_hash: h256_as_bytes,
34-
indexer: indexer_opt_as_bytes
35-
});
2+
use crate::util::stable_hash_glue::impl_stable_hash;
363

374
pub struct PoICausalityRegion<'a> {
385
pub blocks: Vec<Block<'a>>,

graph/src/data_source/offchain.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -374,39 +374,6 @@ pub struct UnresolvedMapping {
374374
pub entities: Vec<String>,
375375
}
376376

377-
impl UnresolvedDataSource {
378-
#[allow(dead_code)]
379-
pub(super) async fn resolve(
380-
self,
381-
resolver: &Arc<dyn LinkResolver>,
382-
logger: &Logger,
383-
manifest_idx: u32,
384-
causality_region: CausalityRegion,
385-
schema: &InputSchema,
386-
) -> Result<DataSource, Error> {
387-
info!(logger, "Resolve offchain data source";
388-
"name" => &self.name,
389-
"kind" => &self.kind,
390-
"source" => format_args!("{:?}", &self.source),
391-
);
392-
393-
let kind = OffchainDataSourceKind::from_str(self.kind.as_str())?;
394-
let source = kind.try_parse_source(Bytes::from(self.source.file.link.as_bytes()))?;
395-
396-
Ok(DataSource {
397-
manifest_idx,
398-
kind,
399-
name: self.name,
400-
source,
401-
mapping: self.mapping.resolve(resolver, schema, logger).await?,
402-
context: Arc::new(None),
403-
creation_block: None,
404-
done_at: Arc::new(AtomicI32::new(NOT_DONE_VALUE)),
405-
causality_region,
406-
})
407-
}
408-
}
409-
410377
impl UnresolvedMapping {
411378
pub async fn resolve(
412379
self,

graph/src/data_source/subgraph.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ impl UnresolvedDataSource {
344344
Ok(())
345345
}
346346

347-
#[allow(dead_code)]
348347
pub(super) async fn resolve<C: Blockchain>(
349348
self,
350349
resolver: &Arc<dyn LinkResolver>,

graph/src/schema/input/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,6 @@ mod validations {
17021702

17031703
/// Helper struct for validations
17041704
struct Schema<'a> {
1705-
#[allow(dead_code)]
17061705
spec_version: &'a Version,
17071706
schema: &'a BaseSchema,
17081707
subgraph_schema_type: Option<&'a s::ObjectType>,

graphql/src/store/resolver.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::query::ext::BlockConstraint;
2424
/// A resolver that fetches entities from a `Store`.
2525
#[derive(Clone, CheapClone)]
2626
pub struct StoreResolver {
27-
#[allow(dead_code)]
2827
logger: Logger,
2928
pub(crate) store: Arc<dyn QueryStore>,
3029
pub(crate) block_ptr: Option<BlockPtr>,

runtime/wasm/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub enum DeterminismLevel {
99
Deterministic,
1010

1111
/// This error is known to be non-deterministic. For example, an intermittent http failure.
12-
#[allow(dead_code)]
1312
NonDeterministic,
1413

1514
/// The runtime is processing a given block, but there is an indication that the blockchain client

runtime/wasm/src/to_from/external.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use graph::runtime::{
1010
use graph::{data::store, runtime::DeterministicHostError};
1111
use graph::{prelude::serde_json, runtime::FromAscObj};
1212
use graph::{prelude::web3::types as web3, runtime::AscHeap};
13-
use graph_runtime_derive::AscType;
1413

1514
use crate::asc_abi::class::*;
1615

@@ -465,14 +464,6 @@ where
465464
}
466465
}
467466

468-
#[derive(Debug, Clone, Eq, PartialEq, AscType)]
469-
#[allow(dead_code)]
470-
pub enum AscSubgraphEntityOp {
471-
Create,
472-
Modify,
473-
Delete,
474-
}
475-
476467
impl ToAscObj<AscEnum<YamlValueKind>> for serde_yaml::Value {
477468
fn to_asc_obj<H: AscHeap + ?Sized>(
478469
&self,

server/index-node/src/resolver.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ pub struct IndexNodeResolver<S: Store> {
9898
logger: Logger,
9999
blockchain_map: Arc<BlockchainMap>,
100100
store: Arc<S>,
101-
#[allow(dead_code)]
102101
link_resolver: Arc<dyn LinkResolver>,
103102
bearer_token: Option<String>,
104103
}

store/postgres/src/chain_head_listener.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ impl Watcher {
4040
}
4141
}
4242

43-
#[allow(dead_code)]
4443
fn send(&self) {
4544
// Unwrap: `self` holds a receiver.
4645
self.sender.send(()).unwrap()

0 commit comments

Comments
 (0)