More work on the SHAMap/Serialize classes.

This commit is contained in:
JoelKatz
2011-11-17 18:11:11 -08:00
parent e7bae43261
commit 477b2df276
5 changed files with 88 additions and 24 deletions

View File

@@ -83,6 +83,14 @@ bool Serializer::get256(uint256& o, int offset) const
return true;
}
uint256 Serializer::get256(int offset) const
{
uint256 ret;
if((offset+sizeof(ret))>mData.size()) return ret;
memcpy(&ret, &(mData.front())+offset, sizeof(ret));
return ret;
}
bool Serializer::getRaw(std::vector<unsigned char>& o, int offset, int length) const
{
if((offset+length)>mData.size()) return false;
@@ -90,6 +98,14 @@ bool Serializer::getRaw(std::vector<unsigned char>& o, int offset, int length) c
return true;
}
std::vector<unsigned char> Serializer::getRaw(int offset, int length) const
{
std::vector<unsigned char> o;
if((offset+length)>mData.size()) return o;
o.assign(mData.begin()+offset, mData.begin()+offset+length);
return o;
}
uint160 Serializer::getRIPEMD160(int size) const
{
uint160 ret;
@@ -141,3 +157,8 @@ bool Serializer::addSignature(CKey& key)
addRaw(signature);
return true;
}
void Serializer::TestSerializer(void)
{
Serializer s(64);
}