mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-27 14:49:37 +00:00
WIP Java sync api
This commit is contained in:
parent
44e73b969e
commit
8434656f5e
@ -0,0 +1,26 @@
|
||||
package org.servalproject.servaldna.rhizome;
|
||||
|
||||
import org.servalproject.servaldna.SubscriberId;
|
||||
|
||||
public class RhizomeSyncStatus {
|
||||
public final SubscriberId sid;
|
||||
public final long receivedBundles;
|
||||
public final long sentBytes;
|
||||
public final long sendingBytes;
|
||||
public final long receivedBytes;
|
||||
public final long requestedBytes;
|
||||
|
||||
public RhizomeSyncStatus(SubscriberId sid,
|
||||
long receivedBundles,
|
||||
long sentBytes,
|
||||
long sendingBytes,
|
||||
long receivedBytes,
|
||||
long requestedBytes) {
|
||||
this.sid = sid;
|
||||
this.receivedBundles = receivedBundles;
|
||||
this.sentBytes = sentBytes;
|
||||
this.sendingBytes = sendingBytes;
|
||||
this.receivedBytes = receivedBytes;
|
||||
this.requestedBytes = requestedBytes;
|
||||
}
|
||||
}
|
@ -51,6 +51,7 @@ struct sync_peer_state{
|
||||
void *peer_context;
|
||||
unsigned send_count;
|
||||
unsigned recv_count;
|
||||
uint8_t explained;
|
||||
struct node *root;
|
||||
};
|
||||
|
||||
@ -703,6 +704,7 @@ static int recv_key(struct sync_state *state, struct sync_peer_state *peer_state
|
||||
if (message->prefix_len == KEY_LEN_BITS+1){
|
||||
// peer has no node of their own, they don't have anything that we have.
|
||||
peer_missing_leaf_nodes(state, peer_state, state->root, NODE_CHILDREN, 0);
|
||||
peer_state->explained = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -740,9 +742,13 @@ static int recv_key(struct sync_state *state, struct sync_peer_state *peer_state
|
||||
// Nothing to do if we understand the rest of the differences
|
||||
if (cmp_message(&peer_message, &node->message)==0){
|
||||
state->received_uninteresting++;
|
||||
if (node->message.min_prefix_len==0)
|
||||
peer_state->explained = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
peer_state->explained = 0;
|
||||
|
||||
// once we've looked at all of the prefix_len bits of the incoming key
|
||||
// we need to stop
|
||||
if (peer_message.prefix_len <= prefix_len){
|
||||
@ -916,4 +922,4 @@ void sync_enum_differences(struct sync_state *state,
|
||||
enum_diffs(state, peer_state, peer_state->root, callback);
|
||||
peer_state = peer_state->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user