Fix some database issues.

This commit is contained in:
JoelKatz
2012-01-01 07:45:13 -08:00
parent d4a79d7c7f
commit a24e7a4c27
7 changed files with 75 additions and 70 deletions

View File

@@ -1,8 +1,8 @@
#include <string>
// Transaction database holds transactions and public keys
std::string TxnDBInit(" \
CREATE TABLE Transactions ( \
const char *TxnDBInit[] = {
"CREATE TABLE Transactions ( \
TransID CHARACTER(64) PRIMARY KEY, \
FromAcct CHARACTER(40), \
FromSeq BIGINT UNSIGNED, \
@@ -15,17 +15,17 @@ std::string TxnDBInit(" \
CommitSeq BIGINT UNSIGNED, \
Status CHARACTER(1), \
Signature BLOB \
); \
\
CREATE TABLE PubKeys ( \
);",
"CREATE TABLE PubKeys ( \
ID CHARACTER(40) PRIMARY KEY, \
PubKey BLOB \
); \
");
);" };
int TxnDBCount=sizeof(TxnDBInit)/sizeof(const char *);
// Ledger database holds ledgers and ledger confirmations
std::string LedgerDBInit(" \
CREATE TABLE Ledgers ( \
const char *LedgerDBInit[] = {
"CREATE TABLE Ledgers ( \
LedgerHash CHARACTER(64) PRIMARY KEY, \
LedgerSeq BIGINT UNSIGNED, \
PrevHash CHARACTER(64), \
@@ -33,31 +33,29 @@ std::string LedgerDBInit(" \
ClosingTime BIGINT UNSINGED, \
AccountSetHash CHARACTER(64), \
TransSetHash CHARACTER(64) \
); \
CREATE INDEX SeqLedger ON Ledgers(LedgerSeq); \
\
CREATE TABLE LedgerConfirmations ( \
);",
"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); \
");
);",
"CREATE INDEX LedgerConfByHash ON \
LedgerConfirmations(LedgerHash)l" };
int LedgerDBCount=sizeof(LedgerDBInit)/sizeof(const char *);
// Wallet database holds local accounts and trusted nodes
std::string WalletDBInit(" \
CREATE TABLE LocalAcctFamilies ( \
const char *WalletDBInit[] = {
"CREATE TABLE LocalAcctFamilies ( \
FamilyName CHARACTER(40) PRIMARY KEY, \
RootPubKey CHARACTER(66), \
Seq BIGINT UNSIGNED, \
Name TEXT, \
Comment TEXT \
); \
\
CREATE TABLE LocalAccounts ( \
);",
"CREATE TABLE LocalAccounts ( \
ID CHARACTER(40) PRIMARY KEY, \
DKID CHARACTER(40), \
DKSeq BIGINT UNSIGNED, \
@@ -65,33 +63,37 @@ std::string WalletDBInit(" \
Balance BIGINT UNSIGNED, \
LedgerSeq BIGINT UNSIGNED, \
Comment TEXT \
); \
\
CREATE TABLE TrustedNodes ( ` \
);",
"CREATE TABLE TrustedNodes ( ` \
Hanko CHARACTER(40) PRIMARY KEY, \
TrustLevel SMALLINT, \
Comment TEXT \
); \
");
);" };
int WalletDBCount=sizeof(WalletDBInit)/sizeof(const char *);
// Hash node database holds nodes indexed by hash
std::string HashNodeDBInit(" \
CREATE TABLE CommittedObjects ( \
const char *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); \
");
);",
"CREATE INDEX ObjectLocate ON \
CommittedObjects(LedgerIndex, ObjType);" };
int HashNodeDBCount=sizeof(HashNodeDBInit)/sizeof(const char *);
// Net node database holds nodes seen on the network
std::string NetNodeDBInit(" \
CREATE TABLE KnownNodes ( \
const char *NetNodeDBInit[] = {
"CREATE TABLE KnownNodes ( \
Hanko CHARACTER(40) PRIMARY KEY, \
LastSeen TEXT, \
HaveContactInfo CHARACTER(1), \
ContactObject BLOB \
); \
");
);" };
int NetNodeDBCount=sizeof(NetNodeDBInit)/sizeof(const char *);