Skip to content
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

Return emission as a string in RPC #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aivve
Copy link
Collaborator

@aivve aivve commented Jan 24, 2025

responses because that large uint64_t number is unsafe in JavaScript environment and therefore as a JSON value and is not working properly:

"result": {
        "block": {
            "alreadyGeneratedCoins": "9988883.631436124907",

vs

"result": {
        "block": {
            "alreadyGeneratedCoins": -8457860442273426709,

in RPC responses because that large uint64_t number is unsafe in JavaScript environment and therefore as a JSON value
@Lastick
Copy link

Lastick commented Jan 24, 2025

Specifying a volume in a string type may not be accurate in terms of constructing the JSON type, but it is possible to specify the mantissa separately from the integer for further processing, although this may lead to inaccuracy.

As far as I remember from old experiments, the node returned an error in the format of a negative number for the number of coins in circulation. In my case, I have sign inversion (or modulus) for some operations.

decimal_point = 12
prec_point = 4
user_agent = "KarboStatsMinibot/1.0"

def AmountFormat(self, amount):
    res = 0.0
    if (amount < 0):
        amount = -amount
    if (amount > 0):
        res = float(round(amount / float(pow(10, self.decimal_point)), self.prec_point))
    return res

alreadyGeneratedCoins = self.AmountFormat(long(json_obj['result']['block']['alreadyGeneratedCoins']))

@aivve
Copy link
Collaborator Author

aivve commented Jan 24, 2025

This is exactly what is happening, negative number. If your solution works we can just use it in the explorer. The emission in block info is wrong currently.

@aivve
Copy link
Collaborator Author

aivve commented Jan 26, 2025

Okay, you gave me the ida, so it's fixed on explorer end.

Perhaps we should also display as number in /getinfo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants