Browse Source

Remove unneeded `mut` from `Store`

refactor-mempool
Roman Zeyde 7 years ago
parent
commit
a84d677a20
No known key found for this signature in database GPG Key ID: 87CAE5FA46917CBB
  1. 2
      src/index.rs
  2. 8
      src/store.rs

2
src/index.rs

@ -75,7 +75,7 @@ fn index_block(block: &Block, height: usize) -> Vec<Row> {
rows
}
fn get_missing_hashes(store: &mut Store, daemon: &Daemon) -> Vec<(usize, String)> {
fn get_missing_hashes(store: &Store, daemon: &Daemon) -> Vec<(usize, String)> {
let indexed_headers = store.read_headers();
let mut hashes: Vec<(usize, String)> = daemon.enumerate_headers();
info!(

8
src/store.rs

@ -76,7 +76,7 @@ impl Store {
self.start = PreciseTime::now();
}
pub fn read_headers(&mut self) -> HashMap<String, BlockHeader> {
pub fn read_headers(&self) -> HashMap<String, BlockHeader> {
let mut headers = HashMap::new();
for row in self.scan(b"B") {
let blockhash = revhex(&row.key);
@ -86,12 +86,12 @@ impl Store {
headers
}
pub fn has_block(&mut self, blockhash: &[u8]) -> bool {
pub fn has_block(&self, blockhash: &[u8]) -> bool {
let key: &[u8] = &[b"B", blockhash].concat();
self.db.get(key).unwrap().is_some()
}
pub fn compact_if_needed(&mut self) {
pub fn compact_if_needed(&self) {
let key = b"F"; // full compaction
if self.db.get(key).unwrap().is_some() {
return;
@ -102,7 +102,7 @@ impl Store {
}
// Use generators ???
fn scan(&mut self, prefix: &[u8]) -> Vec<Row> {
fn scan(&self, prefix: &[u8]) -> Vec<Row> {
let mut rows = Vec::new();
let mut iter = self.db.raw_iterator();
let prefix_len = prefix.len();

Loading…
Cancel
Save