Skip to content

Commit

Permalink
Merge eef02e1 into 6c76bd3
Browse files Browse the repository at this point in the history
  • Loading branch information
bochaco committed Nov 2, 2021
2 parents 6c76bd3 + eef02e1 commit 42fd10f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/block.rs
Expand Up @@ -10,14 +10,14 @@ use serde::{Deserialize, Serialize};
use std::cmp::Ordering;

#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub(crate) struct Block {
pub(crate) key: bls::PublicKey,
pub(crate) signature: bls::Signature,
pub(crate) parent_index: usize,
pub struct Block {
pub key: bls::PublicKey,
pub signature: bls::Signature,
pub parent_index: usize,
}

impl Block {
pub(crate) fn verify(&self, parent_key: &bls::PublicKey) -> bool {
pub fn verify(&self, parent_key: &bls::PublicKey) -> bool {
bincode::serialize(&self.key)
.map(|bytes| parent_key.verify(&self.signature, &bytes))
.unwrap_or(false)
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Expand Up @@ -262,6 +262,11 @@ impl SecuredLinkedList {
.unwrap_or(&self.root)
}

/// Returns the last block found in this chain.
pub fn last_block(&self) -> Option<&Block> {
self.tree.last()
}

/// Returns the parent key of the last key or the root key if this chain has only one key.
pub fn prev_key(&self) -> &bls::PublicKey {
self.branch(self.tree.len())
Expand Down

0 comments on commit 42fd10f

Please sign in to comment.