AcctIdx: generate index inserts/updates directly to disk (#21363)

* when initially creating account index, write directly to disk

* AcctIdx: generate index inserts/updates directly to disk
This commit is contained in:
Jeff Washington (jwash)
2021-11-19 17:17:07 -06:00
committed by GitHub
parent 0bb059185c
commit ebea3297f9
5 changed files with 72 additions and 47 deletions

View File

@ -482,9 +482,9 @@ impl<T: Clone + Copy> Bucket<T> {
}
}
pub fn update<F>(&mut self, key: &Pubkey, updatefn: F)
pub fn update<F>(&mut self, key: &Pubkey, mut updatefn: F)
where
F: Fn(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,
F: FnMut(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,
{
let current = self.read_value(key);
let new = updatefn(current);

View File

@ -128,7 +128,7 @@ impl<T: Clone + Copy> BucketApi<T> {
pub fn update<F>(&self, key: &Pubkey, updatefn: F)
where
F: Fn(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,
F: FnMut(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,
{
let mut bucket = self.get_write_bucket();
bucket.as_mut().unwrap().update(key, updatefn)

View File

@ -148,7 +148,7 @@ impl<T: Clone + Copy + Debug> BucketMap<T> {
/// Update Pubkey `key`'s value with function `updatefn`
pub fn update<F>(&self, key: &Pubkey, updatefn: F)
where
F: Fn(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,
F: FnMut(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,
{
self.get_bucket(key).update(key, updatefn)
}