Skip to content
Snippets Groups Projects
Commit 799c03f4 authored by qiuhao's avatar qiuhao Committed by Xiliang Chen
Browse files

update: impl DataProvider for oracle (#50)

* update: impl DataProvider for oracle

* update: optimize code
parent 8afaae67
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ use sr_primitives::traits::Member;
// would cause compiling error in `decl_module!` and `construct_runtime!`
// #3295 https://github.com/paritytech/substrate/issues/3295
use frame_system::{self as system, ensure_signed};
pub use orml_traits::{CombineData, OnNewData};
pub use orml_traits::{CombineData, DataProvider, OnNewData};
pub use timestamped_value::TimestampedValue;
type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
......@@ -94,6 +94,12 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> DataProvider<T::Key, T::Value> for Module<T> {
fn get(key: &T::Key) -> Option<T::Value> {
Self::get(key).map(|timestamped_value| timestamped_value.value)
}
}
impl<T: Trait> Module<T> {
fn _feed_values(who: T::AccountId, values: Vec<(T::Key, T::Value)>) -> result::Result<(), Error> {
ensure!(T::OperatorProvider::can_feed_data(&who), Error::NoPermission);
......
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