danicoin/src/P2p/NetNodeCommon.h

31 lines
1.5 KiB
C
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-03-03 22:07:58 +00:00
#pragma once
2015-07-30 15:22:07 +00:00
#include "CryptoNote.h"
#include "P2pProtocolTypes.h"
2014-03-03 22:07:58 +00:00
2015-05-27 12:08:46 +00:00
namespace CryptoNote {
2014-03-03 22:07:58 +00:00
2015-07-30 15:22:07 +00:00
struct CryptoNoteConnectionContext;
2014-03-03 22:07:58 +00:00
2015-07-30 15:22:07 +00:00
struct IP2pEndpoint {
virtual void relay_notify_to_all(int command, const BinaryArray& data_buff, const net_connection_id* excludeConnection) = 0;
virtual bool invoke_notify_to_peer(int command, const BinaryArray& req_buff, const CryptoNote::CryptoNoteConnectionContext& context) = 0;
2014-03-03 22:07:58 +00:00
virtual uint64_t get_connections_count()=0;
2015-07-30 15:22:07 +00:00
virtual void for_each_connection(std::function<void(CryptoNote::CryptoNoteConnectionContext&, PeerIdType)> f) = 0;
2015-05-27 12:08:46 +00:00
// can be called from external threads
2015-07-30 15:22:07 +00:00
virtual void externalRelayNotifyToAll(int command, const BinaryArray& data_buff) = 0;
2014-03-03 22:07:58 +00:00
};
2015-07-30 15:22:07 +00:00
struct p2p_endpoint_stub: public IP2pEndpoint {
virtual void relay_notify_to_all(int command, const BinaryArray& data_buff, const net_connection_id* excludeConnection) override {}
virtual bool invoke_notify_to_peer(int command, const BinaryArray& req_buff, const CryptoNote::CryptoNoteConnectionContext& context) override { return true; }
virtual void for_each_connection(std::function<void(CryptoNote::CryptoNoteConnectionContext&, PeerIdType)> f) override {}
virtual uint64_t get_connections_count() override { return 0; }
virtual void externalRelayNotifyToAll(int command, const BinaryArray& data_buff) override {}
2014-03-03 22:07:58 +00:00
};
}