Skip to content
Snippets Groups Projects
Unverified Commit 64ff5a4d authored by bgallois's avatar bgallois
Browse files

fix #255

parent c521f5e1
No related branches found
No related tags found
No related merge requests found
Pipeline #38223 failed
...@@ -40,21 +40,24 @@ where ...@@ -40,21 +40,24 @@ where
Backend: sc_client_api::Backend<B>, Backend: sc_client_api::Backend<B>,
IdtyIndex: Decode + Encode + PartialEq + TypeInfo, IdtyIndex: Decode + Encode + PartialEq + TypeInfo,
{ {
let pool_index = client let pool_index = if let Some(index) = client
.storage( .storage(
parent, parent,
&StorageKey( &StorageKey(
frame_support::storage::storage_prefix(b"Distance", b"CurrentPoolIndex").to_vec(), frame_support::storage::storage_prefix(b"Distance", b"CurrentPoolIndex").to_vec(),
), ),
) )?
.expect("CurrentIndex is Err") .map_or(None, |raw| u32::decode(&mut &raw.0[..]).ok())
.map_or(0, |raw| { {
u32::decode(&mut &raw.0[..]).expect("cannot decode CurrentIndex") index
}); } else {
log::error!("🧙 [distance oracle] CurrentPoolIndex cannot be decoded");
return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None));
};
let published_results = client let published_results = if let Some(results) = client
.storage( .storage(
parent, B::Hash::default(),
&StorageKey( &StorageKey(
frame_support::storage::storage_prefix( frame_support::storage::storage_prefix(
b"Distance", b"Distance",
...@@ -68,10 +71,14 @@ where ...@@ -68,10 +71,14 @@ where
.to_vec(), .to_vec(),
), ),
)? )?
.map_or_else(Default::default, |raw| { .map_or(None, |raw| {
pallet_distance::EvaluationPool::<AccountId32, IdtyIndex>::decode(&mut &raw.0[..]) pallet_distance::EvaluationPool::<AccountId32, IdtyIndex>::decode(&mut &raw.0[..]).ok()
.expect("cannot decode EvaluationPool") }) {
}); results
} else {
log::error!("🧙 [distance oracle] EvaluationPool cannot be decoded");
return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None));
};
// Have we already published a result for this period? // Have we already published a result for this period?
// The block author is guaranteed to be in the owner_keys. // The block author is guaranteed to be in the owner_keys.
......
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