This document is intended to outline generic design of sidechain plugin used by Peerplays Node, to monitor and process events of interest on a target sidechain nodes. This interface will be extended to meet various other integrations.
Assumptions
Sidechain plugin purpose is to monitor and process events of interest on a multiple target sidechains.
Sidechain node provides interface for monitoring changes in a sidechain.
Monitoring is based on new block, new transaction or filtered single event (like transfer operation to specific address).
There is a sufficient C/C++ library for connecting to monitoring interface.
Sidechain node provides communication interface which sidechain handler can use to read all the required info about event of interest. E.g. HTTP/RPC…
For the simplicity, sequence diagram shows interactions between components in a single sidechain handler.
Suggested implementation
peerplays_sidechain_plugin is a class implementing a peerplays sidechain plugin.
Contains the instance of sidechain_manager
sidechain_manager is a class implementing Sidechain Manager
Contains the collection (std::vector) of sidechain_handlers
Contains the factory method for creating instance of sidechain_handler for particular sidechain
Factory method parameters include program options, used to pass configure options to a sidechain handler
Contains methods for calling sidechain_handlers methods for processing events of interest
recreate_primary_wallet This method will initiate recreation of primary wallet on active SON set change, if needed
process_deposits This method will call sidechain handlers method for processing sidechain deposits
process_withdrawals This method will call sidechain handlers method for processing sidechain withdrawals
sidechain_handler is a base class for implementing sidechain handlers
Needs to have access to user sidechain address mapping list, in order to filter events by checking addresses involved in a transaction against the list of addresses of interests.
sidechain_type get_sidechain() Gets the sidechain type
std::vectorstd::string get_sidechain_deposit_addresses() Gets the list of deposit addresses for a sidechain
std::vectorstd::string get_sidechain_withdraw_addresses() Gets the list of withdrawal addresses for a sidechain
std::string get_private_key(std::string public_key) Gets the private key for a given public key, for signing sidechain transactions
Needs to contain method receiving the data structure describing event of interest as the parameter
Contains following abstract methods (the list can change anytime):
virtual void recreate_primary_wallet() = 0; Method is called by sidechain manager, to recreate the primary wallet on a sidechain, if needed
virtual void process_deposit(const son_wallet_deposit_object &swdo) = 0; Callback method, called for each deposit that needs to be processed by a sidechain handler
void recreate_primary_wallet() override; Method is called by sidechain manager, to recreate the primary wallet on a sidechain, if needed
void process_deposit(const son_wallet_deposit_object &swdo) override; Callback method, called for each deposit that needs to be processed by a sidechain handler
void process_withdrawal(const son_wallet_withdraw_object &swwo) override; Callback method, called for each withdrawal that needs to be processed by a sidechain handler
sidechain_handler_ethereum is a class, inheriting sidechain_handler, implementing sidechain handler for Ethereum
TBD
sidechain_handler_eos is a class, inheriting sidechain_handler, implementing sidechain handler for EOS
TBD
sidechain_handler_peerplays is a class, inheriting sidechain_handler, implementing sidechain handler for Peerplays
Listener can be implemented as a callback of database.applied_block signal. This will give us access to newly created blocks, and its content.
Communication interface, like RPC client from Bitcoin handler, is not really needed, as we can read all the data we need from blockchain database.
Implements abstract methods:
void recreate_primary_wallet() override; Method is called by sidechain manager, to recreate the primary wallet on a sidechain, if needed
void process_deposit(const son_wallet_deposit_object &swdo) override; Callback method, called for each deposit that needs to be processed by a sidechain handler
void process_withdrawal(const son_wallet_withdraw_object &swwo) override; Callback method, called for each withdrawal that needs to be processed by a sidechain handler
sidechain_handler_* is a class, inheriting sidechain_handler, implementing sidechain handler for *