You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/chain/controller.cpp
+36-21Lines changed: 36 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -24,9 +24,6 @@
24
24
25
25
#include<eosio/chain/eosio_contract.hpp>
26
26
27
-
#include<eosio/chain/database_utils.hpp>
28
-
#include<eosio/chain/snapshot.hpp>
29
-
30
27
namespaceeosio { namespacechain {
31
28
32
29
using resource_limits::resource_limits_manager;
@@ -149,6 +146,7 @@ struct controller_impl {
149
146
}
150
147
151
148
if ( read_mode == db_read_mode::SPECULATIVE ) {
149
+
EOS_ASSERT( head->block && head->block->transactions.size() == head->trxs.size(), block_validate_exception, "attempting to pop a block that was sparsely loaded from a snapshot");
152
150
for( constauto& t : head->trxs )
153
151
unapplied_transactions[t->signed_id] = t;
154
152
}
@@ -266,15 +264,14 @@ struct controller_impl {
266
264
emit( self.irreversible_block, s );
267
265
}
268
266
269
-
voidinit() {
267
+
voidinit(const snapshot_reader_ptr& snapshot) {
270
268
271
-
/**
272
-
* The fork database needs an initial block_state to be set before
273
-
* it can accept any new blocks. This initial block state can be found
274
-
* in the database (whose head block state should be irreversible) or
275
-
* it would be the genesis state.
276
-
*/
277
-
if( !head ) {
269
+
if (snapshot) {
270
+
EOS_ASSERT(!head, fork_database_exception, "");
271
+
272
+
read_from_snapshot(snapshot);
273
+
274
+
} elseif( !head ) {
278
275
initialize_fork_db(); // set head to genesis state
0 commit comments