Skip to content

Commit

Permalink
Remove RLE.
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed May 15, 2024
1 parent db838df commit b54a58b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 245 deletions.
15 changes: 2 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mod snapshot;
mod config;
mod hex_utils;
mod verifier;
mod rle;

pub mod types;

Expand All @@ -51,7 +50,7 @@ mod tests;
/// sync formats arise in the future.
///
/// The fourth byte is the protocol version in case our format gets updated.
const GOSSIP_PREFIX: [u8; 4] = [76, 68, 75, 1];
const GOSSIP_PREFIX: [u8; 3] = [76, 68, 75];

pub struct RapidSyncProcessor<L: Deref> where L::Target: Logger {
network_graph: Arc<NetworkGraph<L>>,
Expand All @@ -60,7 +59,6 @@ pub struct RapidSyncProcessor<L: Deref> where L::Target: Logger {

pub struct SerializedResponse {
pub data: Vec<u8>,
pub compressed_data: Vec<u8>,
pub message_count: u32,
pub node_announcement_count: u32,
/// Despite the name, the count of node announcements that have associated updates, be those
Expand Down Expand Up @@ -365,23 +363,14 @@ async fn serialize_delta<L: Deref + Clone>(network_graph: Arc<NetworkGraph<L>>,

unversioned_output.append(&mut output);
let mut versioned_output = GOSSIP_PREFIX.to_vec();
versioned_output.push(serialization_version);
versioned_output.append(&mut unversioned_output.clone());

let mut compressed_unversioned_output = rle::encode(&unversioned_output);
{
// sanity check
let recovered_unversioned_output = rle::decode(&compressed_unversioned_output).unwrap();
assert_eq!(unversioned_output, recovered_unversioned_output);
}
let mut compressed_output = [76, 68, 75, 2].to_vec();
compressed_output.append(&mut compressed_unversioned_output);

log_info!(logger, "duplicated node ids: {}", duplicate_node_ids);
log_info!(logger, "latest seen timestamp: {:?}", serialization_details.latest_seen);

SerializedResponse {
data: versioned_output,
compressed_data: compressed_output,
message_count,
node_announcement_count: node_id_count,
node_update_count,
Expand Down
231 changes: 0 additions & 231 deletions src/rle.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ impl<L: Deref + Clone> Snapshotter<L> where L::Target: Logger {
let snapshot_path = format!("{}/{}", pending_snapshot_directory, snapshot_filename);
log_info!(self.logger, "Persisting {}-second snapshot: {} ({} messages, {} announcements, {} updates ({} full, {} incremental))", current_scope, snapshot_filename, snapshot.message_count, snapshot.channel_announcement_count, snapshot.update_count, snapshot.update_count_full, snapshot.update_count_incremental);
fs::write(&snapshot_path, snapshot.data).unwrap();
fs::write(format!("{}.rle", snapshot_path), snapshot.compressed_data).unwrap();
snapshot_filenames_by_scope.insert(current_scope.clone(), snapshot_filename);
}
}
Expand Down

0 comments on commit b54a58b

Please sign in to comment.