Add slot_history for slashing (#7589)

* Add slot_history for slashing

* fixup

* fixup
This commit is contained in:
Rob Walker
2019-12-23 12:23:45 -08:00
committed by GitHub
parent 352a367570
commit 120c8f244c
15 changed files with 209 additions and 53 deletions

View File

@ -3,7 +3,7 @@
extern crate test;
use solana_sdk::{
hash::Hash,
slot_hashes::{Slot, SlotHashes, MAX_SLOT_HASHES},
slot_hashes::{Slot, SlotHashes, MAX_ENTRIES},
sysvar::Sysvar,
};
use test::Bencher;
@ -11,12 +11,10 @@ use test::Bencher;
#[bench]
fn bench_to_from_account(b: &mut Bencher) {
let mut slot_hashes = SlotHashes::new(&[]);
for i in 0..MAX_SLOT_HASHES {
for i in 0..MAX_ENTRIES {
slot_hashes.add(i as Slot, Hash::default());
}
let mut reps = 0;
b.iter(|| {
reps += 1;
let account = slot_hashes.create_account(0);
slot_hashes = SlotHashes::from_account(&account).unwrap();
});

View File

@ -0,0 +1,15 @@
#![feature(test)]
extern crate test;
use solana_sdk::{slot_history::SlotHistory, sysvar::Sysvar};
use test::Bencher;
#[bench]
fn bench_to_from_account(b: &mut Bencher) {
let mut slot_history = SlotHistory::default();
b.iter(|| {
let account = slot_history.create_account(0);
slot_history = SlotHistory::from_account(&account).unwrap();
});
}