mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Get the databases up and running.
This commit is contained in:
@@ -44,30 +44,26 @@ Application::Application() :
|
|||||||
{
|
{
|
||||||
theConfig.load();
|
theConfig.load();
|
||||||
|
|
||||||
uint160 rootFamily=mWallet.addFamily("This is my payphrase.", true);
|
|
||||||
LocalAccount::pointer rootAccount=mWallet.getLocalAccount(rootFamily, 0);
|
|
||||||
assert(!!rootAccount);
|
|
||||||
uint160 rootAddress=rootAccount->getAddress();
|
|
||||||
assert(!!rootAddress);
|
|
||||||
|
|
||||||
Ledger::pointer firstLedger(new Ledger(rootAddress, 1000000));
|
|
||||||
firstLedger->setClosed();
|
|
||||||
firstLedger->setAccepted();
|
|
||||||
mMasterLedger.pushLedger(firstLedger);
|
|
||||||
|
|
||||||
Ledger::pointer secondLedger=firstLedger->closeLedger(time(NULL));
|
|
||||||
mMasterLedger.pushLedger(secondLedger);
|
|
||||||
mMasterLedger.setSynced();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern std::string TxnDBInit, LedgerDBInit, WalletDBInit, HashNodeDBInit, NetNodeDBInit;
|
||||||
|
|
||||||
void Application::run()
|
void Application::run()
|
||||||
{
|
{
|
||||||
mTxnDB=new DatabaseCon("transaction.db");
|
mTxnDB=new DatabaseCon("transaction.db");
|
||||||
|
mTxnDB->getDB()->executeSQL(TxnDBInit.c_str());
|
||||||
|
|
||||||
mLedgerDB=new DatabaseCon("ledger.db");
|
mLedgerDB=new DatabaseCon("ledger.db");
|
||||||
|
mLedgerDB->getDB()->executeSQL(LedgerDBInit.c_str());
|
||||||
|
|
||||||
mWalletDB=new DatabaseCon("wallet.db");
|
mWalletDB=new DatabaseCon("wallet.db");
|
||||||
|
mWalletDB->getDB()->executeSQL(WalletDBInit.c_str());
|
||||||
|
|
||||||
mHashNodeDB=new DatabaseCon("hashnode.db");
|
mHashNodeDB=new DatabaseCon("hashnode.db");
|
||||||
|
mHashNodeDB->getDB()->executeSQL(HashNodeDBInit.c_str());
|
||||||
|
|
||||||
mNetNodeDB=new DatabaseCon("netnode.db");
|
mNetNodeDB=new DatabaseCon("netnode.db");
|
||||||
|
mNetNodeDB->getDB()->executeSQL(NetNodeDBInit.c_str());
|
||||||
|
|
||||||
if(theConfig.PEER_PORT)
|
if(theConfig.PEER_PORT)
|
||||||
{
|
{
|
||||||
@@ -84,6 +80,19 @@ void Application::run()
|
|||||||
std::cout << "Before Run." << std::endl;
|
std::cout << "Before Run." << std::endl;
|
||||||
mIOService.run(); // This blocks
|
mIOService.run(); // This blocks
|
||||||
|
|
||||||
|
// TEMPORARY CODE
|
||||||
|
uint160 rootFamily=mWallet.addFamily("This is my payphrase.", true);
|
||||||
|
LocalAccount::pointer rootAccount=mWallet.getLocalAccount(rootFamily, 0);
|
||||||
|
assert(!!rootAccount);
|
||||||
|
uint160 rootAddress=rootAccount->getAddress();
|
||||||
|
assert(!!rootAddress);
|
||||||
|
Ledger::pointer firstLedger(new Ledger(rootAddress, 1000000));
|
||||||
|
firstLedger->setClosed();
|
||||||
|
firstLedger->setAccepted();
|
||||||
|
mMasterLedger.pushLedger(firstLedger);
|
||||||
|
Ledger::pointer secondLedger=firstLedger->closeLedger(time(NULL));
|
||||||
|
mMasterLedger.pushLedger(secondLedger);
|
||||||
|
mMasterLedger.setSynced();
|
||||||
// temporary
|
// temporary
|
||||||
return;
|
return;
|
||||||
mWallet.load();
|
mWallet.load();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Config::Config()
|
|||||||
RPC_USER="admin";
|
RPC_USER="admin";
|
||||||
RPC_PASSWORD="pass";
|
RPC_PASSWORD="pass";
|
||||||
|
|
||||||
DATA_DIR="";
|
DATA_DIR="db/";
|
||||||
|
|
||||||
TRANSACTION_FEE_BASE=1000;
|
TRANSACTION_FEE_BASE=1000;
|
||||||
}
|
}
|
||||||
|
|||||||
97
DBInit.cpp
Normal file
97
DBInit.cpp
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Transaction database holds transactions and public keys
|
||||||
|
std::string TxnDBInit(" \
|
||||||
|
CREATE TABLE Transactions ( \
|
||||||
|
TransID CHARACTER(64) PRIMARY KEY, \
|
||||||
|
FromAcct CHARACTER(40), \
|
||||||
|
FromSeq BIGINT UNSIGNED, \
|
||||||
|
FromLedger BIGINT UNSIGNED, \
|
||||||
|
Identifier BIGINT UNSIGNED, \
|
||||||
|
ToAcct CHARACTER(40), \
|
||||||
|
Amount BIGINT UNSIGNED, \
|
||||||
|
Fee BIGINT UNSIGNED, \
|
||||||
|
FirstSeen TEXT, \
|
||||||
|
CommitSeq BIGINT UNSIGNED, \
|
||||||
|
Status CHARACTER(1), \
|
||||||
|
Signature BLOB \
|
||||||
|
); \
|
||||||
|
\
|
||||||
|
CREATE TABLE PubKeys ( \
|
||||||
|
ID CHARACTER(40) PRIMARY KEY, \
|
||||||
|
PubKey BLOB \
|
||||||
|
); \
|
||||||
|
");
|
||||||
|
|
||||||
|
// Ledger database holds ledgers and ledger confirmations
|
||||||
|
std::string LedgerDBInit(" \
|
||||||
|
CREATE TABLE Ledgers ( \
|
||||||
|
LedgerHash CHARACTER(64) PRIMARY KEY, \
|
||||||
|
LedgerSeq BIGINT UNSIGNED, \
|
||||||
|
PrevHash CHARACTER(64), \
|
||||||
|
FeeHeld BIGINT UNSIGNED, \
|
||||||
|
ClosingTime BIGINT UNSINGED, \
|
||||||
|
AccountSetHash CHARACTER(64), \
|
||||||
|
TransSetHash CHARACTER(64) \
|
||||||
|
); \
|
||||||
|
CREATE INDEX SeqLedger ON Ledgers(LedgerSeq); \
|
||||||
|
\
|
||||||
|
CREATE TABLE LedgerConfirmations ( \
|
||||||
|
LedgerSeq BIGINT UNSIGNED, \
|
||||||
|
LedgerHash CHARACTER(64), \
|
||||||
|
Hanko CHARACTER(40), \
|
||||||
|
Signature BLOB \
|
||||||
|
); \
|
||||||
|
CREATE INDEX LedgerConfByHash ON \
|
||||||
|
LedgerConfirmations(LedgerHash); \
|
||||||
|
");
|
||||||
|
|
||||||
|
|
||||||
|
// Wallet database holds local accounts and trusted nodes
|
||||||
|
std::string WalletDBInit(" \
|
||||||
|
CREATE TABLE LocalAcctFamilies ( \
|
||||||
|
FamilyName CHARACTER(40) PRIMARY KEY, \
|
||||||
|
RootPubKey CHARACTER(66), \
|
||||||
|
Seq BIGINT UNSIGNED, \
|
||||||
|
Name TEXT, \
|
||||||
|
Comment TEXT \
|
||||||
|
); \
|
||||||
|
\
|
||||||
|
CREATE TABLE LocalAccounts ( \
|
||||||
|
ID CHARACTER(40) PRIMARY KEY, \
|
||||||
|
DKID CHARACTER(40), \
|
||||||
|
DKSeq BIGINT UNSIGNED, \
|
||||||
|
Seq BIGINT UNSIGNED, \
|
||||||
|
Balance BIGINT UNSIGNED, \
|
||||||
|
LedgerSeq BIGINT UNSIGNED, \
|
||||||
|
Comment TEXT \
|
||||||
|
); \
|
||||||
|
\
|
||||||
|
CREATE TABLE TrustedNodes ( ` \
|
||||||
|
Hanko CHARACTER(40) PRIMARY KEY, \
|
||||||
|
TrustLevel SMALLINT, \
|
||||||
|
Comment TEXT \
|
||||||
|
); \
|
||||||
|
");
|
||||||
|
|
||||||
|
// Hash node database holds nodes indexed by hash
|
||||||
|
std::string HashNodeDBInit(" \
|
||||||
|
CREATE TABLE CommittedObjects ( \
|
||||||
|
Hash CHARACTER(64) PRIMARY KEY, \
|
||||||
|
ObjType CHAR(1) NOT NULL, \
|
||||||
|
LedgerIndex BIGINT UNSIGNED, \
|
||||||
|
Object BLOB \
|
||||||
|
); \
|
||||||
|
CREATE INDEX ObjectLocate ON \
|
||||||
|
CommittedObjects(LedgerIndex, ObjType); \
|
||||||
|
");
|
||||||
|
|
||||||
|
// Net node database holds nodes seen on the network
|
||||||
|
std::string NetNodeDBInit(" \
|
||||||
|
CREATE TABLE KnownNodes ( \
|
||||||
|
Hanko CHARACTER(40) PRIMARY KEY, \
|
||||||
|
LastSeen TEXT, \
|
||||||
|
HaveContactInfo CHARACTER(1), \
|
||||||
|
ContactObject BLOB \
|
||||||
|
); \
|
||||||
|
");
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
CREATE TABLE Transactions ( -- transactions in all states
|
CREATE TABLE Transactions ( -- transactions in all states
|
||||||
TransID CHARACTER(64) PRIMARY KEY, -- in hex
|
TransID CHARACTER(64) PRIMARY KEY, -- in hex
|
||||||
FromAcct CHARACTER(40), -- 20 byte hash of pub key in hex
|
FromAcct CHARACTER(40), -- 20 byte hash of pub key in hex
|
||||||
@@ -15,13 +14,14 @@ CREATE TABLE Transactions ( -- transactions in all states
|
|||||||
Signature BLOB
|
Signature BLOB
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE PubKeys ( -- holds pub keys for nodes and accounts
|
CREATE TABLE PubKeys ( -- holds pub keys for nodes and accounts
|
||||||
ID CHARACTER(40) PRIMARY KEY,
|
ID CHARACTER(40) PRIMARY KEY,
|
||||||
PubKey BLOB
|
PubKey BLOB
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE Ledgers ( -- closed/accepted ledgers
|
CREATE TABLE Ledgers ( -- closed/accepted ledgers
|
||||||
LedgerHash CHARACTER(64) PRIMARY KEY,
|
LedgerHash CHARACTER(64) PRIMARY KEY,
|
||||||
LedgerSeq BIGINT UNSIGNED,
|
LedgerSeq BIGINT UNSIGNED,
|
||||||
@@ -29,12 +29,11 @@ CREATE TABLE Ledgers ( -- closed/accepted ledgers
|
|||||||
FeeHeld BIGINT UNSIGNED,
|
FeeHeld BIGINT UNSIGNED,
|
||||||
ClosingTime BIGINT UNSINGED,
|
ClosingTime BIGINT UNSINGED,
|
||||||
AccountSetHash CHARACTER(64),
|
AccountSetHash CHARACTER(64),
|
||||||
TransSetHash CHARACTER(64),
|
TransSetHash CHARACTER(64)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);
|
CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE LedgerConfirmations (
|
CREATE TABLE LedgerConfirmations (
|
||||||
LedgerSeq BIGINT UNSIGNED,
|
LedgerSeq BIGINT UNSIGNED,
|
||||||
LedgerHash CHARACTER(64),
|
LedgerHash CHARACTER(64),
|
||||||
@@ -45,6 +44,8 @@ CREATE TABLE LedgerConfirmations (
|
|||||||
CREATE INDEX LedgerConfByHash ON LedgerConfirmations(LedgerHash);
|
CREATE INDEX LedgerConfByHash ON LedgerConfirmations(LedgerHash);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE TrustedNodes (
|
CREATE TABLE TrustedNodes (
|
||||||
Hanko CHARACTER(40) PRIMARY KEY,
|
Hanko CHARACTER(40) PRIMARY KEY,
|
||||||
TrustLevel SMALLINT,
|
TrustLevel SMALLINT,
|
||||||
@@ -74,7 +75,7 @@ CREATE TABLE LocalAcctFamilies ( -- a family of accounts that share a payphrase
|
|||||||
Seq BIGINT UNSIGNED, -- next one to issue
|
Seq BIGINT UNSIGNED, -- next one to issue
|
||||||
Name TEXT,
|
Name TEXT,
|
||||||
Comment TEXT
|
Comment TEXT
|
||||||
)
|
);
|
||||||
|
|
||||||
CREATE TABLE LocalAccounts ( -- an individual account
|
CREATE TABLE LocalAccounts ( -- an individual account
|
||||||
ID CHARACTER(40) PRIMARY KEY,
|
ID CHARACTER(40) PRIMARY KEY,
|
||||||
@@ -85,5 +86,3 @@ CREATE TABLE LocalAccounts ( -- an individual account
|
|||||||
LedgerSeq BIGINT UNSIGNED, -- ledger this balance is from
|
LedgerSeq BIGINT UNSIGNED, -- ledger this balance is from
|
||||||
Comment TEXT
|
Comment TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNIQUE INDEX AccountLocate ON LocalAccounts(DKID, DKSeq);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user