Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2012-05-15 17:32:49 -07:00
16 changed files with 316 additions and 190 deletions

View File

@@ -54,6 +54,6 @@ double Amount::getDisplayQuantity() const
{
if(!mCurrency.isNational()) throw std::runtime_error("Can only scale national currencies");
int scale=mCurrency.getScale();
return static_cast<double>(mQuantity) * pow(10, 128-scale);
return static_cast<double>(mQuantity) * pow((double)10, 128-scale);
}

View File

@@ -18,17 +18,17 @@
enum LedgerStateParms
{
lepNONE = 0, // no special flags
lepNONE = 0, // no special flags
// input flags
lepCREATE, // Create if not present
lepCREATE = 1, // Create if not present
// output flags
lepOKAY, // success
lepMISSING, // No node in that slot
lepWRONGTYPE, // Node of different type there
lepCREATED, // Node was created
lepERROR, // error
lepOKAY = 2, // success
lepMISSING = 4, // No node in that slot
lepWRONGTYPE = 8, // Node of different type there
lepCREATED = 16, // Node was created
lepERROR = 32, // error
};
class Ledger : public boost::enable_shared_from_this<Ledger>

View File

@@ -55,11 +55,11 @@ LedgerEntryFormat LedgerFormats[]=
LedgerEntryFormat* getLgrFormat(LedgerEntryType t)
{
LedgerEntryFormat* f=LedgerFormats;
while(f->t_name!=NULL)
LedgerEntryFormat* f = LedgerFormats;
while(f->t_name != NULL)
{
if(f->t_type==t) return f;
f++;
if(f->t_type == t) return f;
++f;
}
return NULL;
}

View File

@@ -8,6 +8,9 @@
bool AddSystemEntropy()
{ // Get entropy from the Windows crypto provider
RAND_screen(); // this isn't really that safe since it only works for end users not servers
/* TODO: you need the cryptoAPI installed I think for the below to work. I suppose we should require people to install this to build the windows version
char name[512], rand[128];
DWORD count = 500;
HCRYPTOPROV cryptoHandle;
@@ -39,6 +42,8 @@ bool AddSystemEntropy()
CryptReleaseContext(cryptoHandle, 0);
RAND_seed(rand, 128);
*/
return true;
}

View File

@@ -4,6 +4,7 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <iostream>
#include "Serializer.h"
#include "BitcoinUtil.h"

View File

@@ -6,7 +6,7 @@
#include <boost/smart_ptr/make_shared.hpp>
#include <openssl/sha.h>
#include <iostream>
#include "Serializer.h"
#include "BitcoinUtil.h"
#include "SHAMap.h"

View File

@@ -4,7 +4,7 @@
#include <boost/make_shared.hpp>
#include <openssl/rand.h>
#include <iostream>
#include "SHAMap.h"
void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint256>& hashes, int max)

View File

@@ -117,7 +117,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
if ((flags&elem->e_flags) == 0)
{
done = true;
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
}
}
else if (elem->e_type == SOE_IFNFLAG)
@@ -126,7 +126,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
if ((flags&elem->e_flags) != 0)
{
done = true;
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
}
}
else if (elem->e_type == SOE_FLAGS)

View File

@@ -191,12 +191,13 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
// WRITEME: Special case code for changing transaction key
for (std::vector<AffectedAccount>::iterator it=accounts.begin(), end=accounts.end();
it != end; ++it)
{ if (it->first == taaCREATE)
{
if (it->first == taaCREATE)
{
if (mLedger->writeBack(lepCREATE, it->second) & lepERROR)
assert(false);
}
else if (it->first==taaMODIFY)
else if (it->first == taaMODIFY)
{
if (mLedger->writeBack(lepNONE, it->second) & lepERROR)
assert(false);
@@ -235,7 +236,7 @@ TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction&
}
LedgerStateParms qry = lepNONE;
SerializedLedgerEntry::pointer dest = mLedger->getAccountRoot(qry, sourceAccountID);
SerializedLedgerEntry::pointer dest = accounts[0].second;
if (!dest)
{
@@ -271,8 +272,6 @@ TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction&
// Set the public key needed to use the account.
dest->setIFieldH160(sfAuthorizedKey, hGeneratorID);
accounts.push_back(std::make_pair(taaMODIFY, dest));
// Construct a generator map entry.
gen = boost::make_shared<SerializedLedgerEntry>(ltGENERATOR_MAP);
@@ -295,6 +294,8 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Does the destination account exist?
if (!destAccount) return tenINVALID;
LedgerStateParms qry = lepNONE;
// FIXME: If this transfer is to the same account, bad things will happen
SerializedLedgerEntry::pointer dest = mLedger->getAccountRoot(qry, destAccount);
if (!dest)
{ // can this transaction create an account

View File

@@ -55,11 +55,11 @@ TransactionFormat InnerTxnFormats[]=
TransactionFormat* getTxnFormat(TransactionType t)
{
TransactionFormat* f=InnerTxnFormats;
while(f->t_name!=NULL)
TransactionFormat* f = InnerTxnFormats;
while(f->t_name != NULL)
{
if(f->t_type==t) return f;
f++;
if(f->t_type == t) return f;
++f;
}
return NULL;
}

View File

@@ -124,7 +124,7 @@ int main(int argc, char* argv[])
pvCmd.push_back(const_cast<char*>(param.c_str()));
}
iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]);
// iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]);
}
else if (!vm.count("parameters"))
{