pmconrad 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
The witness plugin is only interested in current head block. Blocks are only popped when switching forks, which means there will be block pushes immediately after the pop, which means the cache will automatically be updated in that case.
This is slightly different from the cache in database itself — that should always be up to date, also after popping blocks.
Overall, I think even if the resulting code is not significantly simpler, the containment in the witness plugin is a big plus.