-
Notifications
You must be signed in to change notification settings - Fork 1.7k
new blooms database #8712
new blooms database #8712
Changes from 3 commits
343b298
b9ac847
2eb233b
f55ee49
94dfcd4
88aa4ff
0da3c9b
0fb7b95
c8b30a4
975fdcb
24a6ba2
c321556
7fa05cd
979ed33
77f0af8
6367cea
6a806a1
65f9f91
ffd5a2a
1781d4a
646957a
fd06dca
bac4638
db2740e
50aa947
8f130b5
7edca53
7e48afd
914aec5
dc2e02a
3bc7a8c
bfc744b
41e5eb1
fdc943a
249c368
f82f599
1cc78f6
59f0fd3
447950e
9894a16
f37f5e7
26c45cd
28ad097
f1ead7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ use snapshot::io::{SnapshotReader, PackedWriter, PackedReader}; | |
use tempdir::TempDir; | ||
use rand::Rng; | ||
|
||
use kvdb::{KeyValueDB, DBValue}; | ||
use kvdb::{DBValue}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blocks around a single import |
||
use ethereum_types::H256; | ||
use hashdb::HashDB; | ||
use journaldb; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
|
||
//! PoW block chunker and rebuilder tests. | ||
|
||
use std::sync::Arc; | ||
use std::sync::atomic::AtomicBool; | ||
use tempdir::TempDir; | ||
use error::{Error, ErrorKind}; | ||
|
@@ -28,8 +27,7 @@ use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}; | |
|
||
use parking_lot::Mutex; | ||
use snappy; | ||
use kvdb::{KeyValueDB, DBTransaction}; | ||
use kvdb_memorydb; | ||
use kvdb::{DBTransaction}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blocks around a single import |
||
use test_helpers; | ||
|
||
const SNAPSHOT_MODE: ::snapshot::PowSnapshot = ::snapshot::PowSnapshot { blocks: 30000, max_restore_blocks: 30000 }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,11 @@ use ids::BlockId; | |
use snapshot::service::{Service, ServiceParams}; | ||
use snapshot::{self, ManifestData, SnapshotService}; | ||
use spec::Spec; | ||
use test_helpers::{self, generate_dummy_client_with_spec_and_data}; | ||
use test_helpers::{generate_dummy_client_with_spec_and_data}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blocks around a single import |
||
use test_helpers_internal::restoration_db_handler; | ||
|
||
use io::IoChannel; | ||
use kvdb_rocksdb::{Database, DatabaseConfig}; | ||
use kvdb_rocksdb::{DatabaseConfig}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blocks around a single import |
||
|
||
struct NoopDBRestore; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
use std::path::Path; | ||
use std::sync::Arc; | ||
use parking_lot::RwLock; | ||
use kvdb::{KeyValueDB, KeyValueDBHandler}; | ||
use kvdb::{KeyValueDB}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blocks around a single import |
||
use kvdb_rocksdb::{Database, DatabaseConfig}; | ||
use blockchain::{BlockChainDBHandler, BlockChainDB}; | ||
use blooms_db; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,12 @@ | |
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Trace database. | ||
use std::ops::Deref; | ||
use std::collections::{HashMap, VecDeque}; | ||
use std::collections::{HashMap, BTreeSet, VecDeque}; | ||
use std::sync::Arc; | ||
use blockchain::{BlockChainDB}; | ||
use heapsize::HeapSizeOf; | ||
use ethereum_types::{H256, H264}; | ||
use kvdb::{KeyValueDB, DBTransaction}; | ||
use kvdb::{DBTransaction}; | ||
use parking_lot::RwLock; | ||
use header::BlockNumber; | ||
use trace::{LocalizedTrace, Config, Filter, Database as TraceDatabase, ImportRequest, DatabaseExtras}; | ||
|
@@ -83,7 +82,6 @@ impl<T> TraceDB<T> where T: DatabaseExtras { | |
|
||
TraceDB { | ||
traces: RwLock::new(HashMap::new()), | ||
//blooms: RwLock::new(HashMap::new()), | ||
cache_manager: RwLock::new(CacheManager::new(config.pref_cache_size, config.max_cache_size, 10 * 1024)), | ||
tracesdb: tracesdb, | ||
enabled: config.enabled, | ||
|
@@ -93,8 +91,6 @@ impl<T> TraceDB<T> where T: DatabaseExtras { | |
|
||
fn cache_size(&self) -> usize { | ||
self.traces.read().heap_size_of_children() | ||
//let blooms = self.blooms.read().heap_size_of_children(); | ||
//traces + blooms | ||
} | ||
|
||
/// Let the cache system know that a cacheable item has been used. | ||
|
@@ -108,18 +104,15 @@ impl<T> TraceDB<T> where T: DatabaseExtras { | |
let current_size = self.cache_size(); | ||
|
||
let mut traces = self.traces.write(); | ||
//let mut blooms = self.blooms.write(); | ||
let mut cache_manager = self.cache_manager.write(); | ||
|
||
cache_manager.collect_garbage(current_size, | ids | { | ||
for id in &ids { | ||
match *id { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
CacheId::Trace(ref h) => { traces.remove(h); }, | ||
//CacheId::Bloom(ref h) => { blooms.remove(h); }, | ||
} | ||
} | ||
traces.shrink_to_fit(); | ||
//blooms.shrink_to_fit(); | ||
|
||
traces.heap_size_of_children() | ||
}); | ||
|
@@ -211,8 +204,6 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras { | |
// now let's rebuild the blooms | ||
if !request.enacted.is_empty() { | ||
let range_start = request.block_number + 1 - request.enacted.len() as u64; | ||
//let range_end = range_start + request.retracted; | ||
//let replaced_range = range_start..range_end; | ||
let enacted_blooms: Vec<_> = request.enacted | ||
.iter() | ||
// all traces are expected to be found here. That's why `expect` has been used | ||
|
@@ -324,19 +315,25 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras { | |
} | ||
|
||
fn filter(&self, filter: &Filter) -> Vec<LocalizedTrace> { | ||
unimplemented!(); | ||
//let chain = BloomGroupChain::new(self.bloom_config, self); | ||
//let numbers = chain.filter(filter); | ||
//numbers.into_iter() | ||
//.flat_map(|n| { | ||
//let number = n as BlockNumber; | ||
//let hash = self.extras.block_hash(number) | ||
//.expect("Expected to find block hash. Extras db is probably corrupted"); | ||
//let traces = self.traces(&hash) | ||
//.expect("Expected to find a trace. Db is probably corrupted."); | ||
//self.matching_block_traces(filter, traces, hash, number) | ||
//}) | ||
//.collect() | ||
let possibilities = filter.bloom_possibilities(); | ||
let blooms_db = self.tracesdb.blooms().read(); | ||
let numbers = possibilities.iter() | ||
.map(|bloom| blooms_db.iterate_matching(filter.range.start as u64, filter.range.end as u64, bloom)?.collect::<Result<Vec<_>, _>>()) | ||
.collect::<Result<Vec<_>, _>>().expect("TODO: blooms pr") | ||
.into_iter() | ||
.flat_map(|n| n) | ||
.collect::<BTreeSet<_>>(); | ||
|
||
numbers.into_iter() | ||
.flat_map(|n| { | ||
let number = n as BlockNumber; | ||
let hash = self.extras.block_hash(number) | ||
.expect("Expected to find block hash. Extras db is probably corrupted"); | ||
let traces = self.traces(&hash) | ||
.expect("Expected to find a trace. Db is probably corrupted."); | ||
self.matching_block_traces(filter, traces, hash, number) | ||
}) | ||
.collect() | ||
} | ||
} | ||
|
||
|
@@ -345,8 +342,7 @@ mod tests { | |
use std::collections::HashMap; | ||
use std::sync::Arc; | ||
use ethereum_types::{H256, U256, Address}; | ||
use kvdb::{DBTransaction, KeyValueDB}; | ||
use kvdb_memorydb; | ||
use kvdb::{DBTransaction}; | ||
use header::BlockNumber; | ||
use trace::{Config, TraceDB, Database as TraceDatabase, DatabaseExtras, ImportRequest}; | ||
use trace::{Filter, LocalizedTrace, AddressesFilter, TraceError}; | ||
|
@@ -542,6 +538,7 @@ mod tests { | |
let mut batch = DBTransaction::new(); | ||
tracedb.import(&mut batch, request); | ||
db.key_value().write(batch).unwrap(); | ||
db.blooms().write().flush().unwrap(); | ||
|
||
let filter = Filter { | ||
range: (1..1), | ||
|
@@ -558,6 +555,7 @@ mod tests { | |
let mut batch = DBTransaction::new(); | ||
tracedb.import(&mut batch, request); | ||
db.key_value().write(batch).unwrap(); | ||
db.blooms().write().flush().unwrap(); | ||
|
||
let filter = Filter { | ||
range: (1..2), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blocks around a single
import