Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ipld docs #1004

Merged
merged 2 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ipld/blockstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#[cfg(feature = "buffered")]
mod buffered;
#[cfg(feature = "resolve")]
/// This module is used for resolving Cids and Ipld recursively. This is generally only needed
/// for testing because links should generally not be collapsed to generate a singular data
/// structure, or this would lead to ambiguity of the data.
pub mod resolve;
#[cfg(feature = "sled")]
mod sled;
Expand Down
4 changes: 2 additions & 2 deletions ipld/blockstore/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cid::{Cid, DAG_CBOR};
use forest_ipld::Ipld;
use std::error::Error as StdError;

/// Resolves link to recursively resolved Ipld with no hash links.
/// Resolves link to recursively resolved [Ipld] with no hash links.
pub fn resolve_cids_recursive<BS>(
bs: &BS,
cid: &Cid,
Expand All @@ -22,7 +22,7 @@ where
Ok(ipld)
}

/// Resolves Ipld links recursively, building an Ipld structure with no hash links.
/// Resolves [Ipld] links recursively, building an [Ipld] structure with no hash links.
pub fn resolve_ipld<BS>(
bs: &BS,
ipld: &mut Ipld,
Expand Down
2 changes: 2 additions & 0 deletions ipld/blockstore/src/tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use db::{Error, Store};
use std::cell::RefCell;
use std::error::Error as StdError;

/// Stats for a [TrackingBlockStore] this indicates the amount of read and written data
/// to the wrapped store.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct BSStats {
/// Number of reads
Expand Down
7 changes: 7 additions & 0 deletions ipld/cid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ const MULTIBASE_IDENTITY: u8 = 0;
#[cfg(feature = "json")]
pub mod json;

/// Cbor [Cid] codec.
pub const DAG_CBOR: u64 = 0x71;
/// Sealed commitment [Cid] codec.
pub const FIL_COMMITMENT_SEALED: u64 = 0xf102;
/// Unsealed commitment [Cid] codec.
pub const FIL_COMMITMENT_UNSEALED: u64 = 0xf101;
/// Raw [Cid] codec. This represents data that is not encoded using any protocol.
pub const RAW: u64 = 0x55;

/// Constructs a cid with bytes using default version and codec
Expand All @@ -46,6 +50,9 @@ pub fn new_from_prefix(prefix: &Prefix, data: &[u8]) -> Result<Cid, Error> {
Cid::new(prefix.version, prefix.codec, hash)
}

/// Content identifier for any Ipld data. This Cid consists of a version, a codec (or serialization)
/// protocol and a multihash (hash of the Ipld data). Cids allow for hash linking, where the Cids
/// are used to resolve any arbitrary data over a network or from local storage.
#[derive(PartialEq, Eq, Clone, Copy, Default, Hash, PartialOrd, Ord)]
pub struct Cid(CidGeneric<multihash::U32>);

Expand Down
3 changes: 3 additions & 0 deletions ipld/hamt/src/hash_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl Hasher for Sha2HasherWrapper {
}
}

/// Sha256 hashing algorithm used for hashing keys in the Hamt.
#[derive(Debug)]
pub enum Sha256 {}

Expand Down Expand Up @@ -60,6 +61,8 @@ impl Hasher for IdentityHasher {
}
}

/// Identity hashing algorithm used for hashing keys in the Hamt. This should only be used
/// for testing. The hash is just the first 32 bytes of the serialized key.
#[cfg(feature = "identity")]
#[derive(Debug)]
pub enum Identity {}
Expand Down