Account state conversion from ledger to structure forms.

This commit is contained in:
JoelKatz
2011-11-23 12:48:45 -08:00
parent 6c7fd5f195
commit 9462cd6718
2 changed files with 29 additions and 0 deletions

21
AccountState.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include "AccountState.h"
#include "Serializer.h"
AccountState::AccountState(const std::vector<unsigned char>& v)
{
Serializer s(v);
mValid=false;
if(!s.get160(mAccountID, 0)) return;
if(!s.get64(mBalance, 20)) return;
if(!s.get32(mAccountSeq, 28)) return;
mValid=true;
}
std::vector<unsigned char> AccountState::getRaw() const
{ // 20-byte acct ID, 8-byte balance, 4-byte sequence
Serializer s(32);
s.add160(mAccountID);
s.add64(mBalance);
s.add32(mAccountSeq);
return s.getData();
}