mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -81,28 +81,31 @@ int Serializer::addRaw(const void *ptr, int len)
|
|||||||
bool Serializer::get16(uint16& o, int offset) const
|
bool Serializer::get16(uint16& o, int offset) const
|
||||||
{
|
{
|
||||||
if ((offset + 2) > mData.size()) return false;
|
if ((offset + 2) > mData.size()) return false;
|
||||||
o = mData.at(offset++);
|
const unsigned char *ptr = &mData[offset];
|
||||||
o <<= 8; o |= mData.at(offset);
|
o = *ptr++; o <<= 8; o |= *ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::get32(uint32& o, int offset) const
|
bool Serializer::get32(uint32& o, int offset) const
|
||||||
{
|
{
|
||||||
if ((offset + 4) > mData.size()) return false;
|
if ((offset + 4) > mData.size()) return false;
|
||||||
o=mData.at(offset++);
|
const unsigned char *ptr = &mData[offset];
|
||||||
o<<=8; o |= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o = *ptr++;
|
||||||
o<<=8; o |= mData.at(offset);
|
o <<= 8; o |= *ptr++;
|
||||||
|
o <<= 8; o |= *ptr++;
|
||||||
|
o <<= 8; o |= *ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::get64(uint64& o, int offset) const
|
bool Serializer::get64(uint64& o, int offset) const
|
||||||
{
|
{
|
||||||
if ((offset + 8) > mData.size()) return false;
|
if ((offset + 8) > mData.size()) return false;
|
||||||
o=mData.at(offset++);
|
const unsigned char *ptr = &mData[offset];
|
||||||
o<<=8; o|= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o = *ptr++;
|
||||||
o<<=8; o|= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o <<= 8; o |= *ptr++; o <<= 8; o |= *ptr++;
|
||||||
o<<=8; o|= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o <<= 8; o |= *ptr++; o <<= 8; o |= *ptr++;
|
||||||
o<<=8; o|= mData.at(offset);
|
o <<= 8; o |= *ptr++; o <<= 8; o |= *ptr++;
|
||||||
|
o <<= 8; o |= *ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +262,7 @@ int Serializer::addVL(const std::vector<unsigned char>& vector)
|
|||||||
{
|
{
|
||||||
int ret = addRaw(encodeVL(vector.size()));
|
int ret = addRaw(encodeVL(vector.size()));
|
||||||
addRaw(vector);
|
addRaw(vector);
|
||||||
assert(mData.size() + (ret + vector.size() + encodeLengthLength(vector.size())));
|
assert(mData.size() == (ret + vector.size() + encodeLengthLength(vector.size())));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user