[bitshares/bitshares-core] Fix issue #125: sign block with old key if signing key updated in same block (#1203)

abitmore commented on this pull request.

> @@ -250,7 +253,7 @@ block_production_condition::block_production_condition_enum witness_plugin::mayb
}

fc::time_point_sec scheduled_time = db.get_slot_time( slot );
— graphene::chain::public_key_type scheduled_key = scheduled_witness( db ).signing_key;
+ graphene::chain::public_key_type scheduled_key = *db.find_witness_key_from_cache( scheduled_witness ); // should be valid

Essentially you mean to move the cache to witness plugin. Because there is no signal when a block is popped out, in order to deal with chain reorganization, the cache should be in (extended) chain state. Then, in order to make it work, need to either replay the whole chain to enable the plugin, or add code to refresh the cache (copy data from main chain state to the extended part) on startup. Then, in case when there is a reorganization to the startup head block, need to make sure the cache don’t get emptied.

I didn’t see it’s simpler so far.