Skip to content
Snippets Groups Projects
Commit 03b858a7 authored by Pascal Engélibert's avatar Pascal Engélibert 🚴
Browse files

Fix distance-oracle EvaluationPool type

parent f8152c2b
No related branches found
No related tags found
1 merge request!105Distance Oracle
Pipeline #33242 waiting for manual action
......@@ -14,14 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use crate::{
runtime,
runtime::runtime_types::{
pallet_distance::median::MedianAcc,
sp_arithmetic::per_things::Perbill,
sp_core::bounded::{bounded_btree_set::BoundedBTreeSet, bounded_vec::BoundedVec},
},
};
use crate::runtime;
use sp_core::H256;
use subxt::storage::StorageKey;
......@@ -29,10 +22,6 @@ use subxt::storage::StorageKey;
pub type Client = subxt::OnlineClient<crate::RuntimeConfig>;
pub type AccountId = subxt::ext::sp_runtime::AccountId32;
pub type IdtyIndex = u32;
pub type EvaluationPool<AccountId, IdtyIndex> = (
BoundedVec<(IdtyIndex, MedianAcc<Perbill>)>,
BoundedBTreeSet<AccountId>,
);
pub async fn client(rpc_url: String) -> Client {
Client::from_url(rpc_url)
......@@ -65,7 +54,7 @@ pub async fn current_pool(
client: &Client,
parent_hash: H256,
current_session: u32,
) -> Option<EvaluationPool<AccountId, IdtyIndex>> {
) -> Option<runtime::runtime_types::pallet_distance::types::EvaluationPool<AccountId, IdtyIndex>> {
client
.storage()
.fetch(
......
......@@ -158,7 +158,7 @@ pub async fn run(
};
// Stop if nothing to evaluate
if evaluation_pool.0 .0.is_empty() {
if evaluation_pool.evaluations.0.is_empty() {
debug!("Nothing to do: Pool is empty");
return None;
}
......@@ -228,8 +228,8 @@ pub async fn run(
let referees = members;
let evaluation = evaluation_pool
.evaluations
.0
.0
.as_slice()
.par_iter()
.map(|(idty, _)| distance_rule(&received_certs, &referees, settings.max_depth, *idty))
......
......@@ -28,8 +28,11 @@ pub struct Client {
}
pub type AccountId = subxt::ext::sp_runtime::AccountId32;
pub type IdtyIndex = u32;
pub type EvaluationPool<AccountId, IdtyIndex> =
((Vec<(IdtyIndex, MedianAcc<Perbill>)>,), BTreeSet<AccountId>);
pub struct EvaluationPool<AccountId: Ord, IdtyIndex> {
pub evaluations: (Vec<(IdtyIndex, MedianAcc<Perbill>)>,),
pub evaluators: BTreeSet<AccountId>,
}
pub async fn client(_rpc_url: String) -> Client {
unimplemented!()
......@@ -52,8 +55,8 @@ pub async fn current_pool(
_parent_hash: H256,
_current_session: u32,
) -> Option<EvaluationPool<AccountId, IdtyIndex>> {
Some((
(client
Some(EvaluationPool {
evaluations: (client
.wot
.get_enabled()
.into_iter()
......@@ -65,8 +68,8 @@ pub async fn current_pool(
})
})
.collect(),),
std::collections::BTreeSet::new(),
))
evaluators: BTreeSet::new(),
})
}
pub async fn evaluation_block(_client: &Client, _parent_hash: H256) -> H256 {
......
......@@ -494,7 +494,7 @@ async fn should_have_distance_result_in_sessions(
.unwrap()
.ok_or_else(|| anyhow::anyhow!("given pool is empty"))?;
for (sample_idty, _) in pool.0 .0 {
for (sample_idty, _) in pool.evaluations.0 {
if sample_idty == idty_id {
return Ok(());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment