Skip to content
Permalink
Browse files

Merge pull request #521 from input-output-hk/state

Track State in a simple way forward
  • Loading branch information...
NicolasDP committed Mar 15, 2019
2 parents 9aa89b3 + e23c54c commit e393f0b068540b6ea7a0fff6a44a6f3e8502df50
Showing with 2,072 additions and 1,214 deletions.
  1. +0 −20 cardano/src/block/block.rs
  2. +0 −8 cardano/src/tx.rs
  3. +4 −4 chain-addr/src/lib.rs
  4. +92 −193 chain-core/src/property.rs
  5. +5 −5 chain-crypto/src/algorithms/fakemmm.rs
  6. +1 −0 chain-impl-mockchain/Cargo.toml
  7. +178 −0 chain-impl-mockchain/FORMAT.md
  8. +30 −4 chain-impl-mockchain/src/account.rs
  9. +2 −1 chain-impl-mockchain/src/block/builder.rs
  10. +11 −8 chain-impl-mockchain/src/block/header.rs
  11. +3 −2 chain-impl-mockchain/src/block/message.rs
  12. +16 −24 chain-impl-mockchain/src/block/mod.rs
  13. +28 −9 chain-impl-mockchain/src/certificate.rs
  14. +11 −10 chain-impl-mockchain/src/environment.rs
  15. +6 −5 chain-impl-mockchain/src/error.rs
  16. +3 −0 chain-impl-mockchain/src/key.rs
  17. +18 −116 chain-impl-mockchain/src/leadership/bft.rs
  18. +319 −213 chain-impl-mockchain/src/leadership/genesis.rs
  19. +88 −18 chain-impl-mockchain/src/leadership/mod.rs
  20. +51 −0 chain-impl-mockchain/src/leadership/none.rs
  21. +179 −95 chain-impl-mockchain/src/ledger.rs
  22. +5 −16 chain-impl-mockchain/src/lib.rs
  23. +51 −0 chain-impl-mockchain/src/multiverse.rs
  24. +1 −65 chain-impl-mockchain/src/setting.rs
  25. +21 −17 chain-impl-mockchain/src/stake.rs
  26. +65 −0 chain-impl-mockchain/src/state.rs
  27. +0 −372 chain-impl-mockchain/src/transaction.rs
  28. +212 −0 chain-impl-mockchain/src/transaction/mod.rs
  29. +71 −0 chain-impl-mockchain/src/transaction/transaction.rs
  30. +109 −0 chain-impl-mockchain/src/transaction/transfer.rs
  31. +32 −0 chain-impl-mockchain/src/transaction/utxo.rs
  32. +148 −0 chain-impl-mockchain/src/transaction/witness.rs
  33. +4 −3 chain-impl-mockchain/src/update.rs
  34. +185 −0 chain-impl-mockchain/src/utxo.rs
  35. +7 −0 chain-impl-mockchain/src/value.rs
  36. +46 −0 imhamt/src/content.rs
  37. +19 −3 imhamt/src/hamt.rs
  38. +16 −3 imhamt/src/lib.rs
  39. +30 −0 imhamt/src/node/reference.rs
  40. +5 −0 imhamt/src/operation.rs
@@ -376,26 +376,6 @@ impl chain_core::property::Deserialize for Block {
}
}

impl chain_core::property::HasTransaction for Block {
type Transaction = TxAux;
fn transactions<'a>(&'a self) -> Box<Iterator<Item = &Self::Transaction> + 'a> {
match self {
Block::BoundaryBlock(_) => Box::new([].iter()),
Block::MainBlock(blk) => Box::new(blk.body.tx.iter()),
}
}

fn for_each_transaction<F>(&self, f: F)
where
F: FnMut(&Self::Transaction),
{
match self {
Block::BoundaryBlock(_) => {}
Block::MainBlock(blk) => blk.body.tx.iter().for_each(f),
}
}
}

// **************************************************************************
// CBOR implementations
// **************************************************************************
@@ -685,7 +685,6 @@ impl chain_core::property::Deserialize for TxAux {
}

impl chain_core::property::Transaction for Tx {
type Id = TxId;
type Input = TxoPointer;
type Output = TxOut;
type Inputs = [TxoPointer];
@@ -697,12 +696,8 @@ impl chain_core::property::Transaction for Tx {
fn outputs(&self) -> &Self::Outputs {
&self.outputs
}
fn id(&self) -> Self::Id {
Tx::id(self)
}
}
impl chain_core::property::Transaction for TxAux {
type Id = TxId;
type Input = TxoPointer;
type Output = TxOut;
type Inputs = [TxoPointer];
@@ -714,9 +709,6 @@ impl chain_core::property::Transaction for TxAux {
fn outputs(&self) -> &Self::Outputs {
&self.tx.outputs
}
fn id(&self) -> Self::Id {
self.tx.id()
}
}

#[cfg(test)]
@@ -25,7 +25,7 @@
use bech32::{Bech32, FromBase32, ToBase32};
use std::string::ToString;

use chain_crypto::{Ed25519, Ed25519Extended, PublicKey, PublicKeyError};
use chain_crypto::{Ed25519Extended, PublicKey, PublicKeyError};

use chain_core::property::{self, Serialize as PropertySerialize};

@@ -52,7 +52,7 @@ pub enum Discrimination {
pub enum Kind {
Single(PublicKey<Ed25519Extended>),
Group(PublicKey<Ed25519Extended>, PublicKey<Ed25519Extended>),
Account(PublicKey<Ed25519>),
Account(PublicKey<Ed25519Extended>),
}

/// Kind Type of an address
@@ -418,7 +418,7 @@ pub mod testing {
use super::*;
use quickcheck::{Arbitrary, Gen};

fn arbitrary_public_key<G: Gen>(g: &mut G) -> PublicKey<Ed25519> {
fn arbitrary_public_key<G: Gen>(g: &mut G) -> PublicKey<Ed25519Extended> {
let mut bytes = [0; 32];
for byte in bytes.iter_mut() {
*byte = u8::arbitrary(g);
@@ -506,7 +506,7 @@ mod test {
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
])
.unwrap();
let fake_accountkey: PublicKey<Ed25519> = PublicKey::from_binary(&[
let fake_accountkey: PublicKey<Ed25519Extended> = PublicKey::from_binary(&[
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
])
Oops, something went wrong.

0 comments on commit e393f0b

Please sign in to comment.
You can’t perform that action at this time.