Skip to content

Commit 2b59501

Browse files
committed
Fix TODO's in docs
Also fix some small lints
1 parent 5902243 commit 2b59501

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/common/node.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ pub(crate) struct NodeByteRange {
1414
pub(crate) length: u64,
1515
}
1616

17-
/// Nodes that are persisted to disk.
17+
/// Nodes of the Merkle Tree that are persisted to disk.
1818
// TODO: replace `hash: Vec<u8>` with `hash: Hash`. This requires patching /
1919
// rewriting the Blake2b crate to support `.from_bytes()` to serialize from
2020
// disk.
2121
#[derive(Debug, Clone, PartialEq, Eq)]
2222
pub struct Node {
23+
/// This node's index in the Merkle tree
2324
pub(crate) index: u64,
25+
/// Hash of the data in this node
2426
pub(crate) hash: Vec<u8>,
27+
/// Number of bytes in this [`Node::data`]
2528
pub(crate) length: u64,
29+
/// Index of this nodes parent
2630
pub(crate) parent: u64,
31+
/// Hypercore's data. Can be receieved after the rest of the node, so it's optional.
2732
pub(crate) data: Option<Vec<u8>>,
2833
pub(crate) blank: bool,
2934
}

src/common/peer.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Types needed for passing information with with peers.
22
//! hypercore-protocol-rs uses these types and wraps them
33
//! into wire messages.
4+
45
use crate::Node;
56

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

2223
#[derive(Debug, Clone, PartialEq)]
23-
/// Request of a DataUpgrade from peer
24+
/// Request for a DataUpgrade from peer
2425
pub struct RequestUpgrade {
2526
/// Hypercore start index
2627
pub start: u64,
@@ -79,7 +80,7 @@ pub struct DataBlock {
7980
pub index: u64,
8081
/// Data block value in bytes
8182
pub value: Vec<u8>,
82-
/// TODO: document
83+
/// Nodes of the merkle tree
8384
pub nodes: Vec<Node>,
8485
}
8586

@@ -104,11 +105,11 @@ pub struct DataSeek {
104105
#[derive(Debug, Clone, PartialEq)]
105106
/// TODO: Document
106107
pub struct DataUpgrade {
107-
/// TODO: Document
108+
/// Starting block of this upgrade response
108109
pub start: u64,
109-
/// TODO: Document
110+
/// Number of blocks in this upgrade response
110111
pub length: u64,
111-
/// TODO: Document
112+
/// The nodes of the merkle tree
112113
pub nodes: Vec<Node>,
113114
/// TODO: Document
114115
pub additional_nodes: Vec<Node>,

src/storage/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ impl Storage {
147147
instruction.index,
148148
&buf,
149149
)),
150-
Err(RandomAccessError::OutOfBounds {
151-
offset: _,
152-
end: _,
153-
length,
154-
}) => {
150+
Err(RandomAccessError::OutOfBounds { length, .. }) => {
155151
if instruction.allow_miss {
156152
Ok(StoreInfo::new_content_miss(
157153
instruction.store.clone(),

src/tree/merkle_tree_changeset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::{
1010
/// first create the changes to this changeset, get out information from this to put to the oplog,
1111
/// and the commit the changeset to the tree.
1212
///
13-
/// This is called "MerkleTreeBatch" in Javascript, see:
14-
/// https://github.com/hypercore-protocol/hypercore/blob/master/lib/merkle-tree.js
13+
/// This is called "MerkleTreeBatch" in Javascript, source
14+
/// [here](https://github.com/holepunchto/hypercore/blob/88a1a2f1ebe6e33102688225516c4e882873f710/lib/merkle-tree.js#L44).
1515
#[derive(Debug)]
1616
pub(crate) struct MerkleTreeChangeset {
1717
pub(crate) length: u64,

0 commit comments

Comments
 (0)