aboutsummaryrefslogtreecommitdiffstats
path: root/src/state
diff options
context:
space:
mode:
Diffstat (limited to 'src/state')
-rw-r--r--src/state/mod.rs10
-rw-r--r--src/state/peer.rs5
2 files changed, 12 insertions, 3 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs
index 1fc8ea8..ff19124 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -532,7 +532,8 @@ impl AppState {
&& let [hash] = after[..]
{
if state.sign_every == SignEvery::Change || sign.wanted(&replica.doc) {
- replica.signatures.sign(hash, key);
+ let replica = &mut *replica;
+ replica.signatures.sign(&replica.doc, hash, key);
} else {
replica.signatures.left_unsigned(hash);
}
@@ -565,8 +566,11 @@ impl AppState {
let key = Arc::clone(&key);
let _ = tokio::task::spawn_blocking(move || {
// Looked at first under the read lock: mostly there is nothing to sign.
- state.doc.blocking_read().signatures.pending()
- && state.doc.blocking_write().signatures.sign_latest(&key)
+ state.doc.blocking_read().signatures.pending() && {
+ let mut replica = state.doc.blocking_write();
+ let replica = &mut *replica;
+ replica.signatures.sign_latest(&replica.doc, &key)
+ }
})
.await;
}
diff --git a/src/state/peer.rs b/src/state/peer.rs
index 7000386..e0b161d 100644
--- a/src/state/peer.rs
+++ b/src/state/peer.rs
@@ -98,6 +98,9 @@ pub(crate) struct PeerState {
/// Everything about the current Automerge sync with this peer; a reset replaces it.
pub(crate) sync: SyncSession,
+ /// The signatures of changes it was sent, up to this stamp
+ /// (`Signatures::newer_than`); a reset sends them again.
+ pub(crate) signatures_sent: u64,
pub(crate) liveness: Liveness,
pub(crate) added_at: Instant,
@@ -300,6 +303,7 @@ impl PeerState {
hello_backoff: Backoff::new(HELLO_RETRY, HELLO_RETRY_MAX),
probe_backoff: timing.probe_backoff(),
sync: SyncSession::new(timing.sync_reply_backoff()),
+ signatures_sent: 0,
liveness: Liveness::Unknown,
added_at: Instant::now(),
last_seen: None,
@@ -369,6 +373,7 @@ impl PeerState {
let mut reply_backoff = self.sync.reply_backoff;
reply_backoff.reset();
self.sync = SyncSession::new(reply_backoff);
+ self.signatures_sent = 0;
// Said over the session that ended.
self.reaches = None;
self.round_trips = None;