BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Public Member Functions | List of all members
graphene::net::node_delegate Class Referenceabstract

used by node reports status to client or fetch data from client More...

#include <node.hpp>

Inheritance diagram for graphene::net::node_delegate:
graphene::app::detail::application_impl graphene::net::detail::statistics_gathering_node_delegate_wrapper

Public Member Functions

virtual ~node_delegate ()=default
 
virtual bool has_item (const net::item_id &id)=0
 
virtual bool handle_block (const graphene::net::block_message &blk_msg, bool sync_mode, std::vector< message_hash_type > &contained_transaction_msg_ids)=0
 Called when a new block comes in from the network. More...
 
virtual void handle_transaction (const graphene::net::trx_message &trx_msg)=0
 Called when a new transaction comes in from the network. More...
 
virtual void handle_message (const message &message_to_process)=0
 Called when a new message comes in from the network other than a block or a transaction. Currently there are no other possible messages, so this should never be called. More...
 
virtual std::vector< item_hash_tget_block_ids (const std::vector< item_hash_t > &blockchain_synopsis, uint32_t &remaining_item_count, uint32_t limit=2000)=0
 
virtual message get_item (const item_id &id)=0
 
virtual chain_id_type get_chain_id () const =0
 
virtual std::vector< item_hash_tget_blockchain_synopsis (const item_hash_t &reference_point, uint32_t number_of_blocks_after_reference_point)=0
 
virtual void sync_status (uint32_t item_type, uint32_t item_count)=0
 
virtual void connection_count_changed (uint32_t c)=0
 
virtual uint32_t get_block_number (const item_hash_t &block_id)=0
 
virtual fc::time_point_sec get_block_time (const item_hash_t &block_id)=0
 
virtual item_hash_t get_head_block_id () const =0
 
virtual uint32_t estimate_last_known_fork_from_git_revision_timestamp (uint32_t unix_timestamp) const =0
 
virtual void error_encountered (const std::string &message, const fc::oexception &error)=0
 
virtual uint8_t get_current_block_interval_in_seconds () const =0
 

Detailed Description

used by node reports status to client or fetch data from client

Definition at line 56 of file node.hpp.

Constructor & Destructor Documentation

◆ ~node_delegate()

virtual graphene::net::node_delegate::~node_delegate ( )
virtualdefault

Member Function Documentation

◆ connection_count_changed()

virtual void graphene::net::node_delegate::connection_count_changed ( uint32_t  c)
pure virtual

Call any time the number of connected peers changes.

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.

◆ error_encountered()

virtual void graphene::net::node_delegate::error_encountered ( const std::string &  message,
const fc::oexception error 
)
pure virtual

◆ estimate_last_known_fork_from_git_revision_timestamp()

virtual uint32_t graphene::net::node_delegate::estimate_last_known_fork_from_git_revision_timestamp ( uint32_t  unix_timestamp) const
pure virtual

◆ get_block_ids()

virtual std::vector<item_hash_t> graphene::net::node_delegate::get_block_ids ( const std::vector< item_hash_t > &  blockchain_synopsis,
uint32_t &  remaining_item_count,
uint32_t  limit = 2000 
)
pure virtual

Assuming all data elements are ordered in some way, this method should return up to limit ids that occur after from_id. 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

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper.

◆ get_block_number()

virtual uint32_t graphene::net::node_delegate::get_block_number ( const item_hash_t block_id)
pure virtual

◆ get_block_time()

virtual fc::time_point_sec graphene::net::node_delegate::get_block_time ( const item_hash_t block_id)
pure virtual

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()

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.

◆ get_blockchain_synopsis()

virtual std::vector<item_hash_t> graphene::net::node_delegate::get_blockchain_synopsis ( const item_hash_t reference_point,
uint32_t  number_of_blocks_after_reference_point 
)
pure virtual

Returns a synopsis of the blockchain used for syncing. This consists of a list of selected item hashes from our current preferred blockchain, exponentially falling off into the past. Horrible explanation.

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

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.

◆ get_chain_id()

virtual chain_id_type graphene::net::node_delegate::get_chain_id ( ) const
pure virtual

◆ get_current_block_interval_in_seconds()

virtual uint8_t graphene::net::node_delegate::get_current_block_interval_in_seconds ( ) const
pure virtual

◆ get_head_block_id()

virtual item_hash_t graphene::net::node_delegate::get_head_block_id ( ) const
pure virtual

◆ get_item()

virtual message graphene::net::node_delegate::get_item ( const item_id id)
pure virtual

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

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.

◆ handle_block()

virtual bool graphene::net::node_delegate::handle_block ( const graphene::net::block_message blk_msg,
bool  sync_mode,
std::vector< message_hash_type > &  contained_transaction_msg_ids 
)
pure virtual

Called when a new block comes in from the network.

Parameters
blk_msgthe message which contains the block
sync_modetrue if the message was fetched through the sync process, false during normal operation
contained_transaction_msg_idscontainer for the transactions to write back into
Returns
true if this message caused the blockchain to switch forks, false if it did not
Exceptions
exceptionif error validating the item, otherwise the item is safe to broadcast on.

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper.

◆ handle_message()

virtual void graphene::net::node_delegate::handle_message ( const message message_to_process)
pure virtual

Called when a new message comes in from the network other than a block or a transaction. Currently there are no other possible messages, so this should never be called.

Exceptions
exceptionif error validating the item, otherwise the item is safe to broadcast on.

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.

◆ handle_transaction()

virtual void graphene::net::node_delegate::handle_transaction ( const graphene::net::trx_message trx_msg)
pure virtual

Called when a new transaction comes in from the network.

Exceptions
exceptionif error validating the item, otherwise the item is safe to broadcast on.

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.

◆ has_item()

virtual bool graphene::net::node_delegate::has_item ( const net::item_id id)
pure virtual

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

Implemented in graphene::app::detail::application_impl, and graphene::net::detail::statistics_gathering_node_delegate_wrapper.

◆ sync_status()

virtual void graphene::net::node_delegate::sync_status ( uint32_t  item_type,
uint32_t  item_count 
)
pure virtual

Call this after the call to handle_message succeeds.

Parameters
item_typethe type of the item we're synchronizing, will be the same as item passed to the sync_from() call
item_countthe 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

Implemented in graphene::net::detail::statistics_gathering_node_delegate_wrapper, and graphene::app::detail::application_impl.


The documentation for this class was generated from the following file: