Refactor Serializer, SerialIter, SHAMapItem, NodeObject:

* Make LessThan private
* Make NodeObject::isSame private
* Remove hotTRANSACTION
* Remove some Serializer members
* Remove unused SHAMapItem::getRaw
* Remove unused STLedgerEntry::getOwners
* Remove Serializer constructors
* Remove unused Serializer members
* Remove SerialIter ctor
This commit is contained in:
Vinnie Falco
2015-05-22 13:10:47 -07:00
parent c25184cc88
commit 8be4e7e65f
56 changed files with 220 additions and 370 deletions

View File

@@ -104,7 +104,6 @@ public:
std::uint32_t getThreadedLedger ();
bool thread (uint256 const& txID, std::uint32_t ledgerSeq, uint256 & prevTxID,
std::uint32_t & prevLedgerID);
std::vector<uint256> getOwners (); // nodes notified if this node is deleted
private:
/** Make STObject comply with the template for this SLE type

View File

@@ -47,23 +47,15 @@ public:
{
mData.reserve (n);
}
Serializer (Blob const& data) : mData (data)
Serializer (void const* data,
std::size_t size)
{
;
}
Serializer (std::string const& data) : mData (data.data (), (data.data ()) + data.size ())
{
;
}
Serializer (Blob ::iterator begin, Blob ::iterator end) :
mData (begin, end)
{
;
}
Serializer (Blob ::const_iterator begin, Blob ::const_iterator end) :
mData (begin, end)
{
;
mData.resize(size);
std::memcpy(mData.data(),
reinterpret_cast<
unsigned char const*>(
data), size);
}
Slice slice() const noexcept
@@ -118,11 +110,6 @@ public:
// disassemble functions
bool get8 (int&, int offset) const;
bool get8 (unsigned char&, int offset) const;
bool get16 (std::uint16_t&, int offset) const;
bool get32 (std::uint32_t&, int offset) const;
bool get64 (std::uint64_t&, int offset) const;
bool get128 (uint128&, int offset) const;
bool get256 (uint256&, int offset) const;
template <typename Integer>
@@ -150,8 +137,6 @@ public:
return success;
}
uint256 get256 (int offset) const;
// TODO(tom): merge with get128 and get256.
template <class Tag>
bool get160 (base_uint<160, Tag>& o, int offset) const
@@ -188,10 +173,7 @@ public:
{
return mData;
}
int getCapacity () const
{
return mData.capacity ();
}
int getDataLength () const
{
return mData.size ();
@@ -318,28 +300,6 @@ public:
{
}
// VFALCO TODO Remove this overload use Slice instead
explicit
SerialIter (std::string const& s) noexcept
: SerialIter(s.data(), s.size())
{
}
template <class T,
std::enable_if_t<std::is_integral<T>::value &&
sizeof(T) == 1>* = nullptr>
explicit
SerialIter (std::vector<T> const& v) noexcept
: SerialIter (v.data(), v.size())
{
}
// DEPRECATED
SerialIter (Serializer const& s) noexcept
: SerialIter(s.peekData())
{
}
std::size_t
empty() const noexcept
{

View File

@@ -40,8 +40,7 @@ STLedgerEntry::STLedgerEntry (
const Serializer& s, uint256 const& index)
: STObject (sfLedgerEntry), mIndex (index), mMutable (true)
{
// we know 's' isn't going away
SerialIter sit (const_cast<Serializer&> (s));
SerialIter sit (s.slice());
set (sit);
setSLEType ();
}
@@ -184,38 +183,4 @@ RippleAddress STLedgerEntry::getSecondOwner ()
return RippleAddress::createAccountID (getFieldAmount (sfHighLimit).getIssuer ());
}
std::vector<uint256> STLedgerEntry::getOwners ()
{
std::vector<uint256> owners;
Account account;
for (int i = 0, fields = getCount (); i < fields; ++i)
{
auto const& fc = getFieldSType (i);
if ((fc == sfAccount) || (fc == sfOwner))
{
auto entry = dynamic_cast<const STAccount*> (peekAtPIndex (i));
if ((entry != nullptr) && entry->getValueH160 (account))
owners.push_back (getAccountRootIndex (account));
}
if ((fc == sfLowLimit) || (fc == sfHighLimit))
{
auto entry = dynamic_cast<const STAmount*> (peekAtPIndex (i));
if ((entry != nullptr))
{
auto issuer = entry->getIssuer ();
if (issuer.isNonZero ())
owners.push_back (getAccountRootIndex (issuer));
}
}
}
return owners;
}
} // ripple

View File

@@ -106,63 +106,6 @@ int Serializer::addRaw (const void* ptr, int len)
return ret;
}
bool Serializer::get16 (std::uint16_t& o, int offset) const
{
if ((offset + 2) > mData.size ()) return false;
const unsigned char* ptr = &mData[offset];
o = *ptr++;
o <<= 8;
o |= *ptr;
return true;
}
bool Serializer::get32 (std::uint32_t& o, int offset) const
{
if ((offset + 4) > mData.size ()) return false;
const unsigned char* ptr = &mData[offset];
o = *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr;
return true;
}
bool Serializer::get64 (std::uint64_t& o, int offset) const
{
if ((offset + 8) > mData.size ()) return false;
const unsigned char* ptr = &mData[offset];
o = *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr++;
o <<= 8;
o |= *ptr;
return true;
}
bool Serializer::get128 (uint128& o, int offset) const
{
if ((offset + (128 / 8)) > mData.size ()) return false;
memcpy (o.begin (), & (mData.front ()) + offset, (128 / 8));
return true;
}
bool Serializer::get256 (uint256& o, int offset) const
{
if ((offset + (256 / 8)) > mData.size ()) return false;
@@ -171,16 +114,6 @@ bool Serializer::get256 (uint256& o, int offset) const
return true;
}
uint256 Serializer::get256 (int offset) const
{
uint256 ret;
if ((offset + (256 / 8)) > mData.size ()) return ret;
memcpy (ret.begin (), & (mData.front ()) + offset, (256 / 8));
return ret;
}
int Serializer::addFieldID (int type, int name)
{
int ret = mData.size ();

View File

@@ -33,7 +33,7 @@ public:
Serializer ser;
s.add (ser);
SerialIter sit (ser);
SerialIter sit (ser.slice());
return STAmount(sit, sfGeneric);
}

View File

@@ -183,7 +183,7 @@ public:
Serializer s;
object1.add (s);
SerialIter it (s);
SerialIter it (s.slice());
STObject object3 (elements, it, sfTestObject);

View File

@@ -46,7 +46,7 @@ public:
Serializer rawTxn;
j.add (rawTxn);
SerialIter sit (rawTxn);
SerialIter sit (rawTxn.slice());
STTx copy (sit);
if (copy != j)
@@ -150,7 +150,7 @@ public:
Serializer rawTxn;
tempTxn.add (rawTxn);
SerialIter sit (rawTxn);
SerialIter sit (rawTxn.slice());
bool serialized = false;
try
{