Skip to content

Commit

Permalink
Fix bug when we read data that does not exists but try to count anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Tricaud committed Apr 16, 2020
1 parent a7f3f21 commit cfd3b16
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/daemon/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,20 @@ impl Database {
};
}
pub fn get_count(&mut self, path: &str, value: &str) -> u128 {
let valuestable = self.hashtable.get_mut(&path.to_string()).unwrap();
let attr = valuestable.get_mut(&value.to_string());
match attr {
Some(attr) => { return attr.count(); },
let valuestable = self.hashtable.get_mut(&path.to_string());
match valuestable {
Some(valuestable) => {
let attr = valuestable.get_mut(&value.to_string());
match attr {
Some(attr) => { return attr.count(); },
None => {
return 0;
},
};
},
None => {
return 0;
},
},
};
}
pub fn get_attr(&mut self, path: &str, value: &str, with_stats: bool, consensus_count: u128) -> String {
Expand Down

0 comments on commit cfd3b16

Please sign in to comment.