Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include block height in _cursor string #76

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub type Member = String;
pub type Key = String;
pub type Delta = i64;
pub type Timestamp = u64;
pub type Height = u64;

#[derive(Debug)]
pub enum Value {
Expand Down Expand Up @@ -108,7 +109,7 @@ pub enum CRDTCommand {
AnyWriteWins(Key, Value),
// TODO make sure Value is a generic not stringly typed
PNCounter(Key, Delta),
BlockFinished(Point),
BlockFinished(Point, Height),
}

impl CRDTCommand {
Expand Down Expand Up @@ -170,7 +171,8 @@ impl CRDTCommand {
pub fn block_finished(block: &MultiEraBlock) -> CRDTCommand {
let hash = block.hash();
let slot = block.slot();
let height = block.number();
let point = Point::Specific(slot, hash.to_vec());
CRDTCommand::BlockFinished(point)
CRDTCommand::BlockFinished(point, height)
}
}
4 changes: 3 additions & 1 deletion src/storage/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ impl gasket::runtime::Worker for Worker {
.incr(key, value)
.or_restart()?;
}
model::CRDTCommand::BlockFinished(point) => {
model::CRDTCommand::BlockFinished(point, height) => {
let cursor_str = crosscut::PointArg::from(point).to_string();

let cursor_str = format!("{},{}", cursor_str, height);

self.connection
.as_mut()
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion src/storage/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl gasket::runtime::Worker for Worker {
model::CRDTCommand::PNCounter(key, value) => {
log::debug!("increasing counter [{}], by [{}]", key, value);
}
model::CRDTCommand::BlockFinished(point) => {
model::CRDTCommand::BlockFinished(point, _height) => {
log::debug!("block finished {:?}", point);
let mut last_point = self.last_point.lock().unwrap();
*last_point = Some(crosscut::PointArg::from(point));
Expand Down