Skip to content

Commit

Permalink
Fix TODO's in docs
Browse files Browse the repository at this point in the history
Also fix some small lints
  • Loading branch information
cowlicks committed Oct 21, 2024
1 parent 5902243 commit 2b59501
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/common/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ pub(crate) struct NodeByteRange {
pub(crate) length: u64,
}

/// Nodes that are persisted to disk.
/// Nodes of the Merkle Tree that are persisted to disk.
// TODO: replace `hash: Vec<u8>` with `hash: Hash`. This requires patching /
// rewriting the Blake2b crate to support `.from_bytes()` to serialize from
// disk.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Node {
/// This node's index in the Merkle tree
pub(crate) index: u64,
/// Hash of the data in this node
pub(crate) hash: Vec<u8>,
/// Number of bytes in this [`Node::data`]
pub(crate) length: u64,
/// Index of this nodes parent
pub(crate) parent: u64,
/// Hypercore's data. Can be receieved after the rest of the node, so it's optional.
pub(crate) data: Option<Vec<u8>>,
pub(crate) blank: bool,
}
Expand Down
11 changes: 6 additions & 5 deletions src/common/peer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Types needed for passing information with with peers.
//! hypercore-protocol-rs uses these types and wraps them
//! into wire messages.
use crate::Node;

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -20,7 +21,7 @@ pub struct RequestSeek {
}

#[derive(Debug, Clone, PartialEq)]
/// Request of a DataUpgrade from peer
/// Request for a DataUpgrade from peer
pub struct RequestUpgrade {
/// Hypercore start index
pub start: u64,
Expand Down Expand Up @@ -79,7 +80,7 @@ pub struct DataBlock {
pub index: u64,
/// Data block value in bytes
pub value: Vec<u8>,
/// TODO: document
/// Nodes of the merkle tree
pub nodes: Vec<Node>,
}

Expand All @@ -104,11 +105,11 @@ pub struct DataSeek {
#[derive(Debug, Clone, PartialEq)]
/// TODO: Document
pub struct DataUpgrade {
/// TODO: Document
/// Starting block of this upgrade response
pub start: u64,
/// TODO: Document
/// Number of blocks in this upgrade response
pub length: u64,
/// TODO: Document
/// The nodes of the merkle tree
pub nodes: Vec<Node>,
/// TODO: Document
pub additional_nodes: Vec<Node>,
Expand Down
6 changes: 1 addition & 5 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ impl Storage {
instruction.index,
&buf,
)),
Err(RandomAccessError::OutOfBounds {
offset: _,
end: _,
length,
}) => {
Err(RandomAccessError::OutOfBounds { length, .. }) => {
if instruction.allow_miss {
Ok(StoreInfo::new_content_miss(
instruction.store.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/tree/merkle_tree_changeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
/// first create the changes to this changeset, get out information from this to put to the oplog,
/// and the commit the changeset to the tree.
///
/// This is called "MerkleTreeBatch" in Javascript, see:
/// https://github.com/hypercore-protocol/hypercore/blob/master/lib/merkle-tree.js
/// This is called "MerkleTreeBatch" in Javascript, source
/// [here](https://github.com/holepunchto/hypercore/blob/88a1a2f1ebe6e33102688225516c4e882873f710/lib/merkle-tree.js#L44).
#[derive(Debug)]
pub(crate) struct MerkleTreeChangeset {
pub(crate) length: u64,
Expand Down

0 comments on commit 2b59501

Please sign in to comment.