(&self)
| 82 | } |
| 83 | |
| 84 | pub fn reindex(&self) { |
| 85 | let db = self.blockchain.get_db(); |
| 86 | let utxo_tree = db.open_tree(UTXO_TREE).unwrap(); |
| 87 | let _ = utxo_tree.clear().unwrap(); |
| 88 | |
| 89 | let utxo_map = self.blockchain.find_utxo(); |
| 90 | for (txid_hex, outs) in &utxo_map { |
| 91 | let txid = HEXLOWER.decode(txid_hex.as_bytes()).unwrap(); |
| 92 | let value = bincode::serialize(outs).unwrap(); |
| 93 | let _ = utxo_tree.insert(txid.as_slice(), value).unwrap(); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | |
| 98 | pub fn update(&self, block: &Block) { |