- fn connect_block(&mut self, txn: &[&Transaction], txn_idxs: &[u32]) {
- let header = BlockHeader { version: 0x20000000, prev_blockhash: self.header_hashes[self.height], merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+ fn connect_block(&mut self, all_txn: &[Transaction]) {
+ let mut txn = Vec::with_capacity(all_txn.len());
+ let mut txn_idxs = Vec::with_capacity(all_txn.len());
+ for (idx, tx) in all_txn.iter().enumerate() {
+ let txid = Sha256dHash::from_data(&serialize(tx).unwrap()[..]);
+ match self.txids_confirmed.entry(txid) {
+ hash_map::Entry::Vacant(e) => {
+ e.insert(self.height);
+ txn.push(tx);
+ txn_idxs.push(idx as u32 + 1);
+ },
+ _ => {},
+ }
+ }
+
+ let header = BlockHeader { version: 0x20000000, prev_blockhash: self.header_hashes[self.height], merkle_root: Default::default(), time: self.blocks_connected, bits: 42, nonce: 42 };