Browse Source

less DEBUG flood, add an automation that triggers when there are less than 7 free spendable notes and increases their number by executing a transaction with the amount = fee by replacing a sietch transaction.

pull/139/head
Deniod 4 months ago
parent
commit
fb1626d11d
  1. 2
      src/addressbook.cpp
  2. 2
      src/chatmodel.cpp
  3. 6
      src/connection.cpp
  4. 59
      src/controller.cpp
  5. 4
      src/mainwindow.cpp

2
src/addressbook.cpp

@ -304,7 +304,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
});
auto fnSetTargetLabelAddr = [=] (QLineEdit* target, QString label, QString addr, QString myAddr, QString cid, QString avatar) {
qDebug() << __func__ << ": label=" << label << " cid=" << cid << " avatar=" << avatar;
// qDebug() << __func__ << ": label=" << label << " cid=" << cid << " avatar=" << avatar;
target->setText(label % "/" % addr % myAddr);
};

2
src/chatmodel.cpp

@ -794,7 +794,7 @@ Tx MainWindow::createTxForSafeContactRequest()
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0) {
this->logger->write("Suspicious client public contact request key, bail out ");
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_seed_keypair, aborting!";
// qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_seed_keypair, aborting!";
return tx;
}

6
src/connection.cpp

@ -34,7 +34,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc)
connD->setupUi(d);
auto theme = Settings::getInstance()->get_theme_name();
DEBUG("theme " << theme << " has loaded");
//DEBUG("theme " << theme << " has loaded");
auto size = QSize(512,512);
if (theme == "Dark" || theme == "Midnight") {
@ -57,7 +57,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc)
ConnectionLoader::~ConnectionLoader()
{
DEBUG("destroying ConnectionLoader");
// DEBUG("destroying ConnectionLoader");
delete isSyncing;
delete connD;
delete d;
@ -389,7 +389,7 @@ QString litelib_process_response(char* resp)
void Executor::run()
{
auto config = std::shared_ptr<ConnectionConfig>(new ConnectionConfig());
DEBUG("cmd=" << cmd << " args=" << args << " server=" << config->server);
//DEBUG("cmd=" << cmd << " args=" << args << " server=" << config->server);
QString response = "";
try {
char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str());

59
src/controller.cpp

@ -126,7 +126,8 @@ void Controller::setConnection(Connection* c)
ui->listChat->verticalScrollBar()->setValue(
ui->listChat->verticalScrollBar()->maximum());
fetchAndProcessUnspentNotes();
//fetch amounts of notes at startup
fetchAndProcessUnspentNotes();
}
@ -160,14 +161,15 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
DataStore::getSietchDataStore()->clear(); // clears the datastore
// Debugging, um die Daten aus NoteCountDataStore zu zeigen
int spendableNotesCount = NoteCountDataStore::getInstance()->getSpendableNotesCount();
QString addressWithMaxValue = NoteCountDataStore::getInstance()->getAddressWithMaxValue();
qDebug() << "Anzahl der spendablen Notizen über 10000:" << spendableNotesCount;
qDebug() << "Adresse mit dem höchsten Gesamtwert:" << addressWithMaxValue;
// Only for Debugging/Testing: How many free Notes are available?
int spendableNotesCount = NoteCountDataStore::getInstance()->getSpendableNotesCount();
QString addressWithMaxValue = NoteCountDataStore::getInstance()->getAddressWithMaxValue();
qDebug() << "Available notes over fee:" << spendableNotesCount;
// Clear NoteCountDataStore
DataStore::getNoteCountDataStore()->clear();
const QString possibleCharacters("0123456789abcdef");
int sizerandomString = 512;
const int randomStringLength = sizerandomString;
@ -186,10 +188,40 @@ qDebug() << "Adresse mit dem höchsten Gesamtwert:" << addressWithMaxValue;
}
for(auto &it: dust)
{
// Create more Notes if spendableNotesCount < 7
bool extraTransactionAdded = false;
if (spendableNotesCount < 7) {
// Create a random memo for that
QString randomMemo;
for (int i = 0; i < randomStringLength; ++i) {
int index = QRandomGenerator::system()->bounded(0, possibleCharacters.length());
randomMemo.append(possibleCharacters.at(index));
}
// create the transaction
json extraTransaction = json::object();
extraTransaction["address"] = addressWithMaxValue.toStdString();
extraTransaction["amount"] = 12000;
extraTransaction["memo"] = randomMemo.toStdString();
// Replace one sietch transaction
if (!dust.empty()) {
dust.front() = extraTransaction;
extraTransactionAdded = true;
} else {
dust.push_back(extraTransaction);
extraTransactionAdded = true;
}
}
// Set amount = 0 to all sietch transactions
for(auto &it: dust) {
if (!extraTransactionAdded || it["address"] != addressWithMaxValue.toStdString()) {
it["amount"] = 0;
}
}
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box
for (int i=0; i < tx.toAddrs.size(); i++)
@ -249,7 +281,6 @@ qDebug() << "Adresse mit dem höchsten Gesamtwert:" << addressWithMaxValue;
}
}
}
void Controller::noConnection()
@ -1545,8 +1576,11 @@ void Controller::executeStandardUITransaction(Tx tx)
// Execute a transaction!
void Controller::executeTransaction(Tx tx,
const std::function<void(QString txid)> submitted,
const std::function<void(QString txid, QString errStr)> error)
const std::function<void(QString txid, QString errStr)> error)
{
// Refresh the available unspent notes
fetchAndProcessUnspentNotes();
unlockIfEncrypted([=] () {
// First, create the json params
json params = json::array();
@ -1572,7 +1606,6 @@ void Controller::executeTransaction(Tx tx,
});
}
void Controller::checkForUpdate(bool silent)
{
// qDebug()<< __func__;
@ -1666,7 +1699,7 @@ void Controller::checkForUpdate(bool silent)
// Get the hush->USD price from coinmarketcap using their API
void Controller::refreshHUSHPrice()
{
qDebug()<< __func__;
// qDebug()<< __func__;
if (!zrpc->haveConnection())
return;

4
src/mainwindow.cpp

@ -427,7 +427,7 @@ void MainWindow::closeEvent(QCloseEvent* event) {
void MainWindow::closeEventpw(QCloseEvent* event) {
// Let the RPC know to shut down any running service.
qDebug() << __func__ << ": event=" << event << " this=" << this;
// qDebug() << __func__ << ": event=" << event << " this=" << this;
if (rpc) {
rpc->shutdownhushd();
} else {
@ -742,7 +742,7 @@ void MainWindow::setMoneyMemo(QString moneymemo)
}
void MainWindow::setupStatusBar() {
qDebug() << __func__ << endl;
// qDebug() << __func__ << endl;
// Status Bar
loadingLabel = new QLabel();
loadingMovie = new QMovie(":/icons/res/loading.gif");

Loading…
Cancel
Save