You are viewing a single comment's thread from:

RE: Podping is preparing for Hard Fork HF26 and HiveFest

in #hf262 years ago

Thanks for this, I can't say I'm finding it very easy to figure out what the RCs actually used for a transaction are or will be. Are these available after the fact for a given transaction?

Right now I'm making a kind of watcher that looks that the resource credits across a group of apps and hands them out if they need more.

Sort:  

There is no easy way to predict RC cost, but you can somewhat get to know what you've already paid. It is the easiest if you have your own node. Having your own node means you can write your own plugin or even add notifications/logs directly to the place that charges your account(s). It is also easy to differentiate between "present" (state from the blocks which can be treated as solid) and "future" (pending state). If you don't have your own node, then you can only use something like rc_api.find_rc_accounts to monitor your accounts. However, if you wanted to use that to see exactly how much you've paid for each transaction, it gets tricky. Typically you only see the "future" when using API, so you'd need to make sure that "future" and "present" are the same, that is, first wait until your transaction gets into block using transaction_status_api.find_transaction, then look for your account's RC and compare it with what it had before transaction. The tricky part is that if you make another transaction in the meantime, you won't be able to tell the cost properly. Also if you are using some service that can f.e. vote in your name, then it can make you the RC payer, not just for your own vote, but for all the votes in the transaction it sent. In normal situation there is little difference between "present" and "future", but during high traffic "future" can be distorted, and in case of highly contested resources, like new account tokens, it can happen that you've claimed your token and "future" shows you've paid 9T RC, but before it becomes "present" some whale claimed 100 tokens and now your token costs 12T RC (it might even happen that you'll no longer be able to afford it and your transaction that was accepted as pending will never make it to the block - these are the dangers of looking into the "future").