Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Transactions to have asset name and ID #1130

Closed
sidhujag opened this issue Dec 11, 2014 · 2 comments
Closed

Transactions to have asset name and ID #1130

sidhujag opened this issue Dec 11, 2014 · 2 comments

Comments

@sidhujag
Copy link
Contributor

  foreach($response['result'] as $txinfo)
  {

    // make sure the order was placed before it was paid on the blockchain, sanity check incase hash's match but tx is for wrong order.
    // also make sure this tx is confirmed on the blockchain before processing it
    if($txinfo['is_confirmed'] == true)
    {
        $timeStamp = $txinfo['timestamp'];
      $trxId = $txinfo['trx_id'];
      foreach($txinfo['ledger_entries'] as $tx) {

          //$txTime = strtotime($tx['timestamp']);
        // echo 'time: ' . $txTime; 
        $toaccount = $tx['to_account'];

          $txSymbol = btsGetAssetNameById($tx['amount']['asset_id'], $rpcUser, $rpcPass, $rpcPort);
        $memo = $tx['memo'];
          if($txSymbol != $asset && !$demoMode)
            {
                continue;
            }
        // sanity check, tx to account should match your configured account in admin settings
        if($toaccount != $account)
        {
          continue;
        }
        // if this TX doesn't have the hash of the open order we are checking, skip this order
        if(strpos($memo, $orderEHASH) == FALSE)
        {
          continue;
        }
        $accumulatedAmountPaid += ($tx['amount']['amount']/100000);
      }
    }
  }  

This is my code to run over all orders using wallet_account_transaction_history... notice the call to btsGetAssetNameById? its another RPC call... can we do something like tx['amount']['asset']['id'] or tx['amount']['asset_id'] as is for id and tx['amount']['asset']['name'] or tx['amount']['asset_name'] for asset name to avoid another rpc call? Just another child json tag for the asset. The later of maybe including asset_name might be the easiest.

Thanks!

@eightyhz
Copy link

While this would be convenient, I am concerned it would further slow down RPC's (by adding lookups and increasing response size)

I use a locally cached identity maps for these type of static data.. I would prefer the core to be fast and lean, and these "convenience" features to be implemented in PHP/Ruby/Python/etc wrappers.

@vikramrajkumar
Copy link
Contributor

Yes, for something as ubiquitous as the asset symbol<->id mapping I agree with @eightyhz. This is what we do in the https://github.com/BitShares/web_wallet.

Also note that we are soon going to completely change the wallet transaction record format as part of #845.

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

No branches or pull requests

3 participants