Nebulus Bug Fixes | Update #009

in #utopian-io6 years ago (edited)

Nebulus-update-009.png

Repository

https://github.com/jrswab/nebulus

Bug Fixes

The following issues where brought to my attention during the last review. Since the past week was spent away with family no new features were able to be added.

Issue 1: Hardcoding SteemConnect Link

This was set by me in the html markup. While this may not cause an issue (or at least work) it is better to use the fix. This way the URL encoded characters are used correctly. This will also save time in the future if there needs to be a URL change for SteemConnect.

Fix 1: Now using PHP's "http_build_query"

PHP's http_build_query takes an array of data and uses that to construct the link with the proper encoded characters. Our array looks as follows:

$info = array('to' => 'nebulus', 'from' => $steemName, 
    'amount' => '1.000 STEEM', 'memo' => 'pin '.$pinHash, 
    'redirect_uri' => 'https://'.$domain.'/welcome.php');

Then we assign the HTTP build method to a variable or easy use in the URL:
$sc2Link = http_build_query($info);
The build method uses both the assigner and the assignee in the link building. So 'to' => 'nebulus' becomes to=nebulus in the URL with any needed encoding. A good example of this is the 'memo' => pin '.$pinHash. In this example, the space between the word pin and the hash variable is encoded with a + symbol.

So, instead of hard-coding:

https://steemconnect.com/sign/transfer?to=nebulus&amount=1.000+STEEM&from='.$steemName.'&memo=pin+'.$pinHash.'&redirect_uri=https://'.$domain.'/welcome.php

we now use:
https://steemconnect.com/sign/transfer?'.$sc2Link.'
This markup is much less likely to get screwed when changing parameters or updating the link as a whole.

Issue 2: Hardcoding roundRobin in the global scope

I am glad @justyy noticed my error here because having this integer defined in the global scope could have messed up another function in the future or a present one in some odd case. When this variable is in the global scope, it could have reset itself. While this was not happening in testing, it does not mean it would never happen.

Fix 2: Moved the variable inside a function

All that we needed to do was to move tho variable out of the global scope and into a function. Now within the robin function we define roundRobin instead of calling the global variable.

def robin(bLimit):
    roundRobin = 0
...

However, we do need that variable in other functions but since the robin function returns roundRobin we can call the robin function in place of the roundRobin global variable.

So instead of executing two functions at the bottom of the Python code we now only call one (sort of):

robin(blockNum)
pin(roundRobin, blockNum)

Becomes:
pin(robin(bLimit), bLimit)

robin() is still called but as an argument of pin() and Python runs robin() to get the return value and use that as the roundRobin variable within pin().

I am still thinking of a suitable way to define bLimit and remove it from the global scope. If you have any ideas, please let me know on Discord or steem.chat.

Issue 3: No testing for the pinAdd and pidKill functions

Another great spot by Justyy, the two functions pinAdd and pidKill had no checks to make sure the PID or hash was present upon running the code. The lack of testing created risks in the code that could have forced the execution to quit and no subsequent hashes to get pinned.

Fix 4: Check if PID exists.

To fix this, I added some true and false returns to the two functions so that we can check them within the pin() function's execution.

pinAdd():
if pgreped is None:
            return None
        else:
            return pgreped
pidKill():
if pgreped is None:
        print("Nothing to kill")

I chose to add a print statement in pidKill for logging purposes.

GitHub Account

https://github.com/jrswab

All images came from royalty and attribution free sources unless specified.

Looking to take your Steem based creations to the next level?
Join us over at the Creators' Guild Discord group! We are here to encourage, support and increase the creation of quality content.


If you have any questions about the future of Steem
or my witness please feel free to message jrswab#3134 on Discord.

vote-jrswab-for-steem-Witnesses—Steemit.gif
Click here to vote with SteemConnect!

Or go to https://steemit.com/~witnesses
and type jrswab in the box at the bottom.
You can see all active witnesses on @drakos' steemian.info


Click here to join the mailing list and get exclusive SDB/STEEM giveaways!

Looking to support my content creation efforts outside of the Steem Blockchain?
Check out jrswab.com/support


Mastodon | Keybase | Twitter | Gab | Minds | Hacker Culture Podcast

Sort:  

Thank you for your contribution. As per Utopian Guidelines - "Bug Fixes for contributor’s Own Projects will not be considered for potential reward, unless the Bugs were caused by third party dependencies." It's better if you combine your bug fixes with an additional feature or enhancement of the application.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @codingdefined!

So far this week you've reviewed 2 contributions. Keep up the good work!

This project is being supported by @Fundition

Fundition is a next-generation, decentralized, peer-to-peer crowdfunding and collaboration platform, built on the Steem blockchain.

#upfundition and #fundition tags on Steem represent the projects that are started on https://fundition.io.

Are You Prepared to Make the World a Better Place too?

Read the full details of Fundition Fund program

Learn more about Fundition by reading our purplepaper

Join a community with heart based giving at its core
steemitf.pngtwitterf.pngyoutubef.pngfacebookf.pnginstaf.pngdiscordf.png

Thank you so much of the support again. It really helps! I can't wait to get some new features out for everyone.

grate work for new development technology.i can follow u.@aryaan

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.029
BTC 63396.80
ETH 2615.51
USDT 1.00
SBD 2.86