Fire up the initial ledgers and attach them to the application.

This commit is contained in:
JoelKatz
2011-12-13 21:54:17 -08:00
parent 7f9f5c5462
commit 0b25b9641f
6 changed files with 24 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
#include "PeerDoor.h"
#include "RPCDoor.h"
#include "BitcoinUtil.h"
#include "DeterministicKeys.h"
#include "database/SqliteDatabase.h"
//#include <boost/log/trivial.hpp>
#include <iostream>
@@ -29,6 +30,17 @@ Application::Application()
mWallet.load();
mPeerDoor=NULL;
mRPCDoor=NULL;
DetKeySet ks("This is a test payphrase.");
Ledger::pointer firstLedger(new Ledger(ks.getAccountID(0), 1000000));
firstLedger->setClosed();
firstLedger->setAccepted();
mMasterLedger.pushLedger(firstLedger);
Ledger::pointer secondLedger=firstLedger->closeLedger(time(NULL));
mMasterLedger.pushLedger(secondLedger);
mMasterLedger.setSynced();
}

View File

@@ -68,4 +68,4 @@ public:
extern Application* theApp;
#endif
#endif

View File

@@ -133,6 +133,11 @@ CKey::pointer DetKeySet::getPrivKey(uint32 n)
return ret;
}
uint160 DetKeySet::getAccountID(uint32 n)
{
return getPubKey(n)->GetAddress().GetHash160();
}
void DetKeySet::getPubKeys(uint32 first, uint32 count, std::list<CKey::pointer>& keys)
{
while(count-->0)

View File

@@ -27,6 +27,7 @@ public:
CKey::pointer getPubKey(uint32 n);
CKey::pointer getPrivKey(uint32 n);
uint160 getAccountID(uint32 n);
void getPubKeys(uint32 first, uint32 count, std::list<CKey::pointer>& keys);
void getPrivKeys(uint32 first, uint32 count, std::list<CKey::pointer>& keys);

View File

@@ -33,8 +33,8 @@ public:
LedgerMaster();
uint32 getCurrentLedgerIndex();
bool IsSynced() { return mIsSynced; }
void SetSynced() { mIsSynced=true; }
bool isSynced() { return mIsSynced; }
void setSynced() { mIsSynced=true; }
Ledger::pointer getCurrentLedger() { return mCurrentLedger; }
Ledger::pointer getClosingLedger() { return mFinalizingLedger; }

View File

@@ -71,7 +71,8 @@ SRCS= keystore.cpp BitcoinUtil.cpp \
AccountState.cpp Wallet.cpp NewcoinAddress.cpp Config.cpp PackedMessage.cpp \
Application.cpp TimingService.cpp KnownNodeList.cpp ConnectionPool.cpp Peer.cpp \
PeerDoor.cpp RPCDoor.cpp RPCServer.cpp rpc.cpp Conversion.cpp RequestParser.cpp HashedObject.cpp \
UniqueNodeList.cpp PubKeyCache.cpp SHAMapDiff.cpp DeterministicKeys.cpp
UniqueNodeList.cpp PubKeyCache.cpp SHAMapDiff.cpp DeterministicKeys.cpp LedgerMaster.cpp \
LedgerHistory.cpp
DBSRCS= SqliteDatabase.cpp database.cpp
@@ -94,7 +95,7 @@ all: newcoind
newcoin.pb.h: newcoin.proto
protoc --cpp_out=. newcoin.proto
%.o: %.cpp newcoin.pb.h $(HEADERS)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<