Mixes for Privacy and Anonymity in the Internet
|
Public Member Functions | |
SINT32 | storeCostConfirmation (CAXMLCostConfirmation &cc, UINT8 *ccCascade) |
Creates the tables we need in the DB. More... | |
SINT32 | getCostConfirmation (UINT64 accountNumber, UINT8 *cascadeId, CAXMLCostConfirmation **pCC, bool &a_bSettled) |
SINT32 | getUnsettledCostConfirmations (CAXMLCostConfirmation ***resultCCs, UINT8 *cascadeId, UINT32 *nrOfCCs, UINT32 a_maxCCs) |
Fills the CAQueue with all non-settled cost confirmations. More... | |
SINT32 | markAsSettled (UINT64 accountNumber, UINT8 *cascadeId, UINT64 a_transferredBytes) |
Marks this account as settled. More... | |
SINT32 | deleteCC (UINT64 accountNumber, UINT8 *cascadeId) |
if the BI reports an error while trying to settle a CC, this will be called to delete it from the database (otherwise the AI would try forever in vain to settle the unusable CC) More... | |
SINT32 | storePrepaidAmount (UINT64 accountNumber, SINT32 prepaidBytes, UINT8 *cascadeId) |
SINT32 | getPrepaidAmount (UINT64 accountNumber, UINT8 *cascadeId, bool a_bDelete) |
SINT32 | storeAccountStatus (UINT64 a_accountNumber, UINT32 a_statusCode) |
SINT32 | getAccountStatus (UINT64 a_accountNumber, UINT32 &a_statusCode) |
SINT32 | clearAccountStatus (UINT64 a_accountNumber) |
SINT32 | checkCountAllQuery (UINT8 *a_query, UINT32 &r_count) |
Takes and executes a query that counts databae records and tests if the result is valid. More... | |
Static Public Member Functions | |
static CAAccountingDBInterface * | getConnection () |
static SINT32 | releaseConnection (CAAccountingDBInterface *dbIf) |
static SINT32 | init () |
static SINT32 | cleanup () |
Private Member Functions | |
CAAccountingDBInterface () | |
Constructor. More... | |
~CAAccountingDBInterface () | |
Destructor. More... | |
SINT32 | __storeCostConfirmation (CAXMLCostConfirmation &cc, UINT8 *ccCascade) |
stores a cost confirmation in the DB More... | |
SINT32 | __getCostConfirmation (UINT64 accountNumber, UINT8 *cascadeId, CAXMLCostConfirmation **pCC, bool &a_bSettled) |
Gets the latest cost confirmation stored for the given user account. More... | |
SINT32 | __getUnsettledCostConfirmations (CAXMLCostConfirmation ***resultCCs, UINT8 *cascadeId, UINT32 *nrOfCCs, UINT32 a_maxCCs) |
Fills the CAQueue with pointer to all non-settled cost confirmations. More... | |
SINT32 | __markAsSettled (UINT64 accountNumber, UINT8 *cascadeId, UINT64 a_transferredBytes) |
Marks this account as settled. More... | |
SINT32 | __deleteCC (UINT64 accountNumber, UINT8 *cascadeId) |
SINT32 | __storePrepaidAmount (UINT64 accountNumber, SINT32 prepaidBytes, UINT8 *cascadeId) |
SINT32 | __getPrepaidAmount (UINT64 accountNumber, UINT8 *cascadeId, bool a_bDelete) |
SINT32 | __storeAccountStatus (UINT64 a_accountNumber, UINT32 a_statusCode) |
SINT32 | __getAccountStatus (UINT64 a_accountNumber, UINT32 &a_statusCode) |
SINT32 | __clearAccountStatus (UINT64 a_accountNumber) |
SINT32 | __checkCountAllQuery (UINT8 *a_query, UINT32 &r_count) |
SINT32 | initDBConnection () |
Initiates the database connection. More... | |
SINT32 | terminateDBConnection () |
Terminates the database connection. More... | |
bool | isDBConnected () |
bool | checkConnectionStatus () |
Checks if the connection still exists and tries to reconnect if not. More... | |
bool | checkOwner () |
bool | testAndSetOwner () |
bool | testAndResetOwner () |
PGresult * | monitored_PQexec (PGconn *conn, const char *query) |
Private Attributes | |
PGconn * | m_dbConn |
connection to postgreSQL database More... | |
bool | m_bConnected |
volatile thread_id_t | m_owner |
volatile bool | m_free |
int | m_protocolVersion |
CAMutex * | m_pConnectionMutex |
Static Private Attributes | |
static CAConditionVariable * | ms_pConnectionAvailable = NULL |
static volatile UINT64 | ms_threadWaitNr = 0 |
static volatile UINT64 | ms_nextThreadNr = 0 |
static CAAccountingDBInterface * | ms_pDBConnectionPool [] |
Friends | |
class | CAAccountingInstance |
This class is used to store cost confirmations in a postgresql database
|
private |
Constructor.
References m_bConnected, m_dbConn, m_free, m_owner, and m_pConnectionMutex.
Referenced by init().
|
private |
Destructor.
References m_pConnectionMutex, and terminateDBConnection().
References E_SUCCESS, E_UNKNOWN, m_dbConn, monitored_PQexec(), and CAMsg::printMsg().
Referenced by __storeAccountStatus(), __storeCostConfirmation(), __storePrepaidAmount(), and checkCountAllQuery().
References ACCOUNT_NUMBER_SIZE, E_SUCCESS, E_UNKNOWN, m_dbConn, MAX_ACCOUNTNUMBER, MIN_ACCOUNTNUMBER, monitored_PQexec(), CAMsg::printMsg(), and STMT_CLEAR_ACCOUNT_STATUS.
Referenced by clearAccountStatus().
References checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, m_dbConn, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by deleteCC().
|
private |
References checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, CAXMLErrorMessage::ERR_OK, m_dbConn, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by getAccountStatus().
|
private |
Gets the latest cost confirmation stored for the given user account.
accountNumber | the account for which the cost confirmation is requested |
pCC | on return contains a pointer to the Cost confirmation (the caller is responsible for deleting this object), NULL in case of an error |
E_SUCCESS,if | everything is OK |
E_NOT_CONNECTED,if | the DB query could not be executed |
E_NOT_FOUND,if | there was no XMLCC found |
E_UNKOWN | in case of a general error |
References checkConnectionStatus(), E_NOT_CONNECTED, E_NOT_FOUND, E_SUCCESS, E_UNKNOWN, m_dbConn, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by getCostConfirmation().
|
private |
References checkConnectionStatus(), E_NOT_CONNECTED, E_UNKNOWN, m_dbConn, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by getPrepaidAmount().
|
private |
Fills the CAQueue with pointer to all non-settled cost confirmations.
The caller is responsible for deleating this cost confirmations.
E_NOT_CONNECTED | if a connection to the DB could not be established |
E_UNKNOWN | in case of a general error |
E_SUCCESS | : database operation completed successfully (but queue might still be empty if there were no unsettled cost confirmation to find). Param: cascadeId : String identifier of a cascade for which to return the cost confirmations (concatenated hashes of all the cascade's mixes' price certs) |
References checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, m_dbConn, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, and CAMsg::printMsg().
Referenced by getUnsettledCostConfirmations().
|
private |
Marks this account as settled.
E_NOT_CONNECTED | if a connection to the DB could not be established |
E_UNKNOWN | in case of a general error |
References checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, m_dbConn, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, and print64().
Referenced by markAsSettled().
|
private |
References __checkCountAllQuery(), checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, len, m_dbConn, max, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by storeAccountStatus().
|
private |
stores a cost confirmation in the DB
References __checkCountAllQuery(), checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, len, m_dbConn, max, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by storeCostConfirmation().
|
private |
References __checkCountAllQuery(), checkConnectionStatus(), E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, len, m_dbConn, max, monitored_PQexec(), MONITORING_FIRE_PAY_EVENT, print64(), and CAMsg::printMsg().
Referenced by storePrepaidAmount().
|
private |
Checks if the connection still exists and tries to reconnect if not.
References m_bConnected, m_dbConn, CAMsg::printMsg(), and terminateDBConnection().
Referenced by __deleteCC(), __getAccountStatus(), __getCostConfirmation(), __getPrepaidAmount(), __getUnsettledCostConfirmations(), __markAsSettled(), __storeAccountStatus(), __storeCostConfirmation(), __storePrepaidAmount(), getConnection(), and monitored_PQexec().
Takes and executes a query that counts databae records and tests if the result is valid.
a_query | a query that should return the count of database rows |
r_count | number of database rows; only valid if E_SUCCESS is returned |
References __checkCountAllQuery(), checkOwner(), and E_UNKNOWN.
|
private |
References CAThread::getSelfID(), CAMutex::lock(), m_free, m_owner, m_pConnectionMutex, and CAMutex::unlock().
Referenced by checkCountAllQuery(), clearAccountStatus(), deleteCC(), getAccountStatus(), getCostConfirmation(), getPrepaidAmount(), getUnsettledCostConfirmations(), markAsSettled(), storeAccountStatus(), storeCostConfirmation(), and storePrepaidAmount().
|
static |
References E_SUCCESS, MAX_DB_CONNECTIONS, ms_pConnectionAvailable, ms_pDBConnectionPool, CAMsg::printMsg(), and terminateDBConnection().
Referenced by CAFirstMix::clean(), and CACmdLnOptions::setAccountingDatabase().
References __clearAccountStatus(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::__commitSettlementToDatabase(), and CAAccountingInstance::settlementTransaction().
if the BI reports an error while trying to settle a CC, this will be called to delete it from the database (otherwise the AI would try forever in vain to settle the unusable CC)
References __deleteCC(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
|
static |
References checkConnectionStatus(), E_SUCCESS, initDBConnection(), CAMutex::lock(), MAX_DB_CONNECTIONS, MONITORING_FIRE_PAY_EVENT, ms_nextThreadNr, ms_pConnectionAvailable, ms_pDBConnectionPool, ms_threadWaitNr, CAMsg::printMsg(), testAndSetOwner(), CAMutex::unlock(), and CAConditionVariable::wait().
Referenced by CAAccountingInstance::__newSettlementTransaction(), CAAccountingInstance::cleanupTableEntry(), CAAccountingInstance::finishLoginProcess(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), and CAAccountingInstance::settlementTransaction().
SINT32 CAAccountingDBInterface::getCostConfirmation | ( | UINT64 | accountNumber, |
UINT8 * | cascadeId, | ||
CAXMLCostConfirmation ** | pCC, | ||
bool & | a_bSettled | ||
) |
References __getCostConfirmation(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::handleChallengeResponse_internal(), and CAAccountingInstance::handleJapPacket_internal().
SINT32 CAAccountingDBInterface::getUnsettledCostConfirmations | ( | CAXMLCostConfirmation *** | resultCCs, |
UINT8 * | cascadeId, | ||
UINT32 * | nrOfCCs, | ||
UINT32 | a_maxCCs | ||
) |
Fills the CAQueue with all non-settled cost confirmations.
References __getUnsettledCostConfirmations(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::__newSettlementTransaction(), and CAAccountingInstance::settlementTransaction().
|
static |
|
private |
Initiates the database connection.
This function is called inside the aiThread
References E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, CACmdLnOptions::getDatabasePort(), CALibProxytest::getOptions(), m_bConnected, m_dbConn, and CAMsg::printMsg().
Referenced by getConnection(), and init().
|
private |
References m_bConnected.
SINT32 CAAccountingDBInterface::markAsSettled | ( | UINT64 | accountNumber, |
UINT8 * | cascadeId, | ||
UINT64 | a_transferredBytes | ||
) |
Marks this account as settled.
References __markAsSettled(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
|
private |
References checkConnectionStatus(), and MONITORING_FIRE_PAY_EVENT.
Referenced by __checkCountAllQuery(), __clearAccountStatus(), __deleteCC(), __getAccountStatus(), __getCostConfirmation(), __getPrepaidAmount(), __getUnsettledCostConfirmations(), __markAsSettled(), __storeAccountStatus(), __storeCostConfirmation(), and __storePrepaidAmount().
|
static |
References CAConditionVariable::broadcast(), E_SUCCESS, E_UNKNOWN, CAMutex::lock(), m_pConnectionMutex, ms_nextThreadNr, ms_pConnectionAvailable, ms_threadWaitNr, CAMsg::printMsg(), testAndResetOwner(), and CAMutex::unlock().
Referenced by CAAccountingInstance::__newSettlementTransaction(), CAAccountingInstance::cleanupTableEntry(), CAAccountingInstance::finishLoginProcess(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), and CAAccountingInstance::settlementTransaction().
References __storeAccountStatus(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
SINT32 CAAccountingDBInterface::storeCostConfirmation | ( | CAXMLCostConfirmation & | cc, |
UINT8 * | ccCascade | ||
) |
Creates the tables we need in the DB.
References __storeCostConfirmation(), checkOwner(), and E_UNKNOWN.
Referenced by CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::handleCostConfirmation_internal(), and CAAccountingInstance::settlementTransaction().
|
private |
Terminates the database connection.
References E_SUCCESS, m_bConnected, and m_dbConn.
Referenced by checkConnectionStatus(), cleanup(), and ~CAAccountingDBInterface().
|
private |
References CAThread::getSelfID(), CAMutex::lock(), m_free, m_owner, m_pConnectionMutex, and CAMutex::unlock().
Referenced by releaseConnection().
|
private |
References CAThread::getSelfID(), CAMutex::lock(), m_free, m_owner, m_pConnectionMutex, and CAMutex::unlock().
Referenced by getConnection().
|
friend |
|
private |
Referenced by CAAccountingDBInterface(), checkConnectionStatus(), initDBConnection(), isDBConnected(), and terminateDBConnection().
|
private |
connection to postgreSQL database
Referenced by __checkCountAllQuery(), __clearAccountStatus(), __deleteCC(), __getAccountStatus(), __getCostConfirmation(), __getPrepaidAmount(), __getUnsettledCostConfirmations(), __markAsSettled(), __storeAccountStatus(), __storeCostConfirmation(), __storePrepaidAmount(), CAAccountingDBInterface(), checkConnectionStatus(), initDBConnection(), and terminateDBConnection().
|
private |
Referenced by CAAccountingDBInterface(), checkOwner(), testAndResetOwner(), and testAndSetOwner().
|
private |
Referenced by CAAccountingDBInterface(), checkOwner(), testAndResetOwner(), and testAndSetOwner().
|
private |
|
private |
|
staticprivate |
Referenced by getConnection(), init(), and releaseConnection().
|
staticprivate |
Referenced by cleanup(), getConnection(), init(), and releaseConnection().
|
staticprivate |
Referenced by cleanup(), getConnection(), and init().
|
staticprivate |
Referenced by getConnection(), init(), and releaseConnection().