Skip to content

Commit 632ef9f

Browse files
author
Zoran Cvetkov
committed
renames
1 parent 56f041a commit 632ef9f

File tree

11 files changed

+56
-53
lines changed

11 files changed

+56
-53
lines changed

graph/src/blockchain/block_stream.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl<C: Blockchain> TriggersAdapterWrapper<C> {
357357

358358
fn create_subgraph_trigger_from_entities(
359359
filter: &SubgraphFilter,
360-
entities: Vec<EntityWithType>,
360+
entities: Vec<EntitySourceOperation>,
361361
) -> Vec<subgraph::TriggerData> {
362362
entities
363363
.into_iter()
@@ -372,7 +372,7 @@ async fn create_subgraph_triggers<C: Blockchain>(
372372
logger: Logger,
373373
blocks: Vec<C::Block>,
374374
filter: &SubgraphFilter,
375-
mut entities: BTreeMap<BlockNumber, Vec<EntityWithType>>,
375+
mut entities: BTreeMap<BlockNumber, Vec<EntitySourceOperation>>,
376376
) -> Result<Vec<BlockWithTriggers<C>>, Error> {
377377
let logger_clone = logger.cheap_clone();
378378

@@ -428,15 +428,15 @@ async fn scan_subgraph_triggers<C: Blockchain>(
428428
}
429429

430430
#[derive(Debug, Clone, Eq, PartialEq)]
431-
pub enum EntitySubgraphOperation {
431+
pub enum EntityOperationKind {
432432
Create,
433433
Modify,
434434
Delete,
435435
}
436436

437437
#[derive(Debug, Clone, Eq, PartialEq)]
438-
pub struct EntityWithType {
439-
pub entity_op: EntitySubgraphOperation,
438+
pub struct EntitySourceOperation {
439+
pub entity_op: EntityOperationKind,
440440
pub entity_type: EntityType,
441441
pub entity: Entity,
442442
pub vid: i64,
@@ -448,7 +448,7 @@ async fn get_entities_for_range(
448448
schema: &InputSchema,
449449
from: BlockNumber,
450450
to: BlockNumber,
451-
) -> Result<BTreeMap<BlockNumber, Vec<EntityWithType>>, Error> {
451+
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, Error> {
452452
let entity_types: Result<Vec<EntityType>> = filter
453453
.entities
454454
.iter()

graph/src/components/store/traits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use async_trait::async_trait;
66
use web3::types::{Address, H256};
77

88
use super::*;
9-
use crate::blockchain::block_stream::{EntityWithType, FirehoseCursor};
9+
use crate::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor};
1010
use crate::blockchain::{BlockTime, ChainIdentifier, ExtendedBlockPtr};
1111
use crate::components::metrics::stopwatch::StopwatchMetrics;
1212
use crate::components::server::index_node::VersionInfo;
@@ -302,7 +302,7 @@ pub trait SourceableStore: Sync + Send + 'static {
302302
entity_types: Vec<EntityType>,
303303
causality_region: CausalityRegion,
304304
block_range: Range<BlockNumber>,
305-
) -> Result<BTreeMap<BlockNumber, Vec<EntityWithType>>, StoreError>;
305+
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, StoreError>;
306306

307307
fn input_schema(&self) -> InputSchema;
308308

@@ -318,7 +318,7 @@ impl<T: ?Sized + SourceableStore> SourceableStore for Arc<T> {
318318
entity_types: Vec<EntityType>,
319319
causality_region: CausalityRegion,
320320
block_range: Range<BlockNumber>,
321-
) -> Result<BTreeMap<BlockNumber, Vec<EntityWithType>>, StoreError> {
321+
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, StoreError> {
322322
(**self).get_range(entity_types, causality_region, block_range)
323323
}
324324

graph/src/data_source/common.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::blockchain::block_stream::EntityWithType;
1+
use crate::blockchain::block_stream::EntitySourceOperation;
22
use crate::prelude::{BlockPtr, Value};
33
use crate::{components::link_resolver::LinkResolver, data::value::Word, prelude::Link};
44
use anyhow::{anyhow, Context, Error};
@@ -193,7 +193,10 @@ impl CallDecl {
193193
})
194194
}
195195

196-
pub fn address_for_entity_handler(&self, entity: &EntityWithType) -> Result<H160, Error> {
196+
pub fn address_for_entity_handler(
197+
&self,
198+
entity: &EntitySourceOperation,
199+
) -> Result<H160, Error> {
197200
match &self.expr.address {
198201
// Static hex address - just return it directly
199202
CallArg::HexAddress(address) => Ok(*address),
@@ -227,7 +230,7 @@ impl CallDecl {
227230
/// Returns an error if argument count mismatches or if conversion fails.
228231
pub fn args_for_entity_handler(
229232
&self,
230-
entity: &EntityWithType,
233+
entity: &EntitySourceOperation,
231234
param_types: Vec<ParamType>,
232235
) -> Result<Vec<Token>, Error> {
233236
self.validate_entity_handler_args(&param_types)?;
@@ -260,7 +263,7 @@ impl CallDecl {
260263
&self,
261264
arg: &CallArg,
262265
expected_type: &ParamType,
263-
entity: &EntityWithType,
266+
entity: &EntitySourceOperation,
264267
) -> Result<Token, Error> {
265268
match arg {
266269
CallArg::HexAddress(address) => self.process_hex_address(*address, expected_type),
@@ -292,7 +295,7 @@ impl CallDecl {
292295
&self,
293296
name: &str,
294297
expected_type: &ParamType,
295-
entity: &EntityWithType,
298+
entity: &EntitySourceOperation,
296299
) -> Result<Token, Error> {
297300
let value = entity
298301
.entity
@@ -549,7 +552,7 @@ impl DeclaredCall {
549552
pub fn from_entity_trigger(
550553
mapping: &dyn FindMappingABI,
551554
call_decls: &CallDecls,
552-
entity: &EntityWithType,
555+
entity: &EntitySourceOperation,
553556
) -> Result<Vec<DeclaredCall>, anyhow::Error> {
554557
Self::create_calls(mapping, call_decls, |decl, function| {
555558
let param_types = function

graph/src/data_source/subgraph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
blockchain::{block_stream::EntityWithType, Block, Blockchain},
2+
blockchain::{block_stream::EntitySourceOperation, Block, Blockchain},
33
components::{link_resolver::LinkResolver, store::BlockNumber},
44
data::{
55
subgraph::{calls_host_fn, SPEC_VERSION_1_3_0},
@@ -353,11 +353,11 @@ pub struct MappingEntityTrigger {
353353
#[derive(Clone, PartialEq, Eq)]
354354
pub struct TriggerData {
355355
pub source: DeploymentHash,
356-
pub entity: EntityWithType,
356+
pub entity: EntitySourceOperation,
357357
}
358358

359359
impl TriggerData {
360-
pub fn new(source: DeploymentHash, entity: EntityWithType) -> Self {
360+
pub fn new(source: DeploymentHash, entity: EntitySourceOperation) -> Self {
361361
Self { source, entity }
362362
}
363363

runtime/wasm/src/to_from/external.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ethabi;
22

3-
use graph::blockchain::block_stream::{EntitySubgraphOperation, EntityWithType};
3+
use graph::blockchain::block_stream::{EntityOperationKind, EntitySourceOperation};
44
use graph::data::store::scalar::Timestamp;
55
use graph::data::value::Word;
66
use graph::prelude::{BigDecimal, BigInt};
@@ -482,16 +482,16 @@ pub struct AscEntityTrigger {
482482
pub vid: i64,
483483
}
484484

485-
impl ToAscObj<AscEntityTrigger> for EntityWithType {
485+
impl ToAscObj<AscEntityTrigger> for EntitySourceOperation {
486486
fn to_asc_obj<H: AscHeap + ?Sized>(
487487
&self,
488488
heap: &mut H,
489489
gas: &GasCounter,
490490
) -> Result<AscEntityTrigger, HostExportError> {
491491
let entity_op = match self.entity_op {
492-
EntitySubgraphOperation::Create => AscSubgraphEntityOp::Create,
493-
EntitySubgraphOperation::Modify => AscSubgraphEntityOp::Modify,
494-
EntitySubgraphOperation::Delete => AscSubgraphEntityOp::Delete,
492+
EntityOperationKind::Create => AscSubgraphEntityOp::Create,
493+
EntityOperationKind::Modify => AscSubgraphEntityOp::Modify,
494+
EntityOperationKind::Delete => AscSubgraphEntityOp::Delete,
495495
};
496496

497497
Ok(AscEntityTrigger {

store/postgres/src/deployment_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use diesel::pg::PgConnection;
44
use diesel::r2d2::{ConnectionManager, PooledConnection};
55
use diesel::{prelude::*, sql_query};
66
use graph::anyhow::Context;
7-
use graph::blockchain::block_stream::{EntityWithType, FirehoseCursor};
7+
use graph::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor};
88
use graph::blockchain::BlockTime;
99
use graph::components::store::write::RowGroup;
1010
use graph::components::store::{
@@ -1062,7 +1062,7 @@ impl DeploymentStore {
10621062
entity_types: Vec<EntityType>,
10631063
causality_region: CausalityRegion,
10641064
block_range: Range<BlockNumber>,
1065-
) -> Result<BTreeMap<BlockNumber, Vec<EntityWithType>>, StoreError> {
1065+
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, StoreError> {
10661066
let mut conn = self.get_conn()?;
10671067
let layout = self.layout(&mut conn, site)?;
10681068
layout.find_range(&mut conn, entity_types, causality_region, block_range)

store/postgres/src/relational.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use diesel::serialize::{Output, ToSql};
2424
use diesel::sql_types::Text;
2525
use diesel::{connection::SimpleConnection, Connection};
2626
use diesel::{debug_query, sql_query, OptionalExtension, PgConnection, QueryResult, RunQueryDsl};
27-
use graph::blockchain::block_stream::{EntitySubgraphOperation, EntityWithType};
27+
use graph::blockchain::block_stream::{EntityOperationKind, EntitySourceOperation};
2828
use graph::blockchain::BlockTime;
2929
use graph::cheap_clone::CheapClone;
3030
use graph::components::store::write::{RowGroup, WriteChunk};
@@ -522,14 +522,14 @@ impl Layout {
522522
entity_types: Vec<EntityType>,
523523
causality_region: CausalityRegion,
524524
block_range: Range<BlockNumber>,
525-
) -> Result<BTreeMap<BlockNumber, Vec<EntityWithType>>, StoreError> {
525+
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, StoreError> {
526526
let mut tables = vec![];
527527
let mut et_map: HashMap<String, Arc<EntityType>> = HashMap::new();
528528
for et in entity_types {
529529
tables.push(self.table_for_entity(&et)?.as_ref());
530530
et_map.insert(et.to_string(), Arc::new(et));
531531
}
532-
let mut entities: BTreeMap<BlockNumber, Vec<EntityWithType>> = BTreeMap::new();
532+
let mut entities: BTreeMap<BlockNumber, Vec<EntitySourceOperation>> = BTreeMap::new();
533533

534534
// collect all entities that have their 'lower(block_range)' attribute in the
535535
// interval of blocks defined by the variable block_range. For the immutable
@@ -558,14 +558,14 @@ impl Layout {
558558
let mut lower = lower_now.unwrap_or(&EntityDataExt::default()).clone();
559559
let mut upper = upper_now.unwrap_or(&EntityDataExt::default()).clone();
560560
let transform = |ede: EntityDataExt,
561-
entity_op: EntitySubgraphOperation|
562-
-> Result<(EntityWithType, BlockNumber), StoreError> {
561+
entity_op: EntityOperationKind|
562+
-> Result<(EntitySourceOperation, BlockNumber), StoreError> {
563563
let e = EntityData::new(ede.entity, ede.data);
564564
let block = ede.block_number;
565565
let entity_type = e.entity_type(&self.input_schema);
566566
let entity = e.deserialize_with_layout::<Entity>(self, None)?;
567567
let vid = ede.vid;
568-
let ewt = EntityWithType {
568+
let ewt = EntitySourceOperation {
569569
entity_op,
570570
entity_type,
571571
entity,
@@ -588,22 +588,22 @@ impl Layout {
588588
match lower.cmp(&upper) {
589589
std::cmp::Ordering::Greater => {
590590
// we have upper bound at this block, but no lower bounds at the same block so it's deletion
591-
let (ewt, block) = transform(upper, EntitySubgraphOperation::Delete)?;
591+
let (ewt, block) = transform(upper, EntityOperationKind::Delete)?;
592592
// advance upper_vec pointer
593593
upper_now = upper_iter.next();
594594
upper = upper_now.unwrap_or(&EntityDataExt::default()).clone();
595595
(ewt, block)
596596
}
597597
std::cmp::Ordering::Less => {
598598
// we have lower bound at this block but no upper bound at the same block so its creation
599-
let (ewt, block) = transform(lower, EntitySubgraphOperation::Create)?;
599+
let (ewt, block) = transform(lower, EntityOperationKind::Create)?;
600600
// advance lower_vec pointer
601601
lower_now = lower_iter.next();
602602
lower = lower_now.unwrap_or(&EntityDataExt::default()).clone();
603603
(ewt, block)
604604
}
605605
std::cmp::Ordering::Equal => {
606-
let (ewt, block) = transform(lower, EntitySubgraphOperation::Modify)?;
606+
let (ewt, block) = transform(lower, EntityOperationKind::Modify)?;
607607
// advance both lower_vec and upper_vec pointers
608608
lower_now = lower_iter.next();
609609
lower = lower_now.unwrap_or(&EntityDataExt::default()).clone();
@@ -615,7 +615,7 @@ impl Layout {
615615
}
616616
(true, false) => {
617617
// we have lower bound at this block but no upper bound at the same block so its creation
618-
let (ewt, block) = transform(lower, EntitySubgraphOperation::Create)?;
618+
let (ewt, block) = transform(lower, EntityOperationKind::Create)?;
619619
// advance lower_vec pointer
620620
lower_now = lower_iter.next();
621621
lower = lower_now.unwrap_or(&EntityDataExt::default()).clone();
@@ -624,7 +624,7 @@ impl Layout {
624624
(false, have_upper) => {
625625
// we have upper bound at this block, but no lower bounds at all so it's deletion
626626
assert!(have_upper);
627-
let (ewt, block) = transform(upper, EntitySubgraphOperation::Delete)?;
627+
let (ewt, block) = transform(upper, EntityOperationKind::Delete)?;
628628
// advance upper_vec pointer
629629
upper_now = upper_iter.next();
630630
upper = upper_now.unwrap_or(&EntityDataExt::default()).clone();

store/postgres/src/writable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::time::Instant;
66
use std::{collections::BTreeMap, sync::Arc};
77

88
use async_trait::async_trait;
9-
use graph::blockchain::block_stream::{EntityWithType, FirehoseCursor};
9+
use graph::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor};
1010
use graph::blockchain::BlockTime;
1111
use graph::components::store::{Batch, DeploymentCursorTracker, DerivedEntityQuery, ReadStore};
1212
use graph::constraint_violation;
@@ -1593,7 +1593,7 @@ impl store::SourceableStore for SourceableStore {
15931593
entity_types: Vec<EntityType>,
15941594
causality_region: CausalityRegion,
15951595
block_range: Range<BlockNumber>,
1596-
) -> Result<BTreeMap<BlockNumber, Vec<EntityWithType>>, StoreError> {
1596+
) -> Result<BTreeMap<BlockNumber, Vec<EntitySourceOperation>>, StoreError> {
15971597
self.store.get_range(
15981598
self.site.clone(),
15991599
entity_types,

store/test-store/tests/postgres/writable.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use graph::blockchain::block_stream::{EntityWithType, FirehoseCursor};
1+
use graph::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor};
22
use graph::data::subgraph::schema::DeploymentCreate;
33
use graph::data::value::Word;
44
use graph::data_source::CausalityRegion;
@@ -337,13 +337,13 @@ fn restart() {
337337
fn read_range_test() {
338338
run_test(|store, writable, sourceable, deployment| async move {
339339
let result_entities = vec![
340-
r#"(1, [EntityWithType { entity_op: Create, entity_type: EntityType(Counter), entity: Entity { count: Int(2), id: String("1") }, vid: 1 }, EntityWithType { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(2), id: String("1") }, vid: 1 }])"#,
341-
r#"(2, [EntityWithType { entity_op: Modify, entity_type: EntityType(Counter), entity: Entity { count: Int(4), id: String("1") }, vid: 2 }, EntityWithType { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(4), id: String("2") }, vid: 2 }])"#,
342-
r#"(3, [EntityWithType { entity_op: Delete, entity_type: EntityType(Counter), entity: Entity { count: Int(4), id: String("1") }, vid: 2 }, EntityWithType { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(6), id: String("3") }, vid: 3 }])"#,
343-
r#"(4, [EntityWithType { entity_op: Create, entity_type: EntityType(Counter), entity: Entity { count: Int(8), id: String("1") }, vid: 3 }, EntityWithType { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(8), id: String("4") }, vid: 4 }])"#,
344-
r#"(5, [EntityWithType { entity_op: Delete, entity_type: EntityType(Counter), entity: Entity { count: Int(8), id: String("1") }, vid: 3 }, EntityWithType { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(10), id: String("5") }, vid: 5 }])"#,
345-
r#"(6, [EntityWithType { entity_op: Create, entity_type: EntityType(Counter), entity: Entity { count: Int(12), id: String("1") }, vid: 4 }])"#,
346-
r#"(7, [EntityWithType { entity_op: Delete, entity_type: EntityType(Counter), entity: Entity { count: Int(12), id: String("1") }, vid: 4 }])"#,
340+
r#"(1, [EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter), entity: Entity { count: Int(2), id: String("1") }, vid: 1 }, EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(2), id: String("1") }, vid: 1 }])"#,
341+
r#"(2, [EntitySourceOperation { entity_op: Modify, entity_type: EntityType(Counter), entity: Entity { count: Int(4), id: String("1") }, vid: 2 }, EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(4), id: String("2") }, vid: 2 }])"#,
342+
r#"(3, [EntitySourceOperation { entity_op: Delete, entity_type: EntityType(Counter), entity: Entity { count: Int(4), id: String("1") }, vid: 2 }, EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(6), id: String("3") }, vid: 3 }])"#,
343+
r#"(4, [EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter), entity: Entity { count: Int(8), id: String("1") }, vid: 3 }, EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(8), id: String("4") }, vid: 4 }])"#,
344+
r#"(5, [EntitySourceOperation { entity_op: Delete, entity_type: EntityType(Counter), entity: Entity { count: Int(8), id: String("1") }, vid: 3 }, EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter2), entity: Entity { count: Int(10), id: String("5") }, vid: 5 }])"#,
345+
r#"(6, [EntitySourceOperation { entity_op: Create, entity_type: EntityType(Counter), entity: Entity { count: Int(12), id: String("1") }, vid: 4 }])"#,
346+
r#"(7, [EntitySourceOperation { entity_op: Delete, entity_type: EntityType(Counter), entity: Entity { count: Int(12), id: String("1") }, vid: 4 }])"#,
347347
];
348348
let subgraph_store = store.subgraph_store();
349349
writable.deployment_synced().unwrap();
@@ -356,7 +356,7 @@ fn read_range_test() {
356356

357357
let br: Range<BlockNumber> = 0..18;
358358
let entity_types = vec![COUNTER_TYPE.clone(), COUNTER2_TYPE.clone()];
359-
let e: BTreeMap<i32, Vec<EntityWithType>> = sourceable
359+
let e: BTreeMap<i32, Vec<EntitySourceOperation>> = sourceable
360360
.get_range(entity_types.clone(), CausalityRegion::ONCHAIN, br.clone())
361361
.unwrap();
362362
assert_eq!(e.len(), 5);
@@ -370,7 +370,7 @@ fn read_range_test() {
370370
}
371371
writable.flush().await.unwrap();
372372
writable.deployment_synced().unwrap();
373-
let e: BTreeMap<i32, Vec<EntityWithType>> = sourceable
373+
let e: BTreeMap<i32, Vec<EntitySourceOperation>> = sourceable
374374
.get_range(entity_types, CausalityRegion::ONCHAIN, br)
375375
.unwrap();
376376
assert_eq!(e.len(), 7);

tests/src/fixture/ethereum.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::{
66
test_ptr, CommonChainConfig, MutexBlockStreamBuilder, NoopAdapterSelector,
77
NoopRuntimeAdapterBuilder, StaticBlockRefetcher, StaticStreamBuilder, Stores, TestChain,
88
};
9-
use graph::blockchain::block_stream::{EntitySubgraphOperation, EntityWithType};
9+
use graph::blockchain::block_stream::{EntityOperationKind, EntitySourceOperation};
1010
use graph::blockchain::client::ChainClient;
1111
use graph::blockchain::{BlockPtr, Trigger, TriggersAdapterSelector};
1212
use graph::cheap_clone::CheapClone;
@@ -167,10 +167,10 @@ pub fn push_test_subgraph_trigger(
167167
source: DeploymentHash,
168168
entity: Entity,
169169
entity_type: EntityType,
170-
entity_op: EntitySubgraphOperation,
170+
entity_op: EntityOperationKind,
171171
vid: i64,
172172
) {
173-
let entity = EntityWithType {
173+
let entity = EntitySourceOperation {
174174
entity: entity,
175175
entity_type: entity_type,
176176
entity_op: entity_op,

0 commit comments

Comments
 (0)