Skip to content

Commit

Permalink
new implementation of datalog pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ddulesov committed Feb 25, 2021
1 parent 3998976 commit 745cc05
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ hex-literal = { version = "0.3.1", optional = true }
smallvec = { version = "1.4.1" }

#local dependencies
pallet-robonomics-datalog = { version = "0.2.0", path = "../../pallets/datalog", default-features = false }
pallet-robonomics-datalog = { version = "0.3.0", path = "../../pallets/datalog", default-features = false }
# primitives
sp-authority-discovery = { version = "2.0.1", default-features = false }
sp-consensus-babe = { version = "0.8.1", default-features = false }
Expand Down
8 changes: 8 additions & 0 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,18 @@ impl pallet_finality_tracker::Trait for Runtime {
type ReportLatency = ReportLatency;
}

parameter_types! {
pub const DatalogWindowSize: u64 = 128;
pub const DatalogMaximumMessageSize: usize = 512;
}

impl pallet_robonomics_datalog::Trait for Runtime {
type Time = Timestamp;
type Record = Vec<u8>;
type Event = Event;
type WindowSize = DatalogWindowSize;
type MaximumMessageSize = DatalogMaximumMessageSize;
type WeightInfo = ();
}

construct_runtime!(
Expand Down
2 changes: 1 addition & 1 deletion pallets/datalog/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pallet-robonomics-datalog"
description = "Robonomics Network data logging Substrate runtime module"
version = "0.2.0"
version = "0.3.0"
authors = ["Airalab <[email protected]>"]
edition = "2018"

Expand Down
20 changes: 20 additions & 0 deletions pallets/datalog/src/default_weight.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};

pub trait WeightInfo {
fn record() -> Weight;
fn erase(win: u64) -> Weight;
}

impl WeightInfo for () {
fn record() -> Weight {
(500_000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
}

fn erase(win: u64) -> Weight {
(100_000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1+win as Weight))
}
}
Loading

0 comments on commit 745cc05

Please sign in to comment.