fix market subscriptions
This commit is contained in:
parent
a5071f2568
commit
a84e56c2aa
4 changed files with 31 additions and 7 deletions
|
|
@ -874,7 +874,6 @@ namespace graphene { namespace app {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if( _market_subscriptions.size() )
|
if( _market_subscriptions.size() )
|
||||||
{
|
{
|
||||||
if( !_subscribe_callback )
|
if( !_subscribe_callback )
|
||||||
|
|
@ -890,7 +889,6 @@ namespace graphene { namespace app {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto capture_this = shared_from_this();
|
auto capture_this = shared_from_this();
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,10 @@ Each node implements the following protocol:
|
||||||
send( peer, block_summary )
|
send( peer, block_summary )
|
||||||
|
|
||||||
|
|
||||||
onConnect( new_peer, new_peer_head_block_num )
|
onHello( new_peer, new_peer_head_block_num )
|
||||||
|
|
||||||
|
replyHello( new_peer ) // ack the hello message with our timestamp to measure latency
|
||||||
|
|
||||||
if( peers.size() >= max_peers )
|
if( peers.size() >= max_peers )
|
||||||
send( new_peer, peers )
|
send( new_peer, peers )
|
||||||
disconnect( new_peer )
|
disconnect( new_peer )
|
||||||
|
|
@ -73,6 +76,9 @@ Each node implements the following protocol:
|
||||||
new_peer.synced = true
|
new_peer.synced = true
|
||||||
for( peer : peers )
|
for( peer : peers )
|
||||||
send( peer, new_peer )
|
send( peer, new_peer )
|
||||||
|
|
||||||
|
onHelloReply( from_peer, hello_reply )
|
||||||
|
update_latency_measure, disconnect if too slow
|
||||||
|
|
||||||
onReceivePeers( from_peer, peers )
|
onReceivePeers( from_peer, peers )
|
||||||
addToPotentialPeers( peers )
|
addToPotentialPeers( peers )
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <fc/reflect/variant.hpp>
|
#include <fc/reflect/variant.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace p2p {
|
namespace graphene { namespace p2p {
|
||||||
|
using namespace graphene::chain;
|
||||||
|
|
||||||
struct message_header
|
struct message_header
|
||||||
{
|
{
|
||||||
|
|
@ -94,16 +95,25 @@ namespace graphene { namespace p2p {
|
||||||
|
|
||||||
std::string user_agent;
|
std::string user_agent;
|
||||||
uint16_t version;
|
uint16_t version;
|
||||||
|
fc::time_point timestamp;
|
||||||
|
|
||||||
fc::ip::address inbound_address;
|
fc::ip::address inbound_address;
|
||||||
uint16_t inbound_port;
|
uint16_t inbound_port;
|
||||||
uint16_t outbound_port;
|
uint16_t outbound_port;
|
||||||
node_id_t node_public_key;
|
public_key_type node_public_key;
|
||||||
fc::sha256 chain_id;
|
fc::sha256 chain_id;
|
||||||
fc::variant_object user_data;
|
fc::variant_object user_data;
|
||||||
block_id_type head_block;
|
block_id_type head_block;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct hello_reply_message
|
||||||
|
{
|
||||||
|
static const core_message_type_enum type;
|
||||||
|
|
||||||
|
fc::time_point hello_timestamp;
|
||||||
|
fc::time_point reply_timestamp;
|
||||||
|
};
|
||||||
|
|
||||||
struct transaction_message
|
struct transaction_message
|
||||||
{
|
{
|
||||||
static const core_message_type_enum type;
|
static const core_message_type_enum type;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <graphene/p2p/node.hpp>
|
#include <graphene/p2p/node.hpp>
|
||||||
|
#include <graphene/p2p/message.hpp>
|
||||||
#include <graphene/p2p/message_oriented_connection.hpp>
|
#include <graphene/p2p/message_oriented_connection.hpp>
|
||||||
#include <graphene/p2p/stcp_socket.hpp>
|
#include <graphene/p2p/stcp_socket.hpp>
|
||||||
|
|
||||||
|
|
@ -42,16 +43,25 @@ namespace graphene { namespace p2p {
|
||||||
class peer_connection_delegate
|
class peer_connection_delegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void on_message(peer_connection* originating_peer,
|
virtual void on_message(peer_connection* originating_peer, const message& received_message) = 0;
|
||||||
const message& received_message) = 0;
|
|
||||||
virtual void on_connection_closed(peer_connection* originating_peer) = 0;
|
virtual void on_connection_closed(peer_connection* originating_peer) = 0;
|
||||||
virtual message get_message_for_item(const item_id& item) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class peer_connection;
|
class peer_connection;
|
||||||
typedef std::shared_ptr<peer_connection> peer_connection_ptr;
|
typedef std::shared_ptr<peer_connection> peer_connection_ptr;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each connection maintains its own queue of messages to be sent, when an item
|
||||||
|
* is first pushed to the queue it starts an async fiber that will sequentially write
|
||||||
|
* all items until there is nothing left to be sent.
|
||||||
|
*
|
||||||
|
* If a particular connection is unable to keep up with the real-time stream of
|
||||||
|
* messages to be sent then it will be disconnected. The backlog will be measured in
|
||||||
|
* seconds.
|
||||||
|
*
|
||||||
|
* A multi-index container that tracks the
|
||||||
|
*/
|
||||||
class peer_connection : public message_oriented_connection_delegate,
|
class peer_connection : public message_oriented_connection_delegate,
|
||||||
public std::enable_shared_from_this<peer_connection>
|
public std::enable_shared_from_this<peer_connection>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue