huskies: merge 1116 story rebuild_and_restart loses pending CRDT ops by calling exec() before persistence channel drains
This commit is contained in:
@@ -5,11 +5,13 @@
|
||||
//! it to the live document, sends it to the persistence channel, and broadcasts
|
||||
//! it to sync peers via [`super::SYNC_TX`].
|
||||
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use bft_json_crdt::json_crdt::JsonValue;
|
||||
use bft_json_crdt::op::Op;
|
||||
|
||||
use super::super::types::CrdtEvent;
|
||||
use super::{CrdtState, statics};
|
||||
use super::{CrdtState, init::PersistMsg, statics};
|
||||
|
||||
/// Create a CRDT op via `op_fn`, sign it, apply it, and send it to the
|
||||
/// persistence channel. The closure receives `&mut CrdtState` so it can
|
||||
@@ -21,7 +23,13 @@ where
|
||||
let raw_op = op_fn(state);
|
||||
let signed = raw_op.sign(&state.keypair);
|
||||
state.crdt.apply(signed.clone());
|
||||
if state.persist_tx.send(signed.clone()).is_err() {
|
||||
if state
|
||||
.persist_tx
|
||||
.send(PersistMsg::Op(Box::new(signed.clone())))
|
||||
.is_ok()
|
||||
{
|
||||
statics::PERSIST_PENDING.fetch_add(1, Ordering::Relaxed);
|
||||
} else {
|
||||
let op_type = if signed.inner.is_deleted {
|
||||
"Delete"
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user