pub struct Commit {
pub did: String,
pub version: i64,
pub data: Cid,
pub rev: String,
pub prev: Option<Cid>,
}Expand description
A commit before it is signed.
The field names are the protocol’s, and every one of them is signed: a
reader that trusted did from anywhere but inside the signature would
accept one account’s commit as another’s.
Fields§
§did: StringThe repository this is a commit for.
version: i64The repository format. Always REPO_VERSION here.
data: CidThe root of the Merkle search tree over every record.
rev: StringA TID that increases with every commit to this repository.
It is what lets a consumer order two commits it received out of order,
and what a since cursor is compared against. It is a string here
rather than a parsed TID because this crate does not mint one — the
caller does, out of the same clock its record keys come from.
prev: Option<Cid>The commit this one replaces, or None for the first.
Implementations§
Source§impl Commit
impl Commit
Sourcepub fn to_sign(&self) -> Vec<u8> ⓘ
pub fn to_sign(&self) -> Vec<u8> ⓘ
The bytes a signature is made over: every field except sig.
A signature over the signed commit would be a signature over itself,
so the field is absent rather than null or empty. That means the block
that is hashed for the CID and the block that is signed are two
different encodings of the same commit, which is the one thing about
this format that reliably surprises people, and why it is a named
method rather than a step inside sign.
Sourcepub fn sign(self, key: &SigningKey) -> SignedCommit
pub fn sign(self, key: &SigningKey) -> SignedCommit
Signs the commit.
The signature is deterministic — k256 uses RFC 6979 nonces — so the
same repository state signed by the same key twice gives the same
bytes and the same commit CID. That is what makes an export
reproducible, and it is a property of the key crate rather than of
anything decided here.
Trait Implementations§
impl Eq for Commit
impl StructuralPartialEq for Commit
Auto Trait Implementations§
impl Freeze for Commit
impl RefUnwindSafe for Commit
impl Send for Commit
impl Sync for Commit
impl Unpin for Commit
impl UnsafeUnpin for Commit
impl UnwindSafe for Commit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.