Open theoreticalbts opened 8 years ago
This is partially implemented in chainbase already but should be formalized by #264
Specifically, the version of a file may be defined as schema and there is semantics. Schema is the set of available fields.
Plugins and core must create schema and semantics objects. Schema objects can automatically be created with FC (see #683). Semantics objects must be manually defined, and manually updated whenever the way a field is calculated changes. Updating semantics should be made part of the release process for every major release.
I should make a special note that the core semantics version is different from STEEMIT_BLOCKCHAIN_VERSION
. Here are some of the differences:
STEEMIT_BLOCKCHAIN_VERSION
.Let's go for a little more detailed specification of what we should actually implement for this.
steem_abstract_plugin
which subclasses abstract_plugin
steem_abstract_plugin
defines a virtual
method virtual optional<sha256> get_state_config_hash()const = 0
steem_abstract_plugin
, we call get_state_config_hash()
and put all (plugin.get_name(), plugin.get_state_config_hash())
pairs in a vector< pair< string, sha256 > >
.("core", database.get_state_config_hash())
get_state_config_hash()
value of "core"
or any plugin should be changed whenever there is a data structure change or change of past semantics that invalidates the old versionget_state_config_hash()
can be anything, the simplest is just H(version)
but you could include other information, e.g. for market stats it could include bucket sizes so it reindexes when you change bucket sizes, or if schema
plugin is finally completed it could include a hash autogenerated from the data structure definitions, so any change to data structure fields automatically invalidates old files without requiring any explicit version number bump
When plugin settings change, plugin needs to be able to request a re-index. Likewise, some plugins may never need to re-index -- for example, plugins that don't provide objects, or whose object lifetimes are limited to a single run.
Related: #264 proposes updating based on schema changes, this code will have to interact with that.