bitshares / bitshares/bitshares-core

[Feature Request] Allow plugins to add tasks to chain maintenance

Open
#211 2 comments 0 reactions 0 assignees Claimed by @Dimfred View on GitHub
plugin
Dominant language
C++
Stars
1.2k
Forks
660
Avg merge
8h 17m
Merged PRs (30d)
26

Description

_From @nathanhourt on May 13, 2016 17:21_

Plugins may add various objects to the database, which allows 3rd party code to benefit from the infrastructure the blockchain uses to maintain its internal state. One of the tools the database uses to keep its state consistent is the maintenance interval, a time during which slow calculations can be performed, or index-wide sweeps to check for and execute pending tasks can be performed.

Currently, there is no way (that I know of) for a plugin to register a routine to be run during chain maintenance. This would be a useful feature for plugins, as they also may have some pending tasks or slow calculations which can be deferred to a maintenance interval.

I propose the addition of a method on the `chain::database` which allows plugins to register callable objects, which take as a parameter a non-const reference to the database, to be called during maintenance intervals. These objects would need to be registered during database initialization.

A different mode of operation could involve one-off tasks which can be deferred until maintenance. In this mode, the callable objects would be registered during normal database operations, executed at the maintenance interval, and then destroyed. Note that in this mode of operation, the callable objects would have to be serializable so that they could be saved to disk and restored on database shutdown and startup. This mode of operation, although more complex to implement due to the added requirements of serializability and persistence, may be more efficient as it is assumed that the tasks would only be registered if it is known that a maintenance step will be required, and the dirty objects (the ones needing updating) may be known as state of the callable object (thus avoiding the need to sweep an entire index looking for dirty objects). In this way, plugin maintenance routines would not need to be run at all unless they were known to be necessary, and index-wide sweeps could be avoided.

_Copied from original issue: cryptonomex/graphene#650_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the chain::database maintenance interval and plugin initialization described in the issue, then review linked pull request #1983. Done means agreeing on and implementing a supported way for plugins to register maintenance callables, with the chosen registration and persistence behavior documented by the project.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
blockchain, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.