Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from hyperledger/master
Browse files Browse the repository at this point in the history
Merging master from hyperledger
  • Loading branch information
anastasia-tarasova authored Jul 3, 2017
2 parents d086c7e + 82bc0bc commit 38031f3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sovrin-client"
version = "0.1.0"
version = "0.1.1"
authors = [
"Sergej Pupykin <sergej.pupykin@dsr-company.com>",
"Vyacheslav Gudkov <vyacheslav.gudkov@dsr-company.com>",
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Indy SDK

## Building of Indy SDK
This is the official SDK for [Hyperledger Indy](https://www.hyperledger.org/projects),
which provides a distributed-ledger-based foundation for [self-sovereign identity](https://sovrin.org).
The major artifact of the SDK is a c-callable
library; there are also convenience wrappers for various programming languages.

All bugs, stories, and backlog for this project are managed through [Hyperledger's Jira](https://jira.hyperledger.org)
in project IS (note that regular Indy tickets are in the INDY project instead...). Also, join
us on [Jira's Rocket.Chat](chat.hyperledger.org) at #indy-sdk to discuss.

## Building Indy SDK

* [Ubuntu based distro (Ubuntu 16.04)](doc/ubuntu-build.md)
* [RHEL based distro (Amazon Linux 2017.03)](doc/rhel-build.md)
* [Windows](doc/windows-build.md)
* [iOS](doc/ios-build.md)
* [MacOS](doc/mac-build.md)
* [MacOS](doc/mac-build.md)
4 changes: 2 additions & 2 deletions ci/sovrin-pool.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ RUN pip3 install -U \
pip \
setuptools

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EAA542E8
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D82D8E35
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BD33704C
RUN echo "deb https://repo.evernym.com/deb xenial master" >> /etc/apt/sources.list
RUN echo "deb https://repo.sovrin.org/deb xenial master" >> /etc/apt/sources.list

Expand Down
24 changes: 14 additions & 10 deletions src/services/ledger/merkletree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ impl MerkleTree {
pub fn consistency_proof(&self,
new_root_hash: &Vec<u8>, new_size: usize,
proof: &Vec<Vec<u8>>) -> Result<bool, CommonError> {
if self.nodes_count == 0 {
if self.count == 0 {
// empty old tree
return Ok(true);
}
if self.nodes_count == new_size && self.root_hash() == new_root_hash {
if self.count == new_size && self.root_hash() == new_root_hash {
// identical trees
return Ok(true);
}
if self.nodes_count > new_size {
if self.count > new_size {
// old tree is bigger!
assert!(false);
return Ok(false);
}

let mut old_node = self.nodes_count - 1;
let mut old_node = self.count - 1;
let mut new_node = new_size - 1;

while old_node % 2 != 0 {
Expand Down Expand Up @@ -304,7 +304,7 @@ mod tests {
0x51, 0x28, 0xc5, 0x8f, 0x59, 0x1f, 0x4f, 0x03,
0x25, 0x81, 0xfe, 0xe7, 0xd8, 0x61, 0x99, 0xae,
0xf8, 0xae, 0xac, 0x7b, 0x05, 0x80, 0xbe, 0x0a ],
2,
4,
&proofs).unwrap());
}

Expand Down Expand Up @@ -344,7 +344,6 @@ mod tests {
}

#[test]
#[ignore] /* FIXME it's blocker for checking cons proofs in CatchUp */
fn consistency_proof_works_for_old4_new8() {
let all_str_values = vec![
r#"{"data":{"alias":"Node1","client_ip":"10.0.0.2","client_port":9702,"node_ip":"10.0.0.2","node_port":9701,"services":["VALIDATOR"]},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv","identifier":"FYmoFw55GeQH7SRFa37dkx1d2dZ3zUF8ckg7wmL7ofN4","txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62","type":"0"}"#,
Expand All @@ -370,19 +369,21 @@ mod tests {
"BhXMcoxZ9eu3Cu85bzr4G4Msrw77BT3R6Mw6P6bM9wQe"
];
let proofs_for_5: Vec<Vec<u8>> = proofs_for_5.into_iter().map(|x| x.from_base58().unwrap()).collect();
assert!(mt.consistency_proof(&full_root_hash, 7, &proofs_for_5).unwrap());
//add 5th node
mt.append(all_values[5 - 1].clone()).unwrap();
assert!(mt.consistency_proof(&full_root_hash, 8, &proofs_for_5).unwrap());

//try to add 6th node
let proofs_for_6: Vec<&str> = vec![
"HhkWitSAXG12Ugn4KFtrUyhbZHi9XrP4jnbLuSthynSu",
"BqHByHYX9gAHye1SoKKiLXLFB7TDntyUoMtZQjMW2w7U",
"BhXMcoxZ9eu3Cu85bzr4G4Msrw77BT3R6Mw6P6bM9wQe"
];
let proofs_for_6: Vec<Vec<u8>> = proofs_for_6.into_iter().map(|x| x.from_base58().unwrap()).collect();
assert!(mt.consistency_proof(&full_root_hash, 7, &proofs_for_6).unwrap());
//add 6th node
mt.append(all_values[6 - 1].clone()).unwrap();
assert!(mt.consistency_proof(&full_root_hash, 8, &proofs_for_6).unwrap());

//try to add 7th node
let proofs_for_7: Vec<&str> = vec![
"2D1aU5DeP8uPmaisGSpNoF2tNS35YhaRvfk2KPZzY2ue",
Expand All @@ -391,11 +392,14 @@ mod tests {
"BhXMcoxZ9eu3Cu85bzr4G4Msrw77BT3R6Mw6P6bM9wQe"
];
let proofs_for_7: Vec<Vec<u8>> = proofs_for_7.into_iter().map(|x| x.from_base58().unwrap()).collect();
assert!(mt.consistency_proof(&full_root_hash, 7, &proofs_for_7).unwrap());
//add 7th node
mt.append(all_values[7 - 1].clone()).unwrap();
assert!(mt.consistency_proof(&full_root_hash, 8, &proofs_for_7).unwrap());

//try to add 8th node, empty proof
let proofs_for_8: Vec<Vec<u8>> = Vec::new();
assert!(mt.consistency_proof(&full_root_hash, 7, &proofs_for_8).unwrap());
//add 7th node
mt.append(all_values[8 - 1].clone()).unwrap();
assert!(mt.consistency_proof(&full_root_hash, 8, &proofs_for_8).unwrap());
}
}
2 changes: 2 additions & 0 deletions src/services/pool/catchup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ impl CatchupHandler {
txnSeqNo: self.nodes.len(),
merkleRoot: self.merkle_tree.root_hash().as_slice().to_base58(),
ledgerId: 0,
ppSeqNo: None,
viewNo: None,
};
let resp_msg: Message = Message::LedgerStatus(ls);
self.nodes[src_ind].send_msg(&resp_msg)?;
Expand Down
2 changes: 2 additions & 0 deletions src/services/pool/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub struct LedgerStatus {
pub txnSeqNo: usize,
pub merkleRoot: String,
pub ledgerId: u8,
pub ppSeqNo: Option<String>,
pub viewNo: Option<String>,
}

#[allow(non_snake_case)]
Expand Down

0 comments on commit 38031f3

Please sign in to comment.