From caa74f6efc85e73fc32ee51f211b3dd0384bef11 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 26 Jul 2020 16:03:36 +0200 Subject: [PATCH] fix number of sietch zaddrs for transactions and hushchat --- src/controller.cpp | 66 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index e14e32d..c3d9e70 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -92,7 +92,7 @@ void Controller::setConnection(Connection* c) // Create Sietch zdust addr at startup. // Using DataStore singelton, to store the data outside of lambda, bing bada boom :D - for(uint8_t i = 0; i < 6; i++) + for(uint8_t i = 0; i < 8; i++) { zrpc->createNewSietchZaddr( [=] (json reply) { QString zdust = QString::fromStdString(reply.get()[0]); @@ -133,12 +133,12 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) json rec = json::object(); //creating the JSON dust parameters in a std::vector to iterate over there during tx - std::vector dust(6); - dust.resize(6, json::object()); + std::vector dust(8); + dust.resize(8, json::object()); // Create Sietch zdust addr again to not use it twice. // Using DataStore singelton, to store the data outside of lambda, bing bada boom :D - for(uint8_t i = 0; i < 6; i++) + for(uint8_t i = 0; i < 8; i++) { zrpc->createNewSietchZaddr( [=] (json reply) { QString zdust = QString::fromStdString(reply.get()[0]); @@ -147,7 +147,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) } // Set sietch zdust addr to json. // Using DataStore singelton, to store the data into the dust. - for(uint8_t i = 0; i < 6; i++) + for(uint8_t i = 0; i < 8; i++) { dust.at(i)["address"] = DataStore::getSietchDataStore()->getData(QString("Sietch" + QString(i))).toStdString(); } @@ -169,7 +169,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) randomString.append(nextChar); } - for(uint8_t i = 0; i < 6; i++) + for(uint8_t i = 0; i < 8; i++) { int length = randomString.length(); int randomSize = rand() % 120 +10; @@ -210,7 +210,56 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) allRecepients.push_back(rec); } + int decider = rand() % 100 + 1 ; ; // random int between 1 and 100 + +if (tx.toAddrs.size() < 2) +{ + +if(decider % 4 == 3) +{ + allRecepients.insert(std::begin(allRecepients), { + dust.at(0), + dust.at(1), + dust.at(2), + dust.at(3), + dust.at(4), + dust.at(5) + + }) ; + +}else{ + + allRecepients.insert(std::begin(allRecepients), { + dust.at(0), + dust.at(1), + dust.at(2), + dust.at(3), + dust.at(4), + dust.at(5), + dust.at(6) + + }) ; + +} +}else{ + +if(decider % 4 == 3) +{ + + allRecepients.insert(std::begin(allRecepients), { + dust.at(0), + dust.at(1), + dust.at(2), + dust.at(3), + dust.at(4) + + + }) ; + +}else{ + + allRecepients.insert(std::begin(allRecepients), { dust.at(0), dust.at(1), dust.at(2), @@ -220,7 +269,10 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) }) ; - qDebug()<<"ADDR DUST"; +} +} + + } void Controller::noConnection()