[EOSIO/eos] Fixes EOSIO/eos#2803 (#2822)

arhag requested changes on this pull request.

> @@ -301,7 +301,7 @@ bool producer_plugin_impl::start_block() {
// If we would wait less than 50ms (1/10 of block_interval), wait for the whole block interval.
fc::time_point now = fc::time_point::now();
fc::time_point base = std::max(now, chain.head_block_time());
— int64_t min_time_to_next_block = (config::block_interval_us) — (now.time_since_epoch().count() % (config::block_interval_us) );
+ int64_t min_time_to_next_block = (config::block_interval_us) — (base.time_since_epoch().count() % (config::block_interval_us) );

Although this isn’t a problem with your change, this line made me realize that the code only works if our block timestamps are always divisible by by the block interval, which it currently does.

It would be nice if you added a static_assert to ensure that `config::block_timestamp_epoch` (which should probably be renamed to `config::block_timestamp_epoch_ms` to be clear that it is in milliseconds since the Unix epoch) is divisible by `config::block_interval_ms`.

Добавить комментарий