![]() |
Master Core
v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
|
#include "bloom.h"
#include "compat.h"
#include "hash.h"
#include "limitedmap.h"
#include "mruset.h"
#include "netbase.h"
#include "protocol.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#include <deque>
#include <stdint.h>
#include <arpa/inet.h>
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp>
#include <openssl/rand.h>
Go to the source code of this file.
Classes | |
struct | CNodeSignals |
struct | LocalServiceInfo |
class | CNodeStats |
class | CNetMessage |
class | CNode |
Information about a peer. More... | |
class | CAddrDB |
Access to the (IP) address database (peers.dat) More... | |
Typedefs | |
typedef int | NodeId |
Enumerations | |
enum | { LOCAL_NONE, LOCAL_IF, LOCAL_BIND, LOCAL_UPNP, LOCAL_HTTP, LOCAL_MANUAL, LOCAL_MAX } |
Functions | |
unsigned int | ReceiveFloodSize () |
unsigned int | SendBufferSize () |
void | AddOneShot (std::string strDest) |
bool | RecvLine (SOCKET hSocket, std::string &strLine) |
bool | GetMyExternalIP (CNetAddr &ipRet) |
void | AddressCurrentlyConnected (const CService &addr) |
CNode * | FindNode (const CNetAddr &ip) |
CNode * | FindNode (const CService &ip) |
CNode * | ConnectNode (CAddress addrConnect, const char *strDest=NULL) |
void | MapPort (bool fUseUPnP) |
unsigned short | GetListenPort () |
bool | BindListenPort (const CService &bindAddr, std::string &strError=REF(std::string())) |
void | StartNode (boost::thread_group &threadGroup) |
bool | StopNode () |
void | SocketSendData (CNode *pnode) |
CNodeSignals & | GetNodeSignals () |
void | SetLimited (enum Network net, bool fLimited=true) |
Make a particular network entirely off-limits (no automatic connects to it) More... | |
bool | IsLimited (enum Network net) |
bool | IsLimited (const CNetAddr &addr) |
bool | AddLocal (const CService &addr, int nScore=LOCAL_NONE) |
bool | AddLocal (const CNetAddr &addr, int nScore=LOCAL_NONE) |
bool | SeenLocal (const CService &addr) |
vote for a local address More... | |
bool | IsLocal (const CService &addr) |
check whether a given address is potentially local More... | |
bool | GetLocal (CService &addr, const CNetAddr *paddrPeer=NULL) |
bool | IsReachable (const CNetAddr &addr) |
check whether a given address is in a network we can probably connect to More... | |
void | SetReachable (enum Network net, bool fFlag=true) |
CAddress | GetLocalAddress (const CNetAddr *paddrPeer=NULL) |
void | RelayTransaction (const CTransaction &tx, const uint256 &hash) |
void | RelayTransaction (const CTransaction &tx, const uint256 &hash, const CDataStream &ss) |
Variables | |
static const unsigned int | MAX_INV_SZ = 50000 |
The maximum number of entries in an 'inv' protocol message. More... | |
static const size_t | MAPASKFOR_MAX_SZ = MAX_INV_SZ |
The maximum number of entries in mapAskFor. More... | |
bool | fDiscover |
uint64_t | nLocalServices |
uint64_t | nLocalHostNonce |
CAddrMan | addrman |
int | nMaxConnections |
std::vector< CNode * > | vNodes |
CCriticalSection | cs_vNodes |
std::map< CInv, CDataStream > | mapRelay |
std::deque< std::pair< int64_t, CInv > > | vRelayExpiration |
CCriticalSection | cs_mapRelay |
limitedmap< CInv, int64_t > | mapAlreadyAskedFor |
std::vector< std::string > | vAddedNodes |
CCriticalSection | cs_vAddedNodes |
NodeId | nLastNodeId |
CCriticalSection | cs_nLastNodeId |
CCriticalSection | cs_mapLocalHost |
map< CNetAddr, LocalServiceInfo > | mapLocalHost |
anonymous enum |
bool AddLocal | ( | const CService & | addr, |
int | nScore = LOCAL_NONE |
||
) |
Definition at line 216 of file net.cpp.
References AdvertizeLocal(), fDiscover, CNetAddr::GetNetwork(), CService::GetPort(), IsLimited(), CNetAddr::IsRoutable(), LOCAL_MANUAL, LOCK, LogPrintf, LocalServiceInfo::nPort, LocalServiceInfo::nScore, SetReachable(), and CService::ToString().
Referenced by AddLocal(), AppInit2(), BindListenPort(), Discover(), and ThreadGetMyExternalIP().
bool AddLocal | ( | const CNetAddr & | addr, |
int | nScore = LOCAL_NONE |
||
) |
Definition at line 245 of file net.cpp.
References AddLocal(), and GetListenPort().
void AddOneShot | ( | std::string | strDest | ) |
Definition at line 88 of file net.cpp.
References LOCK.
Referenced by AppInit2(), ProcessOneShot(), and ThreadDNSAddressSeed().
void AddressCurrentlyConnected | ( | const CService & | addr | ) |
Definition at line 400 of file net.cpp.
References CAddrMan::Connected().
Referenced by ProcessMessage().
Definition at line 1561 of file net.cpp.
References _(), AddLocal(), fDiscover, CService::GetSockAddr(), INVALID_SOCKET, CNetAddr::IsIPv6(), CNetAddr::IsRoutable(), LOCAL_BIND, LogPrintf, NetworkErrorString(), SOCKET_ERROR, strprintf, CService::ToString(), WSAEADDRINUSE, and WSAGetLastError.
Referenced by Bind().
debug print
Definition at line 440 of file net.cpp.
References CNode::AddRef(), CAddrMan::Attempt(), ConnectSocket(), ConnectSocketByName(), FindNode(), GetAdjustedTime(), GetTime(), IsLocal(), LOCK, LogPrint(), LogPrintf, NetworkErrorString(), CAddress::nTime, CNode::nTimeConnected, Params(), SOCKET_ERROR, CService::ToString(), and WSAGetLastError.
Referenced by addnode(), and OpenNetworkConnection().
Definition at line 413 of file net.cpp.
References CNode::addr, and LOCK.
Referenced by ConnectNode(), and OpenNetworkConnection().
Definition at line 431 of file net.cpp.
References CNode::addr, and LOCK.
unsigned short GetListenPort | ( | ) |
Definition at line 94 of file net.cpp.
References GetArg(), and Params().
Referenced by AddLocal(), and AppInit2().
Definition at line 100 of file net.cpp.
References fNoListen, and LOCK.
Referenced by GetLocalAddress().
Definition at line 125 of file net.cpp.
References GetAdjustedTime(), GetLocal(), nLocalServices, CAddress::nServices, and CAddress::nTime.
Referenced by AdvertizeLocal(), ProcessMessage(), CNode::PushVersion(), and SendMessages().
bool GetMyExternalIP | ( | CNetAddr & | ipRet | ) |
Definition at line 346 of file net.cpp.
References GetMyExternalIP2(), and CNetAddr::IsValid().
Referenced by ThreadGetMyExternalIP().
CNodeSignals& GetNodeSignals | ( | ) |
Definition at line 86 of file net.cpp.
References g_signals.
Referenced by AppInit2(), CNode::CNode(), Shutdown(), and CNode::~CNode().
bool IsLimited | ( | enum Network | net | ) |
Definition at line 259 of file net.cpp.
References LOCK, and vfLimited.
Referenced by AddLocal(), AppInit2(), Bind(), Discover(), IsLimited(), and ThreadOpenConnections().
bool IsLimited | ( | const CNetAddr & | addr | ) |
Definition at line 265 of file net.cpp.
References CNetAddr::GetNetwork(), and IsLimited().
bool IsLocal | ( | const CService & | addr | ) |
check whether a given address is potentially local
Definition at line 286 of file net.cpp.
References LOCK.
Referenced by ConnectNode(), CNetAddr::GetGroup(), CNetAddr::IsRoutable(), OpenNetworkConnection(), and ThreadOpenConnections().
bool IsReachable | ( | const CNetAddr & | addr | ) |
check whether a given address is in a network we can probably connect to
Definition at line 293 of file net.cpp.
References CNetAddr::GetNetwork(), LOCK, vfLimited, and vfReachable.
Referenced by ProcessMessage().
void MapPort | ( | bool | fUseUPnP | ) |
Definition at line 1154 of file net.cpp.
Referenced by OptionsModel::setData(), StartNode(), and StopNode().
|
inline |
Definition at line 44 of file net.h.
References GetArg().
Referenced by ThreadSocketHandler().
bool RecvLine | ( | SOCKET | hSocket, |
std::string & | strLine | ||
) |
Definition at line 138 of file net.cpp.
References LogPrint(), MilliSleep(), NetworkErrorString(), WSAEINPROGRESS, WSAEINTR, WSAEMSGSIZE, WSAEWOULDBLOCK, and WSAGetLastError.
Referenced by GetMyExternalIP2().
void RelayTransaction | ( | const CTransaction & | tx, |
const uint256 & | hash | ||
) |
Definition at line 1807 of file net.cpp.
References PROTOCOL_VERSION, RelayTransaction(), CDataStream::reserve(), and SER_NETWORK.
Referenced by ProcessMessage(), RelayTransaction(), CWalletTx::RelayWalletTransaction(), and sendrawtransaction().
void RelayTransaction | ( | const CTransaction & | tx, |
const uint256 & | hash, | ||
const CDataStream & | ss | ||
) |
Definition at line 1815 of file net.cpp.
References CNode::cs_filter, CNode::fRelayTxes, GetTime(), CBloomFilter::IsRelevantAndUpdate(), LOCK, MSG_TX, CNode::pfilter, and CNode::PushInventory().
bool SeenLocal | ( | const CService & | addr | ) |
vote for a local address
Definition at line 271 of file net.cpp.
References AdvertizeLocal(), and LOCK.
Referenced by ProcessMessage().
|
inline |
Definition at line 45 of file net.h.
References GetArg().
Referenced by CNode::CNode(), ProcessGetData(), ProcessMessage(), ProcessMessages(), and ThreadMessageHandler().
void SetLimited | ( | enum Network | net, |
bool | fLimited = true |
||
) |
Make a particular network entirely off-limits (no automatic connects to it)
Definition at line 251 of file net.cpp.
References LOCK, NET_UNROUTABLE, and vfLimited.
Referenced by AppInit2().
void SetReachable | ( | enum Network | net, |
bool | fFlag = true |
||
) |
Definition at line 207 of file net.cpp.
References LOCK, NET_IPV4, NET_IPV6, and vfReachable.
Referenced by AddLocal(), and AppInit2().
void SocketSendData | ( | CNode * | pnode | ) |
Definition at line 693 of file net.cpp.
References CNode::CloseSocketDisconnect(), Checkpoints::data, GetTime(), CNode::hSocket, LogPrintf, MSG_NOSIGNAL, NetworkErrorString(), CNode::nLastSend, CNode::nSendBytes, CNode::nSendOffset, CNode::nSendSize, CNode::RecordBytesSent(), CNode::vSendMsg, WSAEINPROGRESS, WSAEINTR, WSAEMSGSIZE, WSAEWOULDBLOCK, and WSAGetLastError.
Referenced by CNode::EndMessage(), and ThreadSocketHandler().
void StartNode | ( | boost::thread_group & | threadGroup | ) |
Definition at line 1708 of file net.cpp.
References Discover(), DUMP_ADDRESSES_INTERVAL, DumpAddresses(), GetBoolArg(), INVALID_SOCKET, LogPrintf, LoopForever(), MapPort(), nLocalServices, ThreadDNSAddressSeed(), ThreadMessageHandler(), ThreadOpenAddedConnections(), ThreadOpenConnections(), ThreadSocketHandler(), TraceThread(), and USE_UPNP.
Referenced by AppInit2().
bool StopNode | ( | ) |
Definition at line 1751 of file net.cpp.
References DumpAddresses(), LogPrintf, MapPort(), MAX_OUTBOUND_CONNECTIONS, MilliSleep(), and CSemaphore::post().
Referenced by Shutdown().
CAddrMan addrman |
Definition at line 60 of file net.cpp.
Referenced by AppInit2(), and ProcessMessage().
CCriticalSection cs_mapLocalHost |
Definition at line 52 of file net.cpp.
Referenced by getnetworkinfo().
CCriticalSection cs_mapRelay |
Definition at line 67 of file net.cpp.
Referenced by ProcessGetData().
CCriticalSection cs_nLastNodeId |
CCriticalSection cs_vAddedNodes |
Definition at line 77 of file net.cpp.
Referenced by addnode(), and getaddednodeinfo().
CCriticalSection cs_vNodes |
Definition at line 64 of file net.cpp.
Referenced by AcceptBlock(), CopyNodeStats(), getaddednodeinfo(), getconnectioncount(), ClientModel::getNumConnections(), ping(), ProcessMessage(), and SendMessages().
bool fDiscover |
Definition at line 50 of file net.cpp.
Referenced by AddLocal(), AppInit2(), BindListenPort(), and Discover().
limitedmap<CInv, int64_t> mapAlreadyAskedFor |
Referenced by ProcessMessage().
|
static |
The maximum number of entries in mapAskFor.
Definition at line 42 of file net.h.
Referenced by CNode::AskFor().
map<CNetAddr, LocalServiceInfo> mapLocalHost |
Definition at line 53 of file net.cpp.
Referenced by getnetworkinfo().
std::map<CInv, CDataStream> mapRelay |
Definition at line 65 of file net.cpp.
Referenced by ProcessGetData().
|
static |
The maximum number of entries in an 'inv' protocol message.
Definition at line 40 of file net.h.
Referenced by ProcessMessage().
uint64_t nLocalHostNonce |
Definition at line 58 of file net.cpp.
Referenced by ProcessMessage(), and CNode::PushVersion().
uint64_t nLocalServices |
Definition at line 51 of file net.cpp.
Referenced by GetLocalAddress(), CNode::PushVersion(), and StartNode().
int nMaxConnections |
Definition at line 61 of file net.cpp.
Referenced by AppInit2().
std::vector<std::string> vAddedNodes |
Definition at line 76 of file net.cpp.
Referenced by addnode(), and getaddednodeinfo().
std::vector<CNode*> vNodes |
Definition at line 63 of file net.cpp.
Referenced by AcceptBlock(), CopyNodeStats(), getaddednodeinfo(), getblocktemplate(), getconnectioncount(), getinfo(), getnetworkinfo(), ClientModel::getNumConnections(), ping(), ProcessMessage(), SendMessages(), ThreadMessageHandler(), and ThreadSocketHandler().