Przeglądaj źródła

consensus/state: Create merkle tree of transactions in blocks.

parazyd 3 lat temu
rodzic
commit
064c03cbf7
1 zmienionych plików z 6 dodań i 7 usunięć
  1. 6 7
      src/consensus/state.rs

+ 6 - 7
src/consensus/state.rs

@@ -676,15 +676,14 @@ impl ValidatorState {
 
         // TODO: [PLACEHOLDER] Create and add rewards transaction
 
-        let tree = BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(100);
-        /* TODO: FIXME: TESTNET:
+        let mut tree = BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(100);
+        // The following is pretty weird, so something better should be done.
         for tx in &unproposed_txs {
-            for output in &tx.outputs {
-                tree.append(&MerkleNode::from(output.revealed.coin.0));
-                tree.witness();
-            }
+            let mut hash = [0_u8; 32];
+            hash[0..31].copy_from_slice(&blake3::hash(&serialize(tx)).as_bytes()[0..31]);
+            tree.append(&MerkleNode::from(pallas::Base::from_repr(hash).unwrap()));
         }
-        */
+
         let root = tree.root(0).unwrap();
 
         let eta = self.consensus.epoch_eta;