aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol.cpp')
-rw-r--r--src/protocol.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 7b42f5270..c77a92f02 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -1,12 +1,11 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "protocol.h"
+
#include "util.h"
-#include "netbase.h"
-#include "main.h"
#ifndef WIN32
# include <arpa/inet.h>
@@ -22,7 +21,7 @@ static const char* ppszTypeName[] =
CMessageHeader::CMessageHeader()
{
- memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
+ memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE);
memset(pchCommand, 0, sizeof(pchCommand));
pchCommand[1] = 1;
nMessageSize = -1;
@@ -31,7 +30,7 @@ CMessageHeader::CMessageHeader()
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
{
- memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
+ memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE);
strncpy(pchCommand, pszCommand, COMMAND_SIZE);
nMessageSize = nMessageSizeIn;
nChecksum = 0;
@@ -48,7 +47,7 @@ std::string CMessageHeader::GetCommand() const
bool CMessageHeader::IsValid() const
{
// Check start string
- if (memcmp(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)) != 0)
+ if (memcmp(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0)
return false;
// Check the command string for errors
@@ -68,7 +67,7 @@ bool CMessageHeader::IsValid() const
// Message size
if (nMessageSize > MAX_SIZE)
{
- printf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize);
+ LogPrintf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand(), nMessageSize);
return false;
}
@@ -82,7 +81,7 @@ CAddress::CAddress() : CService()
Init();
}
-CAddress::CAddress(CService ipIn, uint64 nServicesIn) : CService(ipIn)
+CAddress::CAddress(CService ipIn, uint64_t nServicesIn) : CService(ipIn)
{
Init();
nServices = nServicesIn;
@@ -119,7 +118,7 @@ CInv::CInv(const std::string& strType, const uint256& hashIn)
}
}
if (i == ARRAYLEN(ppszTypeName))
- throw std::out_of_range(strprintf("CInv::CInv(string, uint256) : unknown type '%s'", strType.c_str()));
+ throw std::out_of_range(strprintf("CInv::CInv(string, uint256) : unknown type '%s'", strType));
hash = hashIn;
}
@@ -142,16 +141,11 @@ const char* CInv::GetCommand() const
std::string CInv::ToString() const
{
- if (type == MSG_BLOCK)
- return strprintf("%s %s", GetCommand(), BlockHashStr(hash).c_str());
- if (type == MSG_TX)
- return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,10).c_str());
-
- return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str());
+ return strprintf("%s %s", GetCommand(), hash.ToString());
}
void CInv::print() const
{
- printf("CInv(%s)\n", ToString().c_str());
+ LogPrintf("CInv(%s)\n", ToString());
}