diff options
Diffstat (limited to 'src/swarm/relay.rs')
| -rw-r--r-- | src/swarm/relay.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/swarm/relay.rs b/src/swarm/relay.rs index 454a46a..492b59d 100644 --- a/src/swarm/relay.rs +++ b/src/swarm/relay.rs @@ -52,6 +52,10 @@ pub(crate) async fn pull_if_behind(state: &AppState, peer: &str, remote: &transp if remote.epoch != state.local_epoch() || !topology::is_neighbour(state, peer) { return; } + // The common case, the same heads, needs only the cached heads (read lock). + if HeadsSummary::of(state.doc.read().await.heads().to_vec()) == remote.heads { + return; + } let missing = match &remote.heads { HeadsSummary::Heads(heads) => { // AutoCommit's lookups take &mut self. |
