mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
merge bitcoin#19314: Use uint16_t instead of unsigned short
This commit is contained in:
parent
9e9e170bd6
commit
f5f41e5348
@ -14,6 +14,8 @@
|
||||
#include <tinyformat.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename Stream, typename Data>
|
||||
@ -36,7 +38,7 @@ template <typename Data>
|
||||
bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data& data)
|
||||
{
|
||||
// Generate random temporary filename
|
||||
unsigned short randv = 0;
|
||||
uint16_t randv = 0;
|
||||
GetRandBytes((unsigned char*)&randv, sizeof(randv));
|
||||
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <sys/event.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <math.h>
|
||||
@ -134,9 +135,9 @@ void CConnman::AddOneShot(const std::string& strDest)
|
||||
vOneShots.push_back(strDest);
|
||||
}
|
||||
|
||||
unsigned short GetListenPort()
|
||||
uint16_t GetListenPort()
|
||||
{
|
||||
return (unsigned short)(gArgs.GetArg("-port", Params().GetDefaultPort()));
|
||||
return (uint16_t)(gArgs.GetArg("-port", Params().GetDefaultPort()));
|
||||
}
|
||||
|
||||
// find 'best' local address for a particular peer
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <consensus/params.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <stdint.h>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <condition_variable>
|
||||
@ -683,7 +683,7 @@ private:
|
||||
friend struct ConnmanTestMsg;
|
||||
};
|
||||
void Discover();
|
||||
unsigned short GetListenPort();
|
||||
uint16_t GetListenPort();
|
||||
|
||||
struct CombinerAll
|
||||
{
|
||||
|
@ -836,15 +836,15 @@ CService::CService() : port(0)
|
||||
{
|
||||
}
|
||||
|
||||
CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn)
|
||||
CService::CService(const CNetAddr& cip, uint16_t portIn) : CNetAddr(cip), port(portIn)
|
||||
{
|
||||
}
|
||||
|
||||
CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn)
|
||||
CService::CService(const struct in_addr& ipv4Addr, uint16_t portIn) : CNetAddr(ipv4Addr), port(portIn)
|
||||
{
|
||||
}
|
||||
|
||||
CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn)
|
||||
CService::CService(const struct in6_addr& ipv6Addr, uint16_t portIn) : CNetAddr(ipv6Addr), port(portIn)
|
||||
{
|
||||
}
|
||||
|
||||
@ -872,7 +872,7 @@ bool CService::SetSockAddr(const struct sockaddr *paddr)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned short CService::GetPort() const
|
||||
uint16_t CService::GetPort() const
|
||||
{
|
||||
return port;
|
||||
}
|
||||
@ -944,7 +944,7 @@ std::string CService::ToString(bool fUseGetnameinfo) const
|
||||
return ToStringIPPort(fUseGetnameinfo);
|
||||
}
|
||||
|
||||
void CService::SetPort(unsigned short portIn)
|
||||
void CService::SetPort(uint16_t portIn)
|
||||
{
|
||||
port = portIn;
|
||||
}
|
||||
|
@ -505,11 +505,11 @@ class CService : public CNetAddr
|
||||
|
||||
public:
|
||||
CService();
|
||||
CService(const CNetAddr& ip, unsigned short port);
|
||||
CService(const struct in_addr& ipv4Addr, unsigned short port);
|
||||
CService(const CNetAddr& ip, uint16_t port);
|
||||
CService(const struct in_addr& ipv4Addr, uint16_t port);
|
||||
explicit CService(const struct sockaddr_in& addr);
|
||||
void SetPort(unsigned short portIn);
|
||||
unsigned short GetPort() const;
|
||||
void SetPort(uint16_t portIn);
|
||||
uint16_t GetPort() const;
|
||||
bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const;
|
||||
bool SetSockAddr(const struct sockaddr* paddr);
|
||||
friend bool operator==(const CService& a, const CService& b);
|
||||
@ -520,7 +520,7 @@ class CService : public CNetAddr
|
||||
std::string ToStringPort() const;
|
||||
std::string ToStringIPPort(bool fUseGetnameinfo = true) const;
|
||||
|
||||
CService(const struct in6_addr& ipv6Addr, unsigned short port);
|
||||
CService(const struct in6_addr& ipv6Addr, uint16_t port);
|
||||
explicit CService(const struct sockaddr_in6& addr);
|
||||
|
||||
SERIALIZE_METHODS(CService, obj)
|
||||
|
@ -799,11 +799,11 @@ bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int
|
||||
ProxyCredentials random_auth;
|
||||
static std::atomic_int counter(0);
|
||||
random_auth.username = random_auth.password = strprintf("%i", counter++);
|
||||
if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) {
|
||||
if (!Socks5(strDest, (uint16_t)port, &random_auth, hSocket)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Socks5(strDest, (unsigned short)port, 0, hSocket)) {
|
||||
if (!Socks5(strDest, (uint16_t)port, 0, hSocket)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include <amount.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
namespace interfaces {
|
||||
@ -14,7 +16,7 @@ class Node;
|
||||
}
|
||||
|
||||
extern const char *DEFAULT_GUI_PROXY_HOST;
|
||||
static constexpr unsigned short DEFAULT_GUI_PROXY_PORT = 9050;
|
||||
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
|
||||
|
||||
/** Interface from Qt to configuration data structure for Bitcoin client.
|
||||
To Qt, the options are presented as a list with the different options
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
@ -17,7 +18,6 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <unordered_map>
|
||||
@ -281,7 +281,7 @@ template <typename T> size_t GetSerializeSize(const T& t, int nVersion = 0);
|
||||
inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
|
||||
{
|
||||
if (nSize < 253) return sizeof(unsigned char);
|
||||
else if (nSize <= std::numeric_limits<unsigned short>::max()) return sizeof(unsigned char) + sizeof(unsigned short);
|
||||
else if (nSize <= std::numeric_limits<uint16_t>::max()) return sizeof(unsigned char) + sizeof(uint16_t);
|
||||
else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
|
||||
else return sizeof(unsigned char) + sizeof(uint64_t);
|
||||
}
|
||||
@ -295,7 +295,7 @@ void WriteCompactSize(Stream& os, uint64_t nSize)
|
||||
{
|
||||
ser_writedata8(os, nSize);
|
||||
}
|
||||
else if (nSize <= std::numeric_limits<unsigned short>::max())
|
||||
else if (nSize <= std::numeric_limits<uint16_t>::max())
|
||||
{
|
||||
ser_writedata8(os, 253);
|
||||
ser_writedata16(os, nSize);
|
||||
|
@ -2,12 +2,11 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <addrdb.h>
|
||||
#include <addrman.h>
|
||||
#include <clientversion.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <string>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <serialize.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
@ -18,8 +17,12 @@
|
||||
#include <util/strencodings.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
class CAddrManSerializationMock : public CAddrMan
|
||||
{
|
||||
@ -84,10 +87,10 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
|
||||
BOOST_AUTO_TEST_CASE(cnode_listen_port)
|
||||
{
|
||||
// test default
|
||||
unsigned short port = GetListenPort();
|
||||
uint16_t port = GetListenPort();
|
||||
BOOST_CHECK(port == Params().GetDefaultPort());
|
||||
// test set port
|
||||
unsigned short altPort = 12345;
|
||||
uint16_t altPort = 12345;
|
||||
BOOST_CHECK(gArgs.SoftSetArg("-port", std::to_string(altPort)));
|
||||
port = GetListenPort();
|
||||
BOOST_CHECK(port == altPort);
|
||||
|
Loading…
Reference in New Issue
Block a user