MCPcopy Create free account
hub / github.com/PacktPublishing/Rust-for-Blockchain-Application-Development / reindex

Method reindex

chapter 5/utxoSet.rs:84–95  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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) {

Callers 2

serveFunction · 0.45
mainFunction · 0.45

Calls 3

get_dbMethod · 0.45
clearMethod · 0.45
find_utxoMethod · 0.45

Tested by

no test coverage detected