Graphene::App

Graphene::App

namespace graphene::app

Unnamed Group

template <typename T>
T dejsonify(const string &s)

Some useful tools for boost::program_options arguments using vectors of JSON strings

Functions

vector<account_id_type> get_relevant_accounts(const object *obj)
void operation_get_impacted_accounts(const operation &op, flat_set<account_id_type> &result)
void transaction_get_impacted_accounts(const transaction &tx, flat_set<account_id_type> &result)
void operation_get_impacted_accounts(const graphene::chain::operation &op, fc::flat_set<graphene::chain::account_id_type> &result)
void transaction_get_impacted_accounts(const graphene::chain::transaction &tx, fc::flat_set<graphene::chain::account_id_type> &result)
class abstract_plugin
#include <plugin.hpp>

Subclassed by graphene::app::plugin

Public Functions

virtual void plugin_initialize(const boost::program_options::variables_map &options) = 0

Perform early startup routines and register plugin indexes, callbacks, etc.

Plugins MUST supply a method initialize() which will be called early in the application startup. This method should contain early setup code such as initializing variables, adding indexes to the database, registering callback methods from the database, adding APIs, etc., as well as applying any options in the options map

This method is called BEFORE the database is open, therefore any routines which require any chain state MUST NOT be called by this method. These routines should be performed in startup() instead.

Parameters
  • options: The options passed to the application, via configuration files or command line

virtual void plugin_startup() = 0

Begin normal runtime operations.

Plugins MUST supply a method startup() which will be called at the end of application startup. This method should contain code which schedules any tasks, or requires chain state.

virtual void plugin_shutdown() = 0

Cleanly shut down the plugin.

This is called to request a clean shutdown (e.g. due to SIGINT or SIGTERM).

virtual void plugin_set_app(application *a) = 0

Register the application instance with the plugin.

This is called by the framework to set the application.

virtual void plugin_set_program_options(boost::program_options::options_description &command_line_options, boost::program_options::options_description &config_file_options) = 0

Fill in command line parameters used by the plugin.

This method populates its arguments with any command-line and configuration file options the plugin supports. If a plugin does not need these options, it may simply provide an empty implementation of this method.

Parameters
  • command_line_options: All options this plugin supports taking on the command-line
  • config_file_options: All options this plugin supports storing in a configuration file

class application
#include <application.hpp>

Public Members

boost::signals2::signal<void()> syncing_finished

Emitted when syncing finishes (is_finished_syncing will return true)

class block_api
#include <api.hpp>

Block api.

class database_api
#include <database_api.hpp>

The database_api class implements the RPC API for the chain database.

This API exposes accessors on the database which query state tracked by a blockchain validating node. This API is read-only; all modifications to the database must be performed via transactions. Transactions are broadcast via the network_broadcast_api.

Public Functions

fc::variants get_objects(const vector<object_id_type> &ids) const

Get the objects corresponding to the provided IDs.

If any of the provided IDs does not map to an object, a null variant is returned in its position.

Return
The objects retrieved, in the order they are mentioned in ids
Parameters
  • ids: IDs of the objects to retrieve

void cancel_all_subscriptions()

Stop receiving any notifications.

This unsubscribes from all subscribed markets and objects.

optional<block_header> get_block_header(uint32_t block_num) const

Retrieve a block header.

Return
header of the referenced block, or null if no matching block was found
Parameters
  • block_num: Height of the block whose header should be returned

map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const

Retrieve multiple block header by block numbers.

Return
array of headers of the referenced blocks, or null if no matching block was found
Parameters
  • block_num: vector containing heights of the block whose header should be returned

optional<signed_block> get_block(uint32_t block_num) const

Retrieve a full, signed block.

Return
the referenced block, or null if no matching block was found
Parameters
  • block_num: Height of the block to be returned

processed_transaction get_transaction(uint32_t block_num, uint32_t trx_in_block) const

used to fetch an individual transaction.

optional<signed_transaction> get_recent_transaction_by_id(const transaction_id_type &id) const

If the transaction has not expired, this method will return the transaction for the given ID or it will return NULL if it is not known. Just because it is not known does not mean it wasn’t included in the blockchain.

chain_property_object get_chain_properties() const

Retrieve the chain_property_object associated with the chain.

global_property_object get_global_properties() const

Retrieve the current global_property_object.

fc::variant_object get_config() const

Retrieve compile-time constants.

chain_id_type get_chain_id() const

Get the chain ID.

dynamic_global_property_object get_dynamic_global_properties() const

Retrieve the current dynamic_global_property_object.

bool is_public_key_registered(string public_key) const

Determine whether a textual representation of a public key (in Base-58 format) is currently linked to any registered (i.e. non-stealth) account on the blockchain

Return
Whether a public key is known
Parameters
  • public_key: Public key

vector<optional<account_object>> get_accounts(const vector<account_id_type> &account_ids) const

Get a list of accounts by ID.

This function has semantics identical to get_objects

Return
The accounts corresponding to the provided IDs
Parameters
  • account_ids: IDs of the accounts to retrieve

std::map<string, full_account> get_full_accounts(const vector<string> &names_or_ids, bool subscribe)

Fetch all objects relevant to the specified accounts and subscribe to updates.

This function fetches all relevant objects for the given accounts, and subscribes to updates to the given accounts. If any of the strings in names_or_ids cannot be tied to an account, that input will be ignored. All other accounts will be retrieved and subscribed.

Return
Map of string from names_or_ids to the corresponding account
Parameters
  • callback: Function to call with updates
  • names_or_ids: Each item must be the name or ID of an account to retrieve

vector<account_id_type> get_account_references(account_id_type account_id) const

Return
all accounts that referr to the key or account id in their owner or active authorities.

vector<optional<account_object>> lookup_account_names(const vector<string> &account_names) const

Get a list of accounts by name.

This function has semantics identical to get_objects

Return
The accounts holding the provided names
Parameters
  • account_names: Names of the accounts to retrieve

map<string, account_id_type> lookup_accounts(const string &lower_bound_name, uint32_t limit) const

Get names and IDs for registered accounts.

Return
Map of account names to corresponding IDs
Parameters
  • lower_bound_name: Lower bound of the first name to return
  • limit: Maximum number of results to return must not exceed 1000

vector<asset> get_account_balances(account_id_type id, const flat_set<asset_id_type> &assets) const

Get an account’s balances in various assets.

Return
Balances of the account
Parameters
  • id: ID of the account to get balances for
  • assets: IDs of the assets to get balances of; if empty, get all assets account has a balance in

vector<asset> get_named_account_balances(const std::string &name, const flat_set<asset_id_type> &assets) const

Semantically equivalent to get_account_balances, but takes a name instead of an ID.

vector<balance_object> get_balance_objects(const vector<address> &addrs) const

Return
all unclaimed balance objects for a set of addresses

uint64_t get_account_count() const

Get the total number of accounts registered with the blockchain.

vector<optional<asset_object>> get_assets(const vector<asset_id_type> &asset_ids) const

Get a list of assets by ID.

This function has semantics identical to get_objects

Return
The assets corresponding to the provided IDs
Parameters
  • asset_ids: IDs of the assets to retrieve

vector<asset_object> list_assets(const string &lower_bound_symbol, uint32_t limit) const

Get assets alphabetically by symbol name.

Return
The assets found
Parameters
  • lower_bound_symbol: Lower bound of symbol names to retrieve
  • limit: Maximum number of assets to fetch (must not exceed 100)

vector<optional<asset_object>> lookup_asset_symbols(const vector<string> &symbols_or_ids) const

Get a list of assets by symbol.

This function has semantics identical to get_objects

Return
The assets corresponding to the provided symbols or IDs
Parameters
  • asset_symbols: Symbols or stringified IDs of the assets to retrieve

vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit) const

Get limit orders in a given market.

Return
The limit orders, ordered from least price to greatest
Parameters
  • a: ID of asset being sold
  • b: ID of asset being purchased
  • limit: Maximum number of orders to retrieve

vector<call_order_object> get_call_orders(asset_id_type a, uint32_t limit) const

Get call orders in a given asset.

Return
The call orders, ordered from earliest to be called to latest
Parameters
  • a: ID of asset being called
  • limit: Maximum number of orders to retrieve

vector<force_settlement_object> get_settle_orders(asset_id_type a, uint32_t limit) const

Get forced settlement orders in a given asset.

Return
The settle orders, ordered from earliest settlement date to latest
Parameters
  • a: ID of asset being settled
  • limit: Maximum number of orders to retrieve

vector<call_order_object> get_margin_positions(const account_id_type &id) const

Return
all open margin positions for a given account id.

void subscribe_to_market(std::function<void(const variant&)> callback, asset_id_type a, asset_id_type b, )

Request notification when the active orders in the market between two assets changes.

Callback will be passed a variant containing a vector<pair<operation, operation_result>>. The vector will contain, in order, the operations which changed the market, and their results.

Parameters
  • callback: Callback method which is called when the market changes
  • a: First asset ID
  • b: Second asset ID

void unsubscribe_from_market(asset_id_type a, asset_id_type b)

Unsubscribe from updates to a given market.

Parameters
  • a: First asset ID
  • b: Second asset ID

market_ticker get_ticker(const string &base, const string &quote) const

Returns the ticker for the market assetA:assetB.

Return
The market ticker for the past 24 hours.
Parameters
  • a: String name of the first asset
  • b: String name of the second asset

market_volume get_24_volume(const string &base, const string &quote) const

Returns the 24 hour volume for the market assetA:assetB.

Return
The market volume over the past 24 hours
Parameters
  • a: String name of the first asset
  • b: String name of the second asset

order_book get_order_book(const string &base, const string &quote, unsigned limit = 50) const

Returns the order book for the market base:quote.

Return
Order book of the market
Parameters
  • base: String name of the first asset
  • quote: String name of the second asset
  • depth: of the order book. Up to depth of each asks and bids, capped at 50. Prioritizes most moderate of each

vector<market_trade> get_trade_history(const string &base, const string &quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100) const

Returns recent trades for the market assetA:assetB Note: Currentlt, timezone offsets are not supported. The time must be UTC.

Return
Recent transactions in the market
Parameters
  • a: String name of the first asset
  • b: String name of the second asset
  • stop: Stop time as a UNIX timestamp
  • limit: Number of trasactions to retrieve, capped at 100
  • start: Start time as a UNIX timestamp

vector<optional<witness_object>> get_witnesses(const vector<witness_id_type> &witness_ids) const

Get a list of witnesses by ID.

This function has semantics identical to get_objects

Return
The witnesses corresponding to the provided IDs
Parameters
  • witness_ids: IDs of the witnesses to retrieve

fc::optional<witness_object> get_witness_by_account(account_id_type account) const

Get the witness owned by a given account.

Return
The witness object, or null if the account does not have a witness
Parameters
  • account: The ID of the account whose witness should be retrieved

map<string, witness_id_type> lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const

Get names and IDs for registered witnesses.

Return
Map of witness names to corresponding IDs
Parameters
  • lower_bound_name: Lower bound of the first name to return
  • limit: Maximum number of results to return must not exceed 1000

uint64_t get_witness_count() const

Get the total number of witnesses registered with the blockchain.

vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const

Get a list of committee_members by ID.

This function has semantics identical to get_objects

Return
The committee_members corresponding to the provided IDs
Parameters
  • committee_member_ids: IDs of the committee_members to retrieve

fc::optional<committee_member_object> get_committee_member_by_account(account_id_type account) const

Get the committee_member owned by a given account.

Return
The committee_member object, or null if the account does not have a committee_member
Parameters
  • account: The ID of the account whose committee_member should be retrieved

map<string, committee_member_id_type> lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const

Get names and IDs for registered committee_members.

Return
Map of committee_member names to corresponding IDs
Parameters
  • lower_bound_name: Lower bound of the first name to return
  • limit: Maximum number of results to return must not exceed 1000

vector<worker_object> get_workers_by_account(account_id_type account) const

WORKERS.

Return the worker objects associated with this account.

vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const

Given a set of votes, return the objects they are voting for.

This will be a mixture of committee_member_object, witness_objects, and worker_objects

The results will be in the same order as the votes. Null will be returned for any vote ids that are not found.

std::string get_transaction_hex(const signed_transaction &trx) const

Get a hexdump of the serialized binary form of a transaction.

set<public_key_type> get_required_signatures(const signed_transaction &trx, const flat_set<public_key_type> &available_keys) const

This API will take a partially signed transaction and a set of public keys that the owner has the ability to sign for and return the minimal subset of public keys that should add signatures to the transaction.

set<public_key_type> get_potential_signatures(const signed_transaction &trx) const

This method will return the set of all public keys that could possibly sign for a given transaction. This call can be used by wallets to filter their set of public keys to just the relevant subset prior to calling get_required_signatures to get the minimum subset.

bool verify_authority(const signed_transaction &trx) const

Return
true of the trx has all of the required signatures, otherwise throws an exception

bool verify_account_authority(const string &name_or_id, const flat_set<public_key_type> &signers) const

Return
true if the signers have enough authority to authorize an account

processed_transaction validate_transaction(const signed_transaction &trx) const

Validates a transaction against the current state without broadcasting it on the network.

vector<fc::variant> get_required_fees(const vector<operation> &ops, asset_id_type id) const

For each operation calculate the required fee in the specified asset type. If the asset type does not have a valid core_exchange_rate

vector<proposal_object> get_proposed_transactions(account_id_type id) const

Return
the set of proposed transactions relevant to the specified account id.

vector<blinded_balance_object> get_blinded_balances(const flat_set<commitment_type> &commitments) const

Return
the set of blinded balance objects by commitment ID

class database_api_impl

Inherits from std::enable_shared_from_this< database_api_impl >

Public Functions

vector<vector<account_id_type>> get_key_references(vector<public_key_type> key) const

Return
all accounts that referr to the key or account id in their owner or active authorities.

vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit) const

Return
the limit orders for both sides of the book for the two assets specified up to limit number on each side.

vector<proposal_object> get_proposed_transactions(account_id_type id) const

TODO: add secondary index that will accelerate this process

void on_objects_new(const vector<object_id_type> &ids, const flat_set<account_id_type> &impacted_accounts)

called every time a block is applied to report the objects that were changed

void on_applied_block()

note: this method cannot yield because it is called in the middle of apply a block.

struct get_required_fees_helper

Container method for mutually recursive functions used to implement get_required_fees() with potentially nested proposals.

class history_api
#include <api.hpp>

The history_api class implements the RPC API for account history.

This API contains methods to access account histories

Public Functions

vector<operation_history_object> get_account_history(account_id_type account, operation_history_id_type stop = operation_history_id_type (), unsigned limit = 100, operation_history_id_type start = operation_history_id_type ()) const

Get operations relevant to the specificed account.

Return
A list of operations performed by account, ordered from most recent to oldest.
Parameters
  • account: The account whose history should be queried
  • stop: ID of the earliest operation to retrieve
  • limit: Maximum number of operations to retrieve (must not exceed 100)
  • start: ID of the most recent operation to retrieve

vector<operation_history_object> get_account_history_operations(account_id_type account, int operation_id, operation_history_id_type start = operation_history_id_type (), operation_history_id_type stop = operation_history_id_type (), unsigned limit = 100) const

Get only asked operations relevant to the specified account.

Return
A list of operations performed by account, ordered from most recent to oldest.
Parameters
  • account: The account whose history should be queried
  • operation_id: The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, …)
  • stop: ID of the earliest operation to retrieve
  • limit: Maximum number of operations to retrieve (must not exceed 100)
  • start: ID of the most recent operation to retrieve

vector<operation_history_object> get_relative_account_history(account_id_type account, uint32_t stop = 0, unsigned limit = 100, uint32_t start = 0) const

Get operations relevant to the specified account referenced by an event numbering specific to the account. The current number of operations for the account can be found in the account statistics (or use 0 for start).

Return
A list of operations performed by account, ordered from most recent to oldest.
Parameters
  • account: The account whose history should be queried
  • stop: Sequence number of earliest operation. 0 is default and will query ‘limit’ number of operations.
  • limit: Maximum number of operations to retrieve (must not exceed 100)
  • start: Sequence number of the most recent operation to retrieve. 0 is default, which will start querying from the most recent operation.

class login_api
#include <api.hpp>

The login_api class implements the bottom layer of the RPC API.

All other APIs must be requested from this API.

Public Functions

bool login(const string &user, const string &password)

Authenticate to the RPC server.

Return
True if logged in successfully; false otherwise
Note
This must be called prior to requesting other APIs. Other APIs may not be accessible until the client has sucessfully authenticated.
Parameters
  • user: Username to login with
  • password: Password to login with

fc::api<block_api> block() const

Retrieve the network block API.

fc::api<network_broadcast_api> network_broadcast() const

Retrieve the network broadcast API.

fc::api<database_api> database() const

Retrieve the database API.

fc::api<history_api> history() const

Retrieve the history API.

fc::api<network_node_api> network_node() const

Retrieve the network node API.

fc::api<crypto_api> crypto() const

Retrieve the cryptography API.

fc::api<asset_api> asset() const

Retrieve the asset API.

fc::api<graphene::debug_witness::debug_api> debug() const

Retrieve the debug API (if available)

void enable_api(const string &api_name)

Called to enable an API, not reflected.

class network_broadcast_api
#include <api.hpp>

The network_broadcast_api class allows broadcasting of transactions.

Inherits from std::enable_shared_from_this< network_broadcast_api >

Public Functions

void broadcast_transaction(const signed_transaction &trx)

Broadcast a transaction to the network.

The transaction will be checked for validity in the local database prior to broadcasting. If it fails to apply locally, an error will be thrown and the transaction will not be broadcast.

Parameters
  • trx: The transaction to broadcast

void broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction &trx)

this version of broadcast transaction registers a callback method that will be called when the transaction is included into a block. The callback method includes the transaction id, block number, and transaction number in the block.

fc::variant broadcast_transaction_synchronous(const signed_transaction &trx)

this version of broadcast transaction registers a callback method that will be called when the transaction is included into a block. The callback method includes the transaction id, block number, and transaction number in the block.

void on_applied_block(const signed_block &b)

Not reflected, thus not accessible to API clients.

This function is registered to receive the applied_block signal from the chain database when a block is received. It then dispatches callbacks to clients who have requested to be notified when a particular txid is included in a block.

class network_node_api
#include <api.hpp>

The network_node_api class allows maintenance of p2p connections.

Public Functions

fc::variant_object get_info() const

Return general network information, such as p2p port.

void add_node(const fc::ip::endpoint &ep)

add_node Connect to a new peer

Parameters
  • ep: The IP/Port of the peer to connect to

std::vector<net::peer_status> get_connected_peers() const

Get status of all current connections to peers.

fc::variant_object get_advanced_node_parameters() const

Get advanced node parameters, such as desired and max number of connections.

void set_advanced_node_parameters(const fc::variant_object &params)

Set advanced node parameters, such as desired and max number of connections.

Parameters
  • params: a JSON object containing the name/value pairs for the parameters to set

std::vector<net::potential_peer_record> get_potential_peers() const

Return list of potential peers.

class plugin
#include <plugin.hpp>

Provides basic default implementations of abstract_plugin functions.

Inherits from graphene::app::abstract_plugin

Public Functions

void plugin_initialize(const boost::program_options::variables_map &options)

Perform early startup routines and register plugin indexes, callbacks, etc.

Plugins MUST supply a method initialize() which will be called early in the application startup. This method should contain early setup code such as initializing variables, adding indexes to the database, registering callback methods from the database, adding APIs, etc., as well as applying any options in the options map

This method is called BEFORE the database is open, therefore any routines which require any chain state MUST NOT be called by this method. These routines should be performed in startup() instead.

Parameters
  • options: The options passed to the application, via configuration files or command line

void plugin_startup()

Begin normal runtime operations.

Plugins MUST supply a method startup() which will be called at the end of application startup. This method should contain code which schedules any tasks, or requires chain state.

void plugin_shutdown()

Cleanly shut down the plugin.

This is called to request a clean shutdown (e.g. due to SIGINT or SIGTERM).

void plugin_set_app(application *a)

Register the application instance with the plugin.

This is called by the framework to set the application.

void plugin_set_program_options(boost::program_options::options_description &command_line_options, boost::program_options::options_description &config_file_options)

Fill in command line parameters used by the plugin.

This method populates its arguments with any command-line and configuration file options the plugin supports. If a plugin does not need these options, it may simply provide an empty implementation of this method.

Parameters
  • command_line_options: All options this plugin supports taking on the command-line
  • config_file_options: All options this plugin supports storing in a configuration file

namespace detail

Functions

genesis_state_type create_example_genesis()
class application_impl

Inherits from node_delegate

Public Functions

virtual bool has_item(const net::item_id &id)

If delegate has the item, the network has no need to fetch it.

virtual bool handle_block(const graphene::net::block_message &blk_msg, bool sync_mode, std::vector<fc::uint160_t> &contained_transaction_message_ids)

allows the application to validate an item prior to broadcasting to peers.

Return
true if this message caused the blockchain to switch forks, false if it did not
Parameters
  • sync_mode: true if the message was fetched through the sync process, false during normal operation
Exceptions
  • exception: if error validating the item, otherwise the item is safe to broadcast on.

virtual std::vector<item_hash_t> get_block_ids(const std::vector<item_hash_t> &blockchain_synopsis, uint32_t &remaining_item_count, uint32_t limit)

Assuming all data elements are ordered in some way, this method should return up to limit ids that occur after the last ID in synopsis that we recognize.

On return, remaining_item_count will be set to the number of items in our blockchain after the last item returned in the result, or 0 if the result contains the last item in the blockchain

virtual message get_item(const item_id &id)

Given the hash of the requested data, fetch the body.

virtual std::vector<item_hash_t> get_blockchain_synopsis(const item_hash_t &reference_point, uint32_t number_of_blocks_after_reference_point)

Returns a synopsis of the blockchain used for syncing. This consists of a list of block hashes at intervals exponentially increasing towards the genesis block. When syncing to a peer, the peer uses this data to determine if we’re on the same fork as they are, and if not, what blocks they need to send us to get us on their fork.

In the over-simplified case, this is a straighforward synopsis of our current preferred blockchain; when we first connect up to a peer, this is what we will be sending. It looks like this: If the blockchain is empty, it will return the empty list. If the blockchain has one block, it will return a list containing just that block. If it contains more than one block: the first element in the list will be the hash of the highest numbered block that we cannot undo the second element will be the hash of an item at the half way point in the undoable segment of the blockchain the third will be ~3/4 of the way through the undoable segment of the block chain the fourth will be at ~7/8… &c. the last item in the list will be the hash of the most recent block on our preferred chain so if the blockchain had 26 blocks labeled a - z, the synopsis would be: a n u x z the idea being that by sending a small (<30) number of block ids, we can summarize a huge blockchain. The block ids are more dense near the end of the chain where because we are more likely to be almost in sync when we first connect, and forks are likely to be short. If the peer we’re syncing with in our example is on a fork that started at block ‘v’, then they will reply to our synopsis with a list of all blocks starting from block ‘u’, the last block they know that we had in common.

In the real code, there are several complications.

First, as an optimization, we don’t usually send a synopsis of the entire blockchain, we send a synopsis of only the segment of the blockchain that we have undo data for. If their fork doesn’t build off of something in our undo history, we would be unable to switch, so there’s no reason to fetch the blocks.

Second, when a peer replies to our initial synopsis and gives us a list of the blocks they think we are missing, they only send a chunk of a few thousand blocks at once. After we get those block ids, we need to request more blocks by sending another synopsis (we can’t just say “send me the next 2000 ids” because they may have switched forks themselves and they don’t track what they’ve sent us). For faster performance, we want to get a fairly long list of block ids first, then start downloading the blocks. The peer doesn’t handle these follow-up block id requests any different from the initial request; it treats the synopsis we send as our blockchain and bases its response entirely off that. So to get the response we want (the next chunk of block ids following the last one they sent us, or, failing that, the shortest fork off of the last list of block ids they sent), we need to construct a synopsis as if our blockchain was made up of:

  1. the blocks in our block chain up to the fork point (if there is a fork) or the head block (if no fork)
  2. the blocks we’ve already pushed from their fork (if there’s a fork)
  3. the block ids they’ve previously sent us Segment 3 is handled in the p2p code, it just tells us the number of blocks it has (in number_of_blocks_after_reference_point) so we can leave space in the synopsis for them. We’re responsible for constructing the synopsis of Segments 1 and 2 from our active blockchain and fork database. The reference_point parameter is the last block from that peer that has been successfully pushed to the blockchain, so that tells us whether the peer is on a fork or on the main chain.

virtual void sync_status(uint32_t item_type, uint32_t item_count)

Call this after the call to handle_message succeeds.

Parameters
  • item_type: the type of the item we’re synchronizing, will be the same as item passed to the sync_from() call
  • item_count: the number of items known to the node that haven’t been sent to handle_item() yet. After item_count more calls to handle_item(), the node will be in sync

virtual void connection_count_changed(uint32_t c)

Call any time the number of connected peers changes.

virtual fc::time_point_sec get_block_time(const item_hash_t &block_id)

Returns the time a block was produced (if block_id = 0, returns genesis time). If we don’t know about the block, returns time_point_sec::min()