def message_please_send(self, localhash): if localhash != self.datasource.hash_history[-1]: # bad state. let reconnection and such handle it self.disconnect("data changed during init") return message = b"" if self.init_remote_hash is not None: idx = self.init_remote_hash_index hashes = self.datasource.hash_history[idx:] assert hashes[0] == self.init_remote_hash message += b" ".join(hashes) del hashes self.init_finished() else: # diverged! self.diverged = True message += b" ".join(self.datasource.hash_history) message += b" " message += syncdata._encode_data(self.datasource.data) self.command(b"history_and_data", message)
def data_changed(self, parents): d = syncdata._encode_data(self.datasource.data) self.command(b"new_data", b" ".join(parents) + b" " + d)