Bugfixes.

This commit is contained in:
JoelKatz
2011-12-15 12:44:29 -08:00
parent a58e2ec5ca
commit c7f890ab47
10 changed files with 16 additions and 10 deletions

View File

@@ -29,8 +29,8 @@ public:
uint64 getBalance() const { return mBalance; } uint64 getBalance() const { return mBalance; }
uint32 getSeq() const { return mAccountSeq; } uint32 getSeq() const { return mAccountSeq; }
bool credit(uint64 a) { mBalance+=a; } void credit(const uint64& a) { mBalance+=a; }
bool charge(uint64 a) { assert(mBalance>=a); mBalance-=a; } void charge(const uint64& a) { assert(mBalance>=a); mBalance-=a; }
void incSeq() { mAccountSeq++; } void incSeq() { mAccountSeq++; }
void decSeq() { assert(mAccountSeq!=0); mAccountSeq--; } void decSeq() { assert(mAccountSeq!=0); mAccountSeq--; }

View File

@@ -36,8 +36,8 @@ Ledger::Ledger(const uint256 &parentHash, const uint256 &transHash, const uint25
} }
Ledger::Ledger(Ledger &prevLedger, uint64 ts) : mTimeStamp(ts), Ledger::Ledger(Ledger &prevLedger, uint64 ts) : mTimeStamp(ts),
mTransactionMap(new SHAMap()), mAccountStateMap(prevLedger.mAccountStateMap), mClosed(false), mValidHash(false), mAccepted(false),
mClosed(false), mValidHash(false), mAccepted(false) mTransactionMap(new SHAMap()), mAccountStateMap(prevLedger.mAccountStateMap)
{ {
mParentHash=prevLedger.getHash(); mParentHash=prevLedger.getHash();
mLedgerSeq=prevLedger.mLedgerSeq+1; mLedgerSeq=prevLedger.mLedgerSeq+1;
@@ -227,6 +227,7 @@ Ledger::TransResult Ledger::removeTransaction(Transaction::pointer trans)
} }
updateAccountState(fromAccount); updateAccountState(fromAccount);
updateAccountState(toAccount); updateAccountState(toAccount);
return TR_SUCCESS;
} }
catch (SHAMapException) catch (SHAMapException)
{ {

View File

@@ -69,7 +69,7 @@ public:
void setClosed() { mClosed=true; } void setClosed() { mClosed=true; }
void setAccepted() { mAccepted=true; } void setAccepted() { mAccepted=true; }
bool isClosed() { return mClosed; } bool isClosed() { return mClosed; }
bool isAccepted() { mAccepted=true; } bool isAccepted() { return mAccepted; }
// ledger signature operations // ledger signature operations
void addRaw(Serializer &s); void addRaw(Serializer &s);

View File

@@ -267,6 +267,7 @@ SHAMapItem::pointer SHAMap::lastBelow(SHAMapInnerNode::pointer node)
return mLeaf->lastItem(); return mLeaf->lastItem();
} }
} }
return SHAMapItem::pointer();
} }
SHAMapItem::pointer SHAMap::peekNextItem(const uint256& id) SHAMapItem::pointer SHAMap::peekNextItem(const uint256& id)
@@ -478,6 +479,7 @@ bool SHAMap::fetchNode(const uint256& hash, std::vector<unsigned char>& data)
HashedObject::pointer obj(HashedObject::retrieve(hash)); HashedObject::pointer obj(HashedObject::retrieve(hash));
if(!obj) return false; if(!obj) return false;
data=obj->getData(); data=obj->getData();
return true;
} }
int SHAMap::flushDirty(int maxNodes, HashedObjectType t, uint32 seq) int SHAMap::flushDirty(int maxNodes, HashedObjectType t, uint32 seq)

View File

@@ -126,7 +126,7 @@ private:
protected: protected:
bool addUpdateItem(SHAMapItem::pointer); bool addUpdateItem(SHAMapItem::pointer);
bool delItem(const SHAMapItem::pointer i) { delItem(i->getTag()); } bool delItem(const SHAMapItem::pointer i) { return delItem(i->getTag()); }
bool delItem(const uint256& tag); bool delItem(const uint256& tag);
public: public:

View File

@@ -45,6 +45,7 @@ public:
mValid=true; mValid=true;
sl.mValid=false; sl.mValid=false;
} }
return *this;
} }
}; };

View File

@@ -59,7 +59,9 @@ int Serializer::addRaw(const std::vector<unsigned char> &vector)
int Serializer::addRaw(const void *ptr, int len) int Serializer::addRaw(const void *ptr, int len)
{ {
int ret=mData.size();
mData.insert(mData.end(), (const char *) ptr, ((const char *)ptr)+len); mData.insert(mData.end(), (const char *) ptr, ((const char *)ptr)+len);
return ret;
} }
bool Serializer::get16(uint16& o, int offset) const bool Serializer::get16(uint16& o, int offset) const

View File

@@ -4,7 +4,7 @@
#include <string> #include <string>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
LocalAccount::LocalAccount(bool) : mAmount(0), mSeqNum(0), mPublicKey(new CKey()) LocalAccount::LocalAccount(bool) : mPublicKey(new CKey()), mAmount(0), mSeqNum(0)
{ {
mPrivateKey.MakeNewKey(); mPrivateKey.MakeNewKey();
mPublicKey->SetPubKey(mPrivateKey.GetPubKey()); mPublicKey->SetPubKey(mPrivateKey.GetPubKey());

View File

@@ -1,6 +1,6 @@
#include "database.h" #include "database.h"
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <string.h>
Database::Database(const char* host,const char* user,const char* pass) : mNumCol(0) Database::Database(const char* host,const char* user,const char* pass) : mNumCol(0)
@@ -82,7 +82,7 @@ bool Database::getColNumber(const char* colName,int* retIndex)
{ {
for(unsigned int n=0; n<mColNameTable.size(); n++) for(unsigned int n=0; n<mColNameTable.size(); n++)
{ {
if(strcasecmp(colName,mColNameTable[n].c_str())==0) if(strcmp(colName,mColNameTable[n].c_str())==0)
{ {
*retIndex=n; *retIndex=n;
return(true); return(true);

View File

@@ -204,7 +204,7 @@ public:
base_uint& operator--() base_uint& operator--()
{ {
// prefix operator // prefix operator
int i = 0; unsigned i = 0;
while (--pn[i] == -1 && i < WIDTH-1) while (--pn[i] == -1 && i < WIDTH-1)
i++; i++;
return *this; return *this;