-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added pipeline added brew.sh script added concurrency to all pipelines
- Loading branch information
Showing
17 changed files
with
138 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ query IndexingStatuses { | |
number | ||
hash | ||
} | ||
earliestBlock { | ||
number | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use crate::prelude::IndexingStatus; | ||
use serde::Deserialize; | ||
|
||
#[derive(Copy, Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub enum BlockChoicePolicy { | ||
// Use the earliest block that all indexers have in common | ||
Earliest, | ||
// Use the block that maximizes the total number of blocks synced across all indexers | ||
MaxSyncedBlocks, | ||
} | ||
|
||
impl Default for BlockChoicePolicy { | ||
fn default() -> Self { | ||
BlockChoicePolicy::MaxSyncedBlocks | ||
} | ||
} | ||
|
||
impl BlockChoicePolicy { | ||
pub fn choose_block<'a>( | ||
&self, | ||
statuses: impl Iterator<Item = &'a IndexingStatus>, | ||
) -> Option<u64> { | ||
match self { | ||
BlockChoicePolicy::Earliest => statuses | ||
.map(|status| &status.latest_block.number) | ||
.min() | ||
.copied(), | ||
BlockChoicePolicy::MaxSyncedBlocks => { | ||
// Assuming that all statuses have the same `deployment` and `earliest_block_num`, | ||
// this will return the block number that maximizes the total number of blocks | ||
// synced across all indexers. | ||
|
||
let mut indexers_ascending: Vec<&'a IndexingStatus> = statuses.collect(); | ||
indexers_ascending.sort_by_key(|status| status.latest_block.number); | ||
|
||
let mut max_utility = 0; | ||
let mut best_block: Option<u64> = None; | ||
|
||
for (i, status) in indexers_ascending.iter().enumerate() { | ||
let remaining_statuses = indexers_ascending.len() - i; | ||
let block_number = status.latest_block.number; | ||
if block_number < status.earliest_block_num { | ||
// This status is inconsistent, ignore it, avoiding overflow. | ||
continue; | ||
} | ||
|
||
let utility = | ||
remaining_statuses as u64 * (block_number - status.earliest_block_num); | ||
|
||
if utility > max_utility { | ||
max_utility = utility; | ||
best_block = Some(block_number); | ||
} | ||
} | ||
|
||
best_block | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod api_types; | ||
pub mod block_choice; | ||
pub mod config; | ||
mod indexer; | ||
pub mod network_subgraph; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.