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 {
249249 }
250250
251251 pub fn check_genesis_root ( & self , db : & HashDB ) -> bool {
252- if db. keys ( ) . is_empty ( ) {
252+ if db. is_empty ( ) {
253253 return true
254254 }
255255 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 {
4848 /// Remove a datum previously inserted. Insertions can be "owed" such that the same number of `insert()`s may
4949 /// happen without the data being eventually being inserted into the DB. It can be "owed" more than once.
5050 fn remove ( & mut self , key : & H256 ) ;
51+
52+ /// check if the db has no commits
53+ fn is_empty ( & self ) -> bool ;
5154}
5255
5356/// Upcast trait.
Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ impl HashDB for ArchiveDB {
102102 fn remove ( & mut self , key : & H256 ) {
103103 self . overlay . remove ( key) ;
104104 }
105+
106+ fn is_empty ( & self ) -> bool {
107+ self . latest_era . is_none ( )
108+ }
105109}
106110
107111impl JournalDB for ArchiveDB {
@@ -114,10 +118,6 @@ impl JournalDB for ArchiveDB {
114118 } )
115119 }
116120
117- fn is_empty ( & self ) -> bool {
118- self . latest_era . is_none ( )
119- }
120-
121121 fn latest_era ( & self ) -> Option < u64 > {
122122 self . latest_era
123123 }
Original file line number Diff line number Diff line change @@ -35,9 +35,6 @@ pub trait JournalDB: HashDB {
3535 0
3636 }
3737
38- /// Check if this database has any commits
39- fn is_empty ( & self ) -> bool ;
40-
4138 /// Get the earliest era in the DB. None if there isn't yet any data in there.
4239 fn earliest_era ( & self ) -> Option < u64 > {
4340 None
Original file line number Diff line number Diff line change @@ -262,6 +262,10 @@ impl HashDB for MemoryDB {
262262 }
263263 }
264264 }
265+
266+ fn is_empty ( & self ) -> bool {
267+ self . data . is_empty ( )
268+ }
265269}
266270
267271#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments