From caed6995643ed850ad7fe9dccef3cb1f11114b1e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 27 Sep 2018 20:35:34 +0200 Subject: [PATCH] Support non-AVVM balances --- cardano/src/block/verify_chain.rs | 9 ++++++++- cardano/src/config.rs | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cardano/src/block/verify_chain.rs b/cardano/src/block/verify_chain.rs index 53c4fd814..86f491b1c 100644 --- a/cardano/src/block/verify_chain.rs +++ b/cardano/src/block/verify_chain.rs @@ -6,6 +6,7 @@ use coin; use tx::{self, TxAux, TxoPointer, TxOut, TxInWitness}; use std::collections::BTreeMap; use fee::{self, FeeAlgorithm}; +use hash; pub struct ChainState { // FIXME: maybe we should just keep a ref to GenesisData? Though @@ -38,7 +39,13 @@ impl ChainState { TxOut { address, value: value.clone() }); } - // FIXME: implement non_avvm_balances. + // Create utxos from non-AVVM balances. + for (address, value) in &genesis_data.non_avvm_balances { + let id = hash::Blake2b256::new(&cbor!(&address).unwrap()); + utxos.insert( + TxoPointer { id, index: 0 }, + TxOut { address: address.clone(), value: value.clone() }); + } ChainState { protocol_magic: genesis_data.protocol_magic, diff --git a/cardano/src/config.rs b/cardano/src/config.rs index 0ad81efdb..4674237f4 100644 --- a/cardano/src/config.rs +++ b/cardano/src/config.rs @@ -10,6 +10,7 @@ use block; use fee; use coin; use redeem; +use address; use std::collections::BTreeMap; /// this is the protocol magic number @@ -108,5 +109,5 @@ pub struct GenesisData { pub protocol_magic: ProtocolMagic, pub fee_policy: fee::LinearFee, pub avvm_distr: BTreeMap, // AVVM = Ada Voucher Vending Machine - pub non_avvm_balances: BTreeMap, + pub non_avvm_balances: BTreeMap, }