Skip to content

Conversation

@gaeacodes
Copy link

Please don't merge till the main PR to https://github.com/KomodoPlatform/insight-ui-komodo is approved

@DeckerSU
Copy link
Owner

I guess this should be implemented as a patches to already installed explorer instance. Explanation of this point of view is simple - explorer can be used not only for KMD itself, but for assetchains / smartchains also. And in smartchains we don't need any rewards calculations or additional getRawTransaction RPC call for every touched tx. Also, as changes required not only in bitcore-node-komodo repo, but also in insight-api-komodo and insight-ui-komodo - this is other argument to format / pack all needed changes as a patches for installed explorer. Bcz smartchains explorer also don't need UI and API changes related to KMD rewards. So, this should be optional anyway. I prepared patch for bitcore-node-komodo based on this PR: https://gist.github.com/DeckerSU/d9e2dd7dddae1daa3f5123d95e132176 (without touching unneeded functions, idents, etc. it looks much better) and will do the same for insight-ui-komodo and insight-api-komodo later. After i will include them in https://github.com/DeckerSU/komodo-explorers-install repo.

Btw, great job, thanks for your contribution.

@gaeacodes
Copy link
Author

Yes, I agree that all of this code is not necessary for assetchains as they don't have rewards. Thanks for creating the necessary patches for all the repos.

In this patch(https://gist.github.com/DeckerSU/d9e2dd7dddae1daa3f5123d95e132176), I noticed that you missed including a line (self.tipTime = response.result.time;) I added in the commit 83913e5 (#2)

@gaeacodes
Copy link
Author

btw, I think the logic I added to bitcore-node-komodo should ideally be present in komodod itself. So, that the rpc queue is not overloaded when handling transactions with lots of vins.

DeckerSU added a commit to DeckerSU/komodo-explorers-install that referenced this pull request Jan 25, 2021
@DeckerSU
Copy link
Owner

Distinquished all needed changes from 3 repoes (bitcore-node-komodo, insight-api-komodo, insight-ui-komodo) as a patches, made an instruction, all of these already available in commit above. Live demo available here - https://api.kmd.dev/ and here - https://explorer.kmd.sh/ .

@DeckerSU
Copy link
Owner

Btw, other thing, i saw new package moment in your implementation ... may be better to use standart routines for the same purposes, like:

moment().unix()

console.log(moment().unix());
console.log(Math.floor(new Date().getTime() / 1000));

moment.duration().humanize()

var seconds = 777777;
console.log(moment.duration(seconds, "seconds").humanize());
console.log(forHumans(seconds));

where forHumans is:

function forHumans ( seconds ) {
    var levels = [
        [Math.floor(seconds / 31536000), 'years'],
        [Math.floor((seconds % 31536000) / 86400), 'days'],
        [Math.floor(((seconds % 31536000) % 86400) / 3600), 'hours'],
        [Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), 'minutes'],
        [(((seconds % 31536000) % 86400) % 3600) % 60, 'seconds'],
    ];
    var returntext = '';

    for (var i = 0, max = levels.length; i < max; i++) {
        if ( levels[i][0] === 0 ) continue;
        returntext += ' ' + levels[i][0] + ' ' + (levels[i][0] === 1 ? levels[i][1].substr(0, levels[i][1].length-1): levels[i][1]);
    };
    return returntext.trim();
}

Results will be the same:

1611582415
1611582415
9 days
9 days 2 minutes 57 seconds

Just as an offer.

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