-
Notifications
You must be signed in to change notification settings - Fork 182
Remove expired polls from overview page #1250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove expired polls from overview page #1250
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put your logic in a function and wrap it in a try-catch so it does not crash wallet on invalid data.
Otherwise good. Thank you for contributing.
src/main.cpp
Outdated
// Alerts are displayed as polls but do not have an expiration | ||
if(sPollExpiration.empty()) | ||
{ | ||
sPollExpiration = std::to_string(pindexBest->nTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid converting things to string if possible.
src/main.cpp
Outdated
{ | ||
sPollExpiration = std::to_string(pindexBest->nTime); | ||
} | ||
if (stoll(sPollExpiration) >= pindexBest->nTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsafe strtoll. Please add error and exception handling or use another function (ToString maybe?).
src/main.cpp
Outdated
} | ||
else | ||
{ | ||
GlobalStatusStruct.poll = "No current polls"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate? I don't see what's wrong with this.
…ed exception handling for stoll()
I've moved the logic into the new function |
I agree with @tomasbrod asking of the try catch there as well. better to pass back no current poll for malformed time then having msMiningErrors saying Error obtaining status and in turn not providing the other valid data/or incomplete data to the wallet -- this saves confusion as well as to where the problem is/was |
src/main.h
Outdated
@@ -260,6 +260,8 @@ bool WriteKey(std::string sKey, std::string sValue); | |||
double GetBlockDifficulty(unsigned int nBits); | |||
std::string ExtractXML(std::string XMLdata, std::string key, std::string key_end); | |||
|
|||
std::string GetPoll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use more descriptive name, with overview or statusbar words. There are getters for rpcs and voting tab, we do not want name clashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally set status to approve.
About that no polls message: if it is a separate line, sure, show that message so it does not appear empty. But if it is under status field, no polls message would just takes up space.
…around function call
label poll is not used for anything but poll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 569bc8d; apon another approval I think due to this being a cosmetic fix more then anything it'll be a small include for the upcoming release milestone if @denravonska and @tomasbrod concur.
src/main.cpp
Outdated
} | ||
catch (std::exception &e) | ||
{ | ||
GlobalStatusStruct.poll = "Error obtaining last poll"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translations should be considered here.
GlobalStatusStruct.poll = _("Error obtaining last poll");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the user needs to see this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree if anything a log entry about the exception should be put. Remove translation and log the e.what() under debug
src/main.cpp
Outdated
} | ||
else | ||
{ | ||
poll = "No current polls"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translations:
poll = _("No current polls");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about "Current Poll: none"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short but sweet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually thinking about this. We should consider use the _() and do translations where we can to increase the readability across languages where we can.
I will wait on adding translations until #1262 is merged. Do we want it to say "No current polls" or "None"? I think the former sounds better in the context of the overview page. |
i would say don't worry about the translations part and it can be done at a later point when we do another translation update before release :) having the _() wont break your code. no worries there -- so just add the requested _() in a commit and make sure all reviews are satisfied and we can move to approval and merge. i'll update the translation strings at next release you wouldn't be manually adding to the bitcoinstrings.cpp file. there's a script for that and would be in a separate pr for updated information |
Is this PR appropriate in its current state or would you guys like any additional changes? |
Any reason to worry about the full contract message appearing in the output of "MiningInfo 2": "<MT>poll</MT><MK>What_do_you_call_a_positively_charged_seal?\n</MK><MV><TITLE>What_do_you_call_a_positively_charged_seal?\n</TITLE><DAYS>14</DAYS><QUESTION>What_do_you_call_a_positively_charged_seal?\n</QUESTION><ANSWERS>A_Sealion;God_dammit_Foxifi!</ANSW ERS><SHARETYPE>3</SHARETYPE><URL>https://i.imgur.com/1D4iQZl.jpg</URL><EXPIRATION>1544712997</EXPIRATION></MV><MA>A</MA><MPK></MPK><MS>MEQCIHwhNJRKus9MwSYWo6epSyfaNytv2/IFFp5fCVUDNZwUAiBUS2U68h4y+ptkQ7tnUr/YGO8bL1Gz4EbIrE1207g2zA==</MS>", |
With jokes like that...yes! ;) |
Added: - Add `rainbymagnitude` RPC command #1235 (@Foggyx420). - Add stake splitting and side staking #1265 (@jamescowens). - Detect and block Windows shutdown so wallet can exit cleanly #1309 (@jamescowens). - Add message support to sendfrom and sendtoaddress #1400 (@denravonska). Changed: - Configuration options are now case insensitive #294 (@Foggyx420). - Update command in beaconstatus help message #1312 (@chrstphrchvz). - Improve synchronization speeds: - Refactor superblock pack/unpack #1194 (@denravonska). - Optimize neuralsecurity calculations #1255 (@denravonska). - Reduce hash calculations when checking blocks #1206 (@denravonska). - Make display of private key in beaconstatus OPT-IN only #1275 (@Foggyx420). - Store Beacon keys in Wallet #1088 (@tomasbrod). - Use default colors for pie chart #1333 (@chrstphrchvz). - Show hand cursor when hovering clickable labels #1332 (@chrstphrchvz). - Update README.md #1337 (@Peppernrino). - Fix integer overflow with displayed nonce #1297 (@personthingman2). - Improve application cache performance #1317 (@denravonska). - Improve reorg speeds #1263 (@denravonska). - Update Polish translation #1375 (@michalkania). Fixed: - Remove expired polls from overview page #1250 (@personthingman2). - Fix plural text on block age #1304 (@scribblemaniac). - Fix researcher staking issue if your chain head was staked by you, #1299 (@denravonska). - Fix incorrect address to grcpool node #1314 (@wilkart). - Do not replace underscores by spaces in Qt Poll URLs #1327 (@tomasbrod). - Fix scraper SSL issues #1330 (@Foggyx420). Removed: - Remove or merged several RPC commands #1228 (@Foggyx420): - `newburnaddress`, removed. - `burn2`: Removed. - `cpid`: Merged into `projects`. - `mymagnitude`: Merged into `magnitude`. - `rsa`: Removed, use `magnitude`. - `rsaweight`: Removed, use `magnitude`. - `proveownership`: Removed. - `encrypt`: Removed. - Remove obsolete POW fields from RPC responses #1358 (@jamescowens). - Remove obsolete netsoft fields for slight RAM requirement reduction #1336 (@denravonska). - Remove unused attachment functionality #1345 (@denravonska).
This is my first contribution to an open source project so please tell me if I'm doing anything wrong.
This is a fix for #1168. I moved the logic into
GetGlobalStatus
becauseMemorizeMessage
is only run when a message is received, meaning users would have to restart their client for an expired poll to disappear. As a resultmsPoll
now contains the entire message XML so it can be processed inGetGlobalStatus
.The "Poll: " and "Foundation Poll: " concats were removed because it looked silly to me.