// Copyright (c) 2011-2015 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once #include "CryptoNote.h" #include "P2pProtocolTypes.h" namespace CryptoNote { struct CryptoNoteConnectionContext; 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; virtual uint64_t get_connections_count()=0; virtual void for_each_connection(std::function f) = 0; // can be called from external threads virtual void externalRelayNotifyToAll(int command, const BinaryArray& data_buff) = 0; }; struct p2p_endpoint_stub: public IP2pEndpoint { virtual void relay_notify_to_all(int command, const BinaryArray& data_buff, const net_connection_id* excludeConnection) {} virtual bool invoke_notify_to_peer(int command, const BinaryArray& req_buff, const CryptoNote::CryptoNoteConnectionContext& context) { return true; } virtual void for_each_connection(std::function f) {} virtual uint64_t get_connections_count() { return 0; } virtual void externalRelayNotifyToAll(int command, const BinaryArray& data_buff) {} }; }