mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Move around to256 to uint256.h, get rid of Conversion.cpp,h
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
#include "Conversion.h"
|
||||
#include "base58.h"
|
||||
using namespace std;
|
||||
|
||||
#if 0
|
||||
|
||||
uint160 protobufTo160(const std::string& buf)
|
||||
{
|
||||
uint160 ret;
|
||||
// TODO:
|
||||
return(ret);
|
||||
}
|
||||
|
||||
uint256 protobufTo256(const std::string& hash)
|
||||
{
|
||||
uint256 ret;
|
||||
// TODO:
|
||||
return(ret);
|
||||
}
|
||||
|
||||
uint160 humanTo160(const std::string& buf)
|
||||
{
|
||||
vector<unsigned char> retVec;
|
||||
DecodeBase58(buf,retVec);
|
||||
uint160 ret;
|
||||
memcpy(ret.begin(), &retVec[0], ret.GetSerializeSize());
|
||||
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
bool humanToPK(const std::string& buf,std::vector<unsigned char>& retVec)
|
||||
{
|
||||
return(DecodeBase58(buf,retVec));
|
||||
}
|
||||
|
||||
bool u160ToHuman(uint160& buf, std::string& retStr)
|
||||
{
|
||||
retStr=EncodeBase58(buf.begin(),buf.end());
|
||||
return(true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
base_uint256 uint160::to256() const
|
||||
{
|
||||
uint256 m;
|
||||
memcpy(m.begin(), begin(), size());
|
||||
return m;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "uint256.h"
|
||||
#include <string>
|
||||
|
||||
extern uint160 protobufTo160(const std::string& buf);
|
||||
extern uint256 protobufTo256(const std::string& hash);
|
||||
extern uint160 humanTo160(const std::string& buf);
|
||||
extern bool humanToPK(const std::string& buf,std::vector<unsigned char>& retVec);
|
||||
|
||||
|
||||
extern bool u160ToHuman(uint160& buf, std::string& retStr);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "../obj/src/newcoin.pb.h"
|
||||
#include "PackedMessage.h"
|
||||
#include "Config.h"
|
||||
#include "Conversion.h"
|
||||
#include "BitcoinUtil.h"
|
||||
#include "Wallet.h"
|
||||
#include "LedgerTiming.h"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "NewcoinAddress.h"
|
||||
#include "Conversion.h"
|
||||
#include "Log.h"
|
||||
|
||||
uint32 LedgerMaster::getCurrentLedgerIndex()
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "Peer.h"
|
||||
#include "Config.h"
|
||||
#include "Application.h"
|
||||
#include "Conversion.h"
|
||||
#include "SerializedTransaction.h"
|
||||
#include "utils.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "Application.h"
|
||||
#include "RPC.h"
|
||||
#include "Wallet.h"
|
||||
#include "Conversion.h"
|
||||
#include "NewcoinAddress.h"
|
||||
#include "AccountState.h"
|
||||
#include "NicknameState.h"
|
||||
@@ -15,9 +14,6 @@
|
||||
#include "RippleLines.h"
|
||||
|
||||
#include "Pathfinder.h"
|
||||
#include "Conversion.h"
|
||||
|
||||
extern uint160 humanTo160(const std::string& buf);
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -1783,7 +1779,7 @@ Json::Value RPCServer::doSend(const Json::Value& params)
|
||||
// Destination exists, ordinary send.
|
||||
|
||||
STPathSet spsPaths;
|
||||
|
||||
/*
|
||||
uint160 srcCurrencyID;
|
||||
bool ret_b;
|
||||
ret_b = false;
|
||||
@@ -1793,7 +1789,7 @@ Json::Value RPCServer::doSend(const Json::Value& params)
|
||||
|
||||
ret_b = pf.findPaths(5, 1, spsPaths);
|
||||
// TODO: Nope; the above can't be right
|
||||
|
||||
*/
|
||||
trans = Transaction::sharedPayment(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
@@ -2544,7 +2540,7 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
{ "data_fetch", &RPCServer::doDataFetch, 1, 1, true },
|
||||
{ "data_store", &RPCServer::doDataStore, 2, 2, true },
|
||||
{ "ledger", &RPCServer::doLedger, 0, 2, false, optNetwork },
|
||||
{ "logrotate", &RPCServer::doLogRotate, 0, 0, true, optCurrent },
|
||||
{ "logrotate", &RPCServer::doLogRotate, 0, 0, false, optCurrent },
|
||||
{ "nickname_info", &RPCServer::doNicknameInfo, 1, 1, false, optCurrent },
|
||||
{ "nickname_set", &RPCServer::doNicknameSet, 2, 3, false, optCurrent },
|
||||
{ "offer_create", &RPCServer::doOfferCreate, 9, 10, false, optCurrent },
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// XXX Want a limit of 2000 validators.
|
||||
|
||||
#include "Application.h"
|
||||
#include "Conversion.h"
|
||||
#include "HttpsClient.h"
|
||||
#include "Log.h"
|
||||
#include "ParseSection.h"
|
||||
|
||||
187
src/uint256.h
187
src/uint256.h
@@ -386,96 +386,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// uint160
|
||||
//
|
||||
|
||||
class uint160 : public base_uint160
|
||||
{
|
||||
public:
|
||||
typedef base_uint160 basetype;
|
||||
|
||||
uint160()
|
||||
{
|
||||
zero();
|
||||
}
|
||||
|
||||
uint160(const basetype& b)
|
||||
{
|
||||
*this = b;
|
||||
}
|
||||
|
||||
uint160& operator=(const basetype& b)
|
||||
{
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
pn[i] = b.pn[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint160(uint64 b)
|
||||
{
|
||||
*this = b;
|
||||
}
|
||||
|
||||
uint160& operator=(uint64 uHost)
|
||||
{
|
||||
zero();
|
||||
|
||||
// Put in least significant bits.
|
||||
((uint64_t *) end())[-1] = htobe64(uHost);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
explicit uint160(const std::string& str)
|
||||
{
|
||||
SetHex(str);
|
||||
}
|
||||
|
||||
explicit uint160(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
if (vch.size() == sizeof(pn))
|
||||
memcpy(pn, &vch[0], sizeof(pn));
|
||||
else
|
||||
zero();
|
||||
}
|
||||
|
||||
base_uint256 to256() const;
|
||||
};
|
||||
|
||||
inline bool operator==(const uint160& a, uint64 b) { return (base_uint160)a == b; }
|
||||
inline bool operator!=(const uint160& a, uint64 b) { return (base_uint160)a != b; }
|
||||
|
||||
inline const uint160 operator^(const base_uint160& a, const base_uint160& b) { return uint160(a) ^= b; }
|
||||
inline const uint160 operator&(const base_uint160& a, const base_uint160& b) { return uint160(a) &= b; }
|
||||
inline const uint160 operator|(const base_uint160& a, const base_uint160& b) { return uint160(a) |= b; }
|
||||
|
||||
inline bool operator==(const base_uint160& a, const uint160& b) { return (base_uint160)a == (base_uint160)b; }
|
||||
inline bool operator!=(const base_uint160& a, const uint160& b) { return (base_uint160)a != (base_uint160)b; }
|
||||
inline const uint160 operator^(const base_uint160& a, const uint160& b) { return (base_uint160)a ^ (base_uint160)b; }
|
||||
inline const uint160 operator&(const base_uint160& a, const uint160& b) { return (base_uint160)a & (base_uint160)b; }
|
||||
inline const uint160 operator|(const base_uint160& a, const uint160& b) { return (base_uint160)a | (base_uint160)b; }
|
||||
|
||||
inline bool operator==(const uint160& a, const base_uint160& b) { return (base_uint160)a == (base_uint160)b; }
|
||||
inline bool operator!=(const uint160& a, const base_uint160& b) { return (base_uint160)a != (base_uint160)b; }
|
||||
inline const uint160 operator^(const uint160& a, const base_uint160& b) { return (base_uint160)a ^ (base_uint160)b; }
|
||||
inline const uint160 operator&(const uint160& a, const base_uint160& b) { return (base_uint160)a & (base_uint160)b; }
|
||||
inline const uint160 operator|(const uint160& a, const base_uint160& b) { return (base_uint160)a | (base_uint160)b; }
|
||||
inline bool operator==(const uint160& a, const uint160& b) { return (base_uint160)a == (base_uint160)b; }
|
||||
inline bool operator!=(const uint160& a, const uint160& b) { return (base_uint160)a != (base_uint160)b; }
|
||||
inline const uint160 operator^(const uint160& a, const uint160& b) { return (base_uint160)a ^ (base_uint160)b; }
|
||||
inline const uint160 operator&(const uint160& a, const uint160& b) { return (base_uint160)a & (base_uint160)b; }
|
||||
inline const uint160 operator|(const uint160& a, const uint160& b) { return (base_uint160)a | (base_uint160)b; }
|
||||
|
||||
extern std::size_t hash_value(const uint160&);
|
||||
|
||||
inline const std::string strHex(const uint160& ui)
|
||||
{
|
||||
return strHex(ui.begin(), ui.size());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// uint256
|
||||
@@ -694,5 +604,102 @@ inline int Testuint256AdHoc(std::vector<std::string> vArg)
|
||||
return (0);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// uint160
|
||||
//
|
||||
|
||||
class uint160 : public base_uint160
|
||||
{
|
||||
public:
|
||||
typedef base_uint160 basetype;
|
||||
|
||||
uint160()
|
||||
{
|
||||
zero();
|
||||
}
|
||||
|
||||
uint160(const basetype& b)
|
||||
{
|
||||
*this = b;
|
||||
}
|
||||
|
||||
uint160& operator=(const basetype& b)
|
||||
{
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
pn[i] = b.pn[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint160(uint64 b)
|
||||
{
|
||||
*this = b;
|
||||
}
|
||||
|
||||
uint160& operator=(uint64 uHost)
|
||||
{
|
||||
zero();
|
||||
|
||||
// Put in least significant bits.
|
||||
((uint64_t *) end())[-1] = htobe64(uHost);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
explicit uint160(const std::string& str)
|
||||
{
|
||||
SetHex(str);
|
||||
}
|
||||
|
||||
explicit uint160(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
if (vch.size() == sizeof(pn))
|
||||
memcpy(pn, &vch[0], sizeof(pn));
|
||||
else
|
||||
zero();
|
||||
}
|
||||
|
||||
base_uint256 to256() const
|
||||
{
|
||||
uint256 m;
|
||||
memcpy(m.begin(), begin(), size());
|
||||
return m;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
inline bool operator==(const uint160& a, uint64 b) { return (base_uint160)a == b; }
|
||||
inline bool operator!=(const uint160& a, uint64 b) { return (base_uint160)a != b; }
|
||||
|
||||
inline const uint160 operator^(const base_uint160& a, const base_uint160& b) { return uint160(a) ^= b; }
|
||||
inline const uint160 operator&(const base_uint160& a, const base_uint160& b) { return uint160(a) &= b; }
|
||||
inline const uint160 operator|(const base_uint160& a, const base_uint160& b) { return uint160(a) |= b; }
|
||||
|
||||
inline bool operator==(const base_uint160& a, const uint160& b) { return (base_uint160)a == (base_uint160)b; }
|
||||
inline bool operator!=(const base_uint160& a, const uint160& b) { return (base_uint160)a != (base_uint160)b; }
|
||||
inline const uint160 operator^(const base_uint160& a, const uint160& b) { return (base_uint160)a ^ (base_uint160)b; }
|
||||
inline const uint160 operator&(const base_uint160& a, const uint160& b) { return (base_uint160)a & (base_uint160)b; }
|
||||
inline const uint160 operator|(const base_uint160& a, const uint160& b) { return (base_uint160)a | (base_uint160)b; }
|
||||
|
||||
inline bool operator==(const uint160& a, const base_uint160& b) { return (base_uint160)a == (base_uint160)b; }
|
||||
inline bool operator!=(const uint160& a, const base_uint160& b) { return (base_uint160)a != (base_uint160)b; }
|
||||
inline const uint160 operator^(const uint160& a, const base_uint160& b) { return (base_uint160)a ^ (base_uint160)b; }
|
||||
inline const uint160 operator&(const uint160& a, const base_uint160& b) { return (base_uint160)a & (base_uint160)b; }
|
||||
inline const uint160 operator|(const uint160& a, const base_uint160& b) { return (base_uint160)a | (base_uint160)b; }
|
||||
inline bool operator==(const uint160& a, const uint160& b) { return (base_uint160)a == (base_uint160)b; }
|
||||
inline bool operator!=(const uint160& a, const uint160& b) { return (base_uint160)a != (base_uint160)b; }
|
||||
inline const uint160 operator^(const uint160& a, const uint160& b) { return (base_uint160)a ^ (base_uint160)b; }
|
||||
inline const uint160 operator&(const uint160& a, const uint160& b) { return (base_uint160)a & (base_uint160)b; }
|
||||
inline const uint160 operator|(const uint160& a, const uint160& b) { return (base_uint160)a | (base_uint160)b; }
|
||||
|
||||
extern std::size_t hash_value(const uint160&);
|
||||
|
||||
inline const std::string strHex(const uint160& ui)
|
||||
{
|
||||
return strHex(ui.begin(), ui.size());
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
Reference in New Issue
Block a user