Skip to content

Commit 745cc05

Browse files
committed
new implementation of datalog pallet
1 parent 3998976 commit 745cc05

File tree

6 files changed

+275
-42
lines changed

6 files changed

+275
-42
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ hex-literal = { version = "0.3.1", optional = true }
2222
smallvec = { version = "1.4.1" }
2323

2424
#local dependencies
25-
pallet-robonomics-datalog = { version = "0.2.0", path = "../../pallets/datalog", default-features = false }
25+
pallet-robonomics-datalog = { version = "0.3.0", path = "../../pallets/datalog", default-features = false }
2626
# primitives
2727
sp-authority-discovery = { version = "2.0.1", default-features = false }
2828
sp-consensus-babe = { version = "0.8.1", default-features = false }

node/runtime/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,18 @@ impl pallet_finality_tracker::Trait for Runtime {
526526
type ReportLatency = ReportLatency;
527527
}
528528

529+
parameter_types! {
530+
pub const DatalogWindowSize: u64 = 128;
531+
pub const DatalogMaximumMessageSize: usize = 512;
532+
}
533+
529534
impl pallet_robonomics_datalog::Trait for Runtime {
530535
type Time = Timestamp;
531536
type Record = Vec<u8>;
532537
type Event = Event;
538+
type WindowSize = DatalogWindowSize;
539+
type MaximumMessageSize = DatalogMaximumMessageSize;
540+
type WeightInfo = ();
533541
}
534542

535543
construct_runtime!(

pallets/datalog/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pallet-robonomics-datalog"
33
description = "Robonomics Network data logging Substrate runtime module"
4-
version = "0.2.0"
4+
version = "0.3.0"
55
authors = ["Airalab <[email protected]>"]
66
edition = "2018"
77

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
2+
3+
pub trait WeightInfo {
4+
fn record() -> Weight;
5+
fn erase(win: u64) -> Weight;
6+
}
7+
8+
impl WeightInfo for () {
9+
fn record() -> Weight {
10+
(500_000 as Weight)
11+
.saturating_add(DbWeight::get().reads(2 as Weight))
12+
.saturating_add(DbWeight::get().writes(3 as Weight))
13+
}
14+
15+
fn erase(win: u64) -> Weight {
16+
(100_000 as Weight)
17+
.saturating_add(DbWeight::get().reads(1 as Weight))
18+
.saturating_add(DbWeight::get().writes(1+win as Weight))
19+
}
20+
}

0 commit comments

Comments
 (0)