ui reporting

This commit is contained in:
Evan 2014-04-06 12:03:41 -07:00
parent d64084d86f
commit 32e04193cc
4 changed files with 82 additions and 23 deletions

View File

@ -3809,10 +3809,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
bool error;
std::string errorMessage;
vRecv >> error >> errorMessage;
std::string lastMessage;
vRecv >> error >> lastMessage;
darkSendPool.CompletedTransaction(error, errorMessage);
darkSendPool.CompletedTransaction(error, lastMessage);
}
@ -3901,7 +3901,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
int current;
vRecv >> vin >> addr >> count >> current;
printf("Searching existing masternodes : %s\n", vin.ToString().c_str());
printf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str());
bool found = false;
BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) {
@ -5416,8 +5416,9 @@ void CDarkSendPool::SetNull(){
lastTimeChanged = GetTimeMillis();
sigCount = 0;
errorMessage = "";
completedTransaction = false;
entriesCount = 0;
lastEntryAccepted = 0;
countEntriesAccepted = 0;
}
void CDarkSendPool::SetCollateralAddress(std::string strAddress){
@ -5516,7 +5517,7 @@ void CDarkSendPool::Check()
SetNull();
pwalletMain->Lock();
UpdateState(POOL_STATUS_ACCEPTING_ENTRIES);
RelayDarkSendCompletedTransaction(true, "Transaction not valid");
RelayDarkSendCompletedTransaction(true, "Transaction not valid, please try again");
return;
}
@ -5529,7 +5530,7 @@ void CDarkSendPool::Check()
txNew.RelayWalletTransaction();
RelayDarkSendCompletedTransaction(false, "");
RelayDarkSendCompletedTransaction(false, "Transaction Created Successfully");
printf("CDarkSendPool::Check() -- IS MASTER -- TRANSMITTING DARKSEND\n");
}
}
@ -5545,6 +5546,10 @@ void CDarkSendPool::Check()
DisconnectMasterNode();
}
if((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis()-lastTimeChanged >= 10000) {
printf("CDarkSendPool::Check() -- RESETTING MESSAGE \n");
SetNull();
}
}
void CDarkSendPool::ChargeFees(){
@ -5729,6 +5734,8 @@ void CDarkSendPool::SendMoney(const CTransaction& collateral, CTxIn& in, CTxOut&
printf("CDarkSendPool::SendMoney() -- NEW INPUT -- adding %s\n", in.ToString().c_str());
}
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) ClearLastMessage();
if(!IsConnectedToMasterNode()){
ConnectToBestMasterNode();
}
@ -5757,12 +5764,15 @@ void CDarkSendPool::SendMoney(const CTransaction& collateral, CTxIn& in, CTxOut&
bool CDarkSendPool::StatusUpdate(int newState, int newEntriesCount, int newAccepted){
if(fMasterNode) return false;
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false;
state = newState;
UpdateState(newState);
entriesCount = newEntriesCount;
if(newAccepted != -1)
if(newAccepted != -1) {
lastEntryAccepted = newAccepted;
countEntriesAccepted += newAccepted;
}
return true;
}
@ -5861,18 +5871,18 @@ void CDarkSendPool::ConnectToBestMasterNode(int depth){
darkSendMasterNodes[winner].enabled = 0;
if(depth < 5){
UpdateState(POOL_STATUS_ERROR);
errorMessage = "Trying MasterNode #" + to_string(depth);
lastMessage = "Trying MasterNode #" + to_string(depth);
ConnectToBestMasterNode(depth+1);
} else {
UpdateState(POOL_STATUS_ERROR);
errorMessage = "No valid MasterNode";
printf("ERROR: %s\n", errorMessage.c_str());
lastMessage = "No valid MasterNode";
printf("ERROR: %s\n", lastMessage.c_str());
}
}
} else {
UpdateState(POOL_STATUS_ERROR);
errorMessage = "No valid MasterNode";
printf("ERROR: %s\n", errorMessage.c_str());
lastMessage = "No valid MasterNode";
printf("ERROR: %s\n", lastMessage.c_str());
}
//if couldn't connect, disable that one and try next
@ -5918,6 +5928,8 @@ void CDarkSendPool::RegisterAsMasterNode()
if(GetMasterNodeVin(vinMasterNode)) {
printf("Is capable master node!\n");
isCapableMasterNode = true;
pwalletMain->LockCoin(vinMasterNode.prevout);
printf("Adding myself to masternode list %s\n", vinMasterNode.ToString().c_str());
CMasterNode mn(addr, vinMasterNode);
mn.UpdateLastSeen();
@ -5998,17 +6010,29 @@ void CDarkSendPool::NewBlock()
*/
}
void CDarkSendPool::CompletedTransaction(bool error, std::string errorMessageNew)
void CDarkSendPool::CompletedTransaction(bool error, std::string lastMessageNew)
{
printf("CompletedTransaction\n");
if(error){
state = POOL_STATUS_ERROR;
errorMessage = errorMessageNew;
printf("CompletedTransaction -- error \n");
UpdateState(POOL_STATUS_ERROR);
} else {
printf("CompletedTransaction -- success \n");
UpdateState(POOL_STATUS_SUCCESS);
}
lastMessage = lastMessageNew;
completedTransaction = true;
Check();
}
void CDarkSendPool::ClearLastMessage()
{
SetNull();
lastMessage = "";
}
uint256 CMasterNode::CalculateScore()
{
if(pindexBest == NULL) return 0;

View File

@ -14,6 +14,9 @@
#include <list>
#include <algorithm>
//#define static_assert(numeric_limits<double>::max_exponent() > 8, "your double sux");
class CWallet;
class CBlock;
class CBlockIndex;
@ -2403,6 +2406,7 @@ public:
#define POOL_STATUS_SIGNING 4 // check inputs/outputs, sign final tx
#define POOL_STATUS_TRANSMISSION 5 // transmit transaction
#define POOL_STATUS_ERROR 6 // error
#define POOL_STATUS_SUCCESS 7 // success
static const int64 POOL_FEE_AMOUNT = 0.1*COIN;
@ -2423,12 +2427,14 @@ public:
unsigned int state;
unsigned int entriesCount;
unsigned int lastEntryAccepted;
unsigned int countEntriesAccepted;
CScript collateralPubKey;
CTxIn vinMasterNode;
bool isCapableMasterNode;
uint256 masterNodeBlockHash;
std::string errorMessage;
std::string lastMessage;
bool completedTransaction;
CDarkSendPool()
@ -2477,6 +2483,11 @@ public:
return lastEntryAccepted;
}
int GetCountEntriesAccepted() const
{
return countEntriesAccepted;
}
int GetSignatureCount() const
{
return (int)sigCount;
@ -2522,7 +2533,8 @@ public:
void RegisterAsMasterNode();
bool GetLastValidBlockHash(uint256& hash);
void NewBlock();
void CompletedTransaction(bool error, std::string errorMessageNew);
void CompletedTransaction(bool error, std::string lastMessageNew);
void ClearLastMessage();
};
void ConnectToDarkSendMasterNodeWinner();

View File

@ -80,6 +80,7 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
ui->labelCoinControlChange->addAction(clipboardChangeAction);
fNewRecipientAllowed = true;
showingDarkSendMessage = 0;
}
void SendCoinsDialog::setModel(WalletModel *model)
@ -254,23 +255,44 @@ void SendCoinsDialog::darkSendStatusButton()
int state = darkSendPool.GetState();
int entries = darkSendPool.GetEntriesCount();
int accepted = darkSendPool.GetLastEntryAccepted();
int countAccepted = darkSendPool.GetCountEntriesAccepted();
std::ostringstream convert;
if(state == POOL_STATUS_ACCEPTING_ENTRIES)
convert << "darkSend Status => ( Entries " << entries << " | Accepted " << accepted << " )";
if(entries == 0) {
convert << "darkSend Status => Idle";
showingDarkSendMessage = 0;
} else if (accepted == 1) {
if(showingDarkSendMessage % 10 <= 8) {
convert << "darkSend Status => Your transaction was accepted into the pool!";
} else {
darkSendPool.lastEntryAccepted = 0;
showingDarkSendMessage = 0;
}
} else {
if(showingDarkSendMessage % 70 <= 40) convert << "darkSend Status => ( Entries " << entries << "/" << POOL_MAX_TRANSACTIONS << ")";
else if(showingDarkSendMessage % 70 <= 50) convert << "darkSend Status => Waiting for more entries (" << entries << "/" << POOL_MAX_TRANSACTIONS << ") .";
else if(showingDarkSendMessage % 70 <= 60) convert << "darkSend Status => Waiting for more entries (" << entries << "/" << POOL_MAX_TRANSACTIONS << ") ..";
else if(showingDarkSendMessage % 70 <= 70) convert << "darkSend Status => Waiting for more entries (" << entries << "/" << POOL_MAX_TRANSACTIONS << ") ...";
}
else if(state == POOL_STATUS_SIGNING)
convert << "darkSend Status => SIGNING";
else if(state == POOL_STATUS_TRANSMISSION)
convert << "darkSend Status => TRANSMISSION";
else if(state == POOL_STATUS_ERROR)
convert << "darkSend Status => ERROR : " << darkSendPool.errorMessage;
convert << "darkSend Status => ERROR : " << darkSendPool.lastMessage;
else if(state == POOL_STATUS_SUCCESS)
convert << "darkSend Status => SUCCESS : " << darkSendPool.lastMessage;
else
convert << "darkSend Status => UNKNOWN STATE";
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) darkSendPool.Check();
QString s(convert.str().c_str());
ui->darkSendStatusButton->setText(s);
showingDarkSendMessage++;
}
void SendCoinsDialog::reject()

View File

@ -50,6 +50,7 @@ private:
Ui::SendCoinsDialog *ui;
WalletModel *model;
bool fNewRecipientAllowed;
int showingDarkSendMessage;
private slots:
void on_sendButton_clicked();