File tree Expand file tree Collapse file tree 4 files changed +15
-13
lines changed Expand file tree Collapse file tree 4 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,21 @@ pub(crate) struct NodeByteRange {
14
14
pub ( crate ) length : u64 ,
15
15
}
16
16
17
- /// Nodes that are persisted to disk.
17
+ /// Nodes of the Merkle Tree that are persisted to disk.
18
18
// TODO: replace `hash: Vec<u8>` with `hash: Hash`. This requires patching /
19
19
// rewriting the Blake2b crate to support `.from_bytes()` to serialize from
20
20
// disk.
21
21
#[ derive( Debug , Clone , PartialEq , Eq ) ]
22
22
pub struct Node {
23
+ /// This node's index in the Merkle tree
23
24
pub ( crate ) index : u64 ,
25
+ /// Hash of the data in this node
24
26
pub ( crate ) hash : Vec < u8 > ,
27
+ /// Number of bytes in this [`Node::data`]
25
28
pub ( crate ) length : u64 ,
29
+ /// Index of this nodes parent
26
30
pub ( crate ) parent : u64 ,
31
+ /// Hypercore's data. Can be receieved after the rest of the node, so it's optional.
27
32
pub ( crate ) data : Option < Vec < u8 > > ,
28
33
pub ( crate ) blank : bool ,
29
34
}
Original file line number Diff line number Diff line change 1
1
//! Types needed for passing information with with peers.
2
2
//! hypercore-protocol-rs uses these types and wraps them
3
3
//! into wire messages.
4
+
4
5
use crate :: Node ;
5
6
6
7
#[ derive( Debug , Clone , PartialEq ) ]
@@ -20,7 +21,7 @@ pub struct RequestSeek {
20
21
}
21
22
22
23
#[ derive( Debug , Clone , PartialEq ) ]
23
- /// Request of a DataUpgrade from peer
24
+ /// Request for a DataUpgrade from peer
24
25
pub struct RequestUpgrade {
25
26
/// Hypercore start index
26
27
pub start : u64 ,
@@ -79,7 +80,7 @@ pub struct DataBlock {
79
80
pub index : u64 ,
80
81
/// Data block value in bytes
81
82
pub value : Vec < u8 > ,
82
- /// TODO: document
83
+ /// Nodes of the merkle tree
83
84
pub nodes : Vec < Node > ,
84
85
}
85
86
@@ -104,11 +105,11 @@ pub struct DataSeek {
104
105
#[ derive( Debug , Clone , PartialEq ) ]
105
106
/// TODO: Document
106
107
pub struct DataUpgrade {
107
- /// TODO: Document
108
+ /// Starting block of this upgrade response
108
109
pub start : u64 ,
109
- /// TODO: Document
110
+ /// Number of blocks in this upgrade response
110
111
pub length : u64 ,
111
- /// TODO: Document
112
+ /// The nodes of the merkle tree
112
113
pub nodes : Vec < Node > ,
113
114
/// TODO: Document
114
115
pub additional_nodes : Vec < Node > ,
Original file line number Diff line number Diff line change @@ -147,11 +147,7 @@ impl Storage {
147
147
instruction. index ,
148
148
& buf,
149
149
) ) ,
150
- Err ( RandomAccessError :: OutOfBounds {
151
- offset : _,
152
- end : _,
153
- length,
154
- } ) => {
150
+ Err ( RandomAccessError :: OutOfBounds { length, .. } ) => {
155
151
if instruction. allow_miss {
156
152
Ok ( StoreInfo :: new_content_miss (
157
153
instruction. store . clone ( ) ,
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ use crate::{
10
10
/// first create the changes to this changeset, get out information from this to put to the oplog,
11
11
/// and the commit the changeset to the tree.
12
12
///
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).
15
15
#[ derive( Debug ) ]
16
16
pub ( crate ) struct MerkleTreeChangeset {
17
17
pub ( crate ) length : u64 ,
You can’t perform that action at this time.
0 commit comments