-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Consumption processing * fix tests * process * fix * make clippy happy
- Loading branch information
Showing
21 changed files
with
306 additions
and
45 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "processor" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
log = "0.4" | ||
shared = { path = "../../shared" } | ||
env_logger = "0.10.1" | ||
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } | ||
types = { path = "../../types" } |
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,84 @@ | ||
// This file is part of RegionX. | ||
// | ||
// RegionX is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// RegionX is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with RegionX. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use shared::{ | ||
config::config, | ||
consumption::{delete_consumption, get_consumption, write_batch_consumption}, | ||
registry::registered_paras, | ||
}; | ||
use std::collections::BTreeMap; | ||
use types::WeightConsumption; | ||
|
||
const LOG_TARGET: &str = "processor"; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let outputs = config().outputs; | ||
let paras = registered_paras(); | ||
|
||
paras.iter().for_each(|para| { | ||
let mut processed = BTreeMap::new(); | ||
|
||
log::info!( | ||
target: LOG_TARGET, | ||
"{}-{} - Processing consumption.", | ||
para.relay_chain, | ||
para.para_id, | ||
); | ||
|
||
(0..outputs).for_each(|output_index| { | ||
let consumption = if let Ok(data) = get_consumption(para.clone(), Some(output_index)) { | ||
data | ||
} else { | ||
log::error!( | ||
target: LOG_TARGET, | ||
"{}-{} - Failed to get consumption.", | ||
para.relay_chain, | ||
para.para_id, | ||
); | ||
vec![] | ||
}; | ||
|
||
consumption.into_iter().for_each(|data| { | ||
processed.entry(data.block_number).or_insert(data); | ||
}); | ||
}); | ||
|
||
let processed: Vec<WeightConsumption> = processed.values().cloned().collect(); | ||
|
||
log::info!( | ||
target: LOG_TARGET, | ||
"{}-{} - Writing processed consumption. Total blocks tracked: {}", | ||
para.relay_chain, | ||
para.para_id, | ||
processed.len() | ||
); | ||
|
||
if let Err(e) = write_batch_consumption(para.clone(), processed) { | ||
log::error!( | ||
target: LOG_TARGET, | ||
"{}-{} - Failed to write batch consumption: {:?}", | ||
para.relay_chain, | ||
para.para_id, | ||
e, | ||
); | ||
|
||
return; | ||
} | ||
|
||
(0..outputs).for_each(|output_index| delete_consumption(para.clone(), output_index)); | ||
}); | ||
} |
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
sh -c 'RUST_LOG=INFO ./target/release/processor' >> logs/processor.out 2>&1 |
Empty file.
Oops, something went wrong.