Skip to content

Commit 497ae06

Browse files
committed
Some reworks
1 parent f65e262 commit 497ae06

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

crates/hriblt/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Add the library to your `Cargo.toml` file.
1111
hriblt = "0.1"
1212
```
1313

14-
Create two encoding sessions, one containing your data, and another containing the counter-parties data. This counterparty data might have been sent to you over a network for example.
14+
Create two encoding sessions, one containing Alice's data, and another containing Bob's data. Bob's data might have been sent to you over a network for example.
1515

16-
The following example attempts to reconcile the differences between two sets of `u64` integers, and is done from the perspective of "Bob", who has recieved some symbols from "Alice".
16+
The following example attempts to reconcile the differences between two such sets of `u64` integers, and is done from the perspective of "Bob", who has received some symbols from "Alice".
1717

1818
```rust
1919
use hriblt::{DecodingSession, EncodingSession, DefaultHashFunctions};
-16.9 KB
Binary file not shown.

crates/hriblt/docs/sizing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Regardless, there are some advantages to getting the size of your decoding sessi
66

77
## Coded Symbol Multiplier
88

9-
The number of coded symbols required to find the difference between two sets is proportional to the difference between the two sets. The following chart shows the relationship between the number of coded symbols required to decode HRIBLT and the size of the diff. Note that the size of the base set (before diffs were added) was fixed.
9+
The number of coded symbols required to find the difference between two sets is proportional to the difference between the two sets. The following chart shows the relationship between the number of coded symbols required to decode HRIBLT and the size of the diff. Note that the size of the base set (before diffs were added) was fixed at 1000 entries.
1010

1111
`y = len(coded_symbols) / diff_size`
1212

crates/hriblt/src/coded_symbol.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ impl<T: Encodable> CodedSymbol<T> {
5858

5959
/// Checks whether this coded symbol is pure, i.e., whether it represents a single entity
6060
/// A pure coded symbol must satisfy the following conditions:
61-
/// - The 1-bit counter must be 1 or -1 (which are both represented by the bit being set)
62-
/// - The checksum must match the checksum of the value.
61+
/// - The 1-bit counter must be 1 or -1 (which are both represented by the least significant bit being set)
62+
/// - The checksum must match the absolute value of the checksum of the value.
63+
/// The sign (-/+) tells you if it was an insertion or deletion
6364
/// - The indices of the value must match the index of this coded symbol.
6465
pub(crate) fn is_pure<S: HashFunctions<T>>(
6566
&self,
@@ -118,10 +119,10 @@ fn indices_contains<T: std::hash::Hash>(
118119
if stream_len > 32 && i % 32 != 0 {
119120
let seed = i % 4;
120121
let j = index_for_seed(state, value, stream_len, seed as u32);
121-
if i == j { 1 } else { 0 }
122+
i32::from(i == j)
122123
} else {
123124
indices(state, value, stream_len)
124-
.map(|j| if j == i { 1 } else { 0 })
125+
.map(|j| i32::from(i == j))
125126
.sum()
126127
}
127128
}

crates/hriblt/src/decoding_session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
pub struct DecodingSession<T: Encodable, H: HashFunctions<T>> {
1111
/// The encoded stream of hashes.
1212
/// All recovered coded symbols have been removed from this stream.
13-
/// If decoded failed, then one can simply append more data and continue decoding.
13+
/// If decoded fails, then one can simply append more data and continue decoding.
1414
encoded: EncodingSession<T, H>,
1515
/// All the recovered coded symbols.
1616
recovered: Vec<CodedSymbol<T>>,

0 commit comments

Comments
 (0)