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

timestamps in get_relative_account_history() call #487

Closed
DanielLeberle opened this issue Nov 16, 2017 · 5 comments · Fixed by #2642
Closed

timestamps in get_relative_account_history() call #487

DanielLeberle opened this issue Nov 16, 2017 · 5 comments · Fixed by #2642

Comments

@DanielLeberle
Copy link

Is it possible to get the timestamp for every operation in the account history?

@oxarbitrage
Copy link
Member

Hi there, you need to use the new elasticsearch plugin to make this, documentation is in progress but you can get some of it at: https://github.com/oxarbitrage/worker-proposals/blob/master/elasticsearch-plugin.md - #358

For example, getting the last op from the network will return:

root@NC-PH-1346-07:~# curl -X GET 'http://localhost:9200/graphene-*/data/_search?pretty=true' -d '
{
  "query": {
    "match_all": {}
  },
  "size": 1,
  "sort": [
    {
      "block_data.block_time": {
        "order": "desc"
      }
    }
  ]
}
'
{
  "took" : 394,
  "timed_out" : false,
  "_shards" : {
    "total" : 130,
    "successful" : 130,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 90991474,
    "max_score" : null,
    "hits" : [
      {
        "_index" : "graphene-2017-11",
        "_type" : "data",
        "_id" : "2.9.90991445",
        "_score" : null,
        "_source" : {
          "account_history" : {
            "id" : "2.9.90991445",
            "account" : "1.2.410471",
            "operation_id" : "1.11.89931301",
            "sequence" : 219332,
            "next" : "2.9.90991444"
          },
          "operation_history" : {
            "trx_in_block" : 2,
            "op_in_trx" : 1,
            "operation_result" : "[1,\"1.7.37153893\"]",
            "virtual_op" : 40981,
            "op" : "[1,{\"fee\":{\"amount\":1213,\"asset_id\":\"1.3.0\"},\"seller\":\"1.2.410471\",\"amount_to_sell\":{\"amount\":482315280,\"asset_id\":\"1.3.0\"},
\"min_to_receive\":{\"amount\":4701839,\"asset_id\":\"1.3.121\"},\"expiration\":\"1963-11-25T09:31:44\",\"fill_or_kill\":false,\"extensions\":[]}]"
          },
          "operation_type" : 1,
          "block_data" : {
            "block_num" : 21840919,
            "block_time" : "2017-11-16T11:41:42",
            "trx_id" : "a06be59f63345f32c7b6005761059010739376de"
          },
          "additional_data" : {
            "fee_data" : {
              "asset" : "1.3.0",
              "amount" : 1213
            },
            "transfer_data" : {
              "asset" : "1.3.0",
              "amount" : 0,
              "from" : "1.2.0",
              "to" : "1.2.0"
            }
          }
        },
        "sort" : [
          1510832502000
        ]
      }
    ]
  }
}
root@NC-PH-1346-07:~# 

The block_time is the timestamp you are looking for and in elasticsearch plugin this date is with every operation. For this and other similar issues get_relative_account_history will not be modified in the short term and you need to start looking into this plugin.

If you need help, have questions, etc please post here or open new issues accordingly.

@xeroc
Copy link
Member

xeroc commented Nov 16, 2017

There is no infrastructure of ES yet. Can we not simply add the blocks timestamp to the APIs output?

@oxarbitrage
Copy link
Member

i don't think so. first there are performance issues to fetch the block and later the timestamp with each op, no code to do it was accepted. second, the output of the api call is just ops, if we add the timestamp we will be changing the format of the output possible breaking ongoing applications. we can go over this by adding a new api call but (third), we developed the ES plugin just for that (between other reasons), to don't add more stuff the the current api outputs, now is timestamp, then is filter by op, then filter by transaction, and so on.

the ES is a global solution for this kind of situations of all kind of searches inside account history.

I agree there is no infrastructure but all you need is to setup your own node with ES to make use of the new api.

@oxarbitrage
Copy link
Member

we need to educate IMHO to start resolving this issues by the plugin where everything can be done instead of just adding more stuff to the account history api outputs and more api calls.

@abitmore
Copy link
Member

abitmore commented Oct 2, 2022

Done via #2642

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 a pull request may close this issue.

4 participants