This commit is contained in:
Christian Grothoff 2015-06-03 12:29:09 +02:00
parent 50afaadf16
commit 510c45efd6

View File

@ -264,6 +264,9 @@ postgres_create_tables (void *cls,
" ON reserves_in (expiration_date);"); " ON reserves_in (expiration_date);");
/* Table with the withdraw operations that have been performed on a reserve. /* Table with the withdraw operations that have been performed on a reserve.
TODO: maybe rename to "reserves_out"? #3810 TODO: maybe rename to "reserves_out"? #3810
TODO: maybe add timestamp of when the operation was performed, so we
can influence the reserves' expiration_date not just based on
incoming but also based on outgoing transactions?
TODO: is blind_ev really a _primary key_? Is this constraint useful? */ TODO: is blind_ev really a _primary key_? Is this constraint useful? */
SQLEXEC ("CREATE TABLE IF NOT EXISTS collectable_blindcoins" SQLEXEC ("CREATE TABLE IF NOT EXISTS collectable_blindcoins"
"(blind_ev BYTEA PRIMARY KEY" "(blind_ev BYTEA PRIMARY KEY"
@ -277,8 +280,7 @@ postgres_create_tables (void *cls,
" collectable_blindcoins (reserve_pub)"); " collectable_blindcoins (reserve_pub)");
/* Table with coins that have been (partially) spent, used to detect /* Table with coins that have been (partially) spent, used to detect
double-spending. double-spending.
TODO: maybe rename to "spent_coins"? TODO: maybe rename to "spent_coins"? (#3811) */
TODO: maybe have two tables, one for spending and one for refreshing, instead of optional refresh_session_hash? */
SQLEXEC("CREATE TABLE IF NOT EXISTS known_coins " SQLEXEC("CREATE TABLE IF NOT EXISTS known_coins "
"(coin_pub BYTEA NOT NULL PRIMARY KEY" "(coin_pub BYTEA NOT NULL PRIMARY KEY"
",denom_pub BYTEA NOT NULL REFERENCES denominations (pub)" ",denom_pub BYTEA NOT NULL REFERENCES denominations (pub)"
@ -470,26 +472,33 @@ postgres_prepare (PGconn *db_conn)
",balance_curr" ",balance_curr"
",expiration_date" ",expiration_date"
",details" ",details"
" FROM reserves_in WHERE reserve_pub=$1", " FROM reserves_in"
" WHERE reserve_pub=$1",
1, NULL); 1, NULL);
PREPARE ("insert_collectable_blindcoin", PREPARE ("insert_collectable_blindcoin",
"INSERT INTO collectable_blindcoins ( " "INSERT INTO collectable_blindcoins "
" blind_ev" "(blind_ev"
",denom_pub, denom_sig" ",denom_pub"
",reserve_pub, reserve_sig) " ",denom_sig"
"VALUES ($1, $2, $3, $4, $5)", ",reserve_pub"
",reserve_sig"
") VALUES "
"($1, $2, $3, $4, $5);",
5, NULL); 5, NULL);
PREPARE ("get_collectable_blindcoin", PREPARE ("get_collectable_blindcoin",
"SELECT " "SELECT "
" denom_pub, denom_sig" " denom_pub"
",reserve_sig, reserve_pub " ",denom_sig"
"FROM collectable_blindcoins " ",reserve_sig"
"WHERE blind_ev=$1", ",reserve_pub"
" FROM collectable_blindcoins"
" WHERE blind_ev=$1",
1, NULL); 1, NULL);
PREPARE ("get_reserves_blindcoins", PREPARE ("get_reserves_blindcoins",
"SELECT" "SELECT"
" blind_ev" " blind_ev"
",denom_pub, denom_sig" ",denom_pub"
",denom_sig"
",reserve_sig" ",reserve_sig"
" FROM collectable_blindcoins" " FROM collectable_blindcoins"
" WHERE reserve_pub=$1;", " WHERE reserve_pub=$1;",