mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user