File tree Expand file tree Collapse file tree 5 files changed +12
-8
lines changed Expand file tree Collapse file tree 5 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ impl Scheme {
249
249
}
250
250
251
251
pub fn check_genesis_root ( & self , db : & HashDB ) -> bool {
252
- if db. keys ( ) . is_empty ( ) {
252
+ if db. is_empty ( ) {
253
253
return true
254
254
}
255
255
db. contains ( & self . state_root ( ) )
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ pub trait HashDB: AsHashDB + Send + Sync {
48
48
/// Remove a datum previously inserted. Insertions can be "owed" such that the same number of `insert()`s may
49
49
/// happen without the data being eventually being inserted into the DB. It can be "owed" more than once.
50
50
fn remove ( & mut self , key : & H256 ) ;
51
+
52
+ /// check if the db has no commits
53
+ fn is_empty ( & self ) -> bool ;
51
54
}
52
55
53
56
/// Upcast trait.
Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ impl HashDB for ArchiveDB {
102
102
fn remove ( & mut self , key : & H256 ) {
103
103
self . overlay . remove ( key) ;
104
104
}
105
+
106
+ fn is_empty ( & self ) -> bool {
107
+ self . latest_era . is_none ( )
108
+ }
105
109
}
106
110
107
111
impl JournalDB for ArchiveDB {
@@ -114,10 +118,6 @@ impl JournalDB for ArchiveDB {
114
118
} )
115
119
}
116
120
117
- fn is_empty ( & self ) -> bool {
118
- self . latest_era . is_none ( )
119
- }
120
-
121
121
fn latest_era ( & self ) -> Option < u64 > {
122
122
self . latest_era
123
123
}
Original file line number Diff line number Diff line change @@ -35,9 +35,6 @@ pub trait JournalDB: HashDB {
35
35
0
36
36
}
37
37
38
- /// Check if this database has any commits
39
- fn is_empty ( & self ) -> bool ;
40
-
41
38
/// Get the earliest era in the DB. None if there isn't yet any data in there.
42
39
fn earliest_era ( & self ) -> Option < u64 > {
43
40
None
Original file line number Diff line number Diff line change @@ -262,6 +262,10 @@ impl HashDB for MemoryDB {
262
262
}
263
263
}
264
264
}
265
+
266
+ fn is_empty ( & self ) -> bool {
267
+ self . data . is_empty ( )
268
+ }
265
269
}
266
270
267
271
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments