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

SignedHeader should contain commit #42

Merged
merged 5 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions tendermint/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod parts;
mod size;

pub use self::{
commit::LastCommit,
commit::Commit,
header::Header,
height::*,
id::{Id, ParseId},
Expand All @@ -35,5 +35,5 @@ pub struct Block {
pub evidence: evidence::Data,

/// Last commit
pub last_commit: LastCommit,
pub last_commit: Commit,
}
5 changes: 3 additions & 2 deletions tendermint/src/block/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use crate::{block, Vote};
use serde::{Deserialize, Serialize};
use std::{ops::Deref, slice};

/// Last commit to a particular blockchain: +2/3 precommit signatures.
/// Commit contains the justification (ie. a set of signatures) that a block was committed by a set of validators.
///
/// <https://github.com/tendermint/tendermint/blob/51dc810d041eaac78320adc6d53ad8b160b06601/types/block.go#L486-L502>
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#lastcommit>
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct LastCommit {
pub struct Commit {
/// Block ID of the last commit
pub block_id: block::Id,

Expand Down
11 changes: 2 additions & 9 deletions tendermint/src/rpc/endpoint/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use crate::{block, rpc};
use serde::{Deserialize, Serialize};
use std::ops::Deref;

/// Get commit information about a specific block
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
Expand Down Expand Up @@ -44,12 +43,6 @@ impl rpc::Response for Response {}
pub struct SignedHeader {
/// Block header
pub header: block::Header,
}

impl Deref for SignedHeader {
type Target = block::Header;

fn deref(&self) -> &block::Header {
&self.header
}
/// Commit containing signatures for the header
pub commit: block::Commit,
}
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions tests/rpc.rs → tendermint/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ mod endpoints {
let response = endpoint::commit::Response::from_json(&read_json_fixture("commit")).unwrap();
let header = response.signed_header.header;
assert_eq!(header.chain_id.as_ref(), EXAMPLE_CHAIN);
// For now we just want to make sure the commit including precommits and a block_id exist
// in SignedHeader; later we should verify some properties: e.g. block_id.hash matches the
// header etc:
let commit = response.signed_header.commit;
let _block_id = commit.block_id;
let _precommits = commit.precommits;
}

#[test]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.