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

get_block changes #275

Closed
wants to merge 1 commit into from
Closed

Conversation

oxarbitrage
Copy link
Member

Return account_transaction_history_object in get_block for transfers.

Issue #243

Can be probably make it shorter but it seems to be working.

the transfer operation return empty operation_results, the new function will place a 2.9.X here. As the operation result is already empty for transfer, client sides applications will not be affected.

Works only for the transfer operation as it needs the from account field of it to get the 2.9.X object.

The 2.9.X could be replaced by a 1.11 if we decide to don't expose 2.9 anymore(#265).

It can be extended to work with other(all?) operations but that will mean changes in the current and maybe consumed by clients operation_results functionality.

I don't expect this pull request to be accepted as it is but to build together something more general.

Samples:

block from @xeroc issue: #243

root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_block", [14448783]], "method": "call", "id": 10}' http://localhost:8090/rpc | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1172  100  1077  100    95  59110   5214 --:--:-- --:--:-- --:--:-- 59833
{
  "id": 10,
  "result": {
    "previous": "00dc788eee4533479fde0b9189e310017beade53",
    "timestamp": "2017-03-02T11:56:33",
    "witness": "1.6.17",
    "transaction_merkle_root": "2b114c0d45b77198880cdcce5a8be512014b622b",
    "extensions": [],
    "witness_signature": "201c2f657322e05c71a32dd975419365978dfe96c1d29df41e16ff5a079b7a545d48f0d81d23b1a3c7b0b90853d0d7b8fea4ba126707fcd5c762a16f33c2cd58d7",
    "transactions": [
      {
        "ref_block_num": 30862,
        "ref_block_prefix": 1194542574,
        "expiration": "2017-03-02T11:56:48",
        "operations": [
          [
            0,
            {
              "fee": {
                "amount": 279652,
                "asset_id": "1.3.0"
              },
              "from": "1.2.100665",
              "to": "1.2.36644",
              "amount": {
                "amount": 7294494,
                "asset_id": "1.3.861"
              },
              "memo": {
                "from": "BTS5AjtESJLTuBmL5hDSLeuigpkWDTe4ZUSjugwAvHSzMJWEUbDAf",
                "to": "BTS7tqXBbtJwDoT8b2LY3kx547ocVfSacTirBMFEsDyhGf2FNR48p",
                "nonce": "381044681844390",
                "message": "1afad56165a60016979d78d3162bc172d83a40025c7e57873625152367c483e0"
              },
              "extensions": []
            }
          ]
        ],
        "extensions": [],
        "signatures": [
          "1f620755f8c7384ed94a748f3f6aec083892b1a8cfab34a411c12fa01b29fa25a70e0f181fa083c76247692938b58e8f9baac0e98d0e38cc271619b7ed72dece07"
        ],
        "operation_results": [
          [
            1,
            "2.9.9559052"
          ]
        ]
      }
    ]
  }
}

root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_objects", [["2.9.9559052"]]], "method": "call", "id": 10}' http://localhost:8090/r
pc | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   233  100   129  100   104   139k   112k --:--:-- --:--:-- --:--:--  125k
{
  "id": 10,
  "result": [
    {
      "id": "2.9.9559052",
      "account": "1.2.100665",
      "operation_id": "1.11.9349261",
      "sequence": 51,
      "next": "2.9.5934581"
    }
  ]
}
root@alfredo:~#  curl --data '{"jsonrpc": "2.0", "params": ["database", "get_objects", [["1.11.9349261"]]], "method": "call", "id": 10}' http://localhost:8090
/rpc | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   625  100   520  100   105   637k   128k --:--:-- --:--:-- --:--:--  507k
{
  "id": 10,
  "result": [
    {
      "id": "1.11.9349261",
      "op": [
        0,
        {
          "fee": {
            "amount": 279652,
            "asset_id": "1.3.0"
          },
          "from": "1.2.100665",
          "to": "1.2.36644",
          "amount": {
            "amount": 7294494,
            "asset_id": "1.3.861"
          },
          "memo": {
            "from": "BTS5AjtESJLTuBmL5hDSLeuigpkWDTe4ZUSjugwAvHSzMJWEUbDAf",
            "to": "BTS7tqXBbtJwDoT8b2LY3kx547ocVfSacTirBMFEsDyhGf2FNR48p",
            "nonce": "381044681844390",
            "message": "1afad56165a60016979d78d3162bc172d83a40025c7e57873625152367c483e0"
          },
          "extensions": []
        }
      ],
      "result": [
        0,
        {}
      ],
      "block_num": 14448783,
      "trx_in_block": 0,
      "op_in_trx": 0,
      "virtual_op": 9252
    }
  ]
}
root@alfredo:~# 

A Block with several transactions and a transfer.

root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_block", [16292266]], "method": "call", "id": 10}' http://localhost:8090/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2803  100  2708  100    95   497k  17863 --:--:-- --:--:-- --:--:--  528k
{
  "id": 10,
  "result": {
    "previous": "00f899a9915e7f4703acc49625cfc3db5002c3f9",
    "timestamp": "2017-05-06T04:28:24",
    "witness": "1.6.23",
    "transaction_merkle_root": "34bfa8eaf131c342c8c5538b4302f9f24bc8fae8",
    "extensions": [],
    "witness_signature": "202c2446abfb78eb9fda49da0ed937ea1ec8348616b278a16993808b8a95f7b6275f37c4775b0e5ff97dc40906f2c1c807170c52f38538482a158078fb5d2d8027",
    "transactions": [
      {
        "ref_block_num": 39336,
        "ref_block_prefix": 3064895919,
        "expiration": "2017-05-07T04:26:19",
        "operations": [
          [
            2,
            {
              "fee": {
                "amount": 725,
                "asset_id": "1.3.0"
              },
              "fee_paying_account": "1.2.134639",
              "order": "1.7.4536742",
              "extensions": []
            }
          ],
          [
            2,
            {
              "fee": {
                "amount": 725,
                "asset_id": "1.3.0"
              },
              "fee_paying_account": "1.2.134639",
              "order": "1.7.4536756",
              "extensions": []
            }
          ],
          [
            2,
            {
              "fee": {
                "amount": 725,
                "asset_id": "1.3.0"
              },
              "fee_paying_account": "1.2.134639",
              "order": "1.7.4536743",
              "extensions": []
            }
          ],
          [
            1,
            {
              "fee": {
                "amount": 7256,
                "asset_id": "1.3.0"
              },
              "seller": "1.2.134639",
              "amount_to_sell": {
                "amount": "9512575225",
                "asset_id": "1.3.1152"
              },
              "min_to_receive": {
                "amount": 2329901460,
                "asset_id": "1.3.860"
              },
              "expiration": "1963-11-25T17:31:44",
              "fill_or_kill": false,
              "extensions": []
            }
          ],
          [
            1,
            {
              "fee": {
                "amount": 7256,
                "asset_id": "1.3.0"
              },
              "seller": "1.2.134639",
              "amount_to_sell": {
                "amount": 533929837,
                "asset_id": "1.3.0"
              },
              "min_to_receive": {
                "amount": "10463832742",
                "asset_id": "1.3.1152"
              },
              "expiration": "1963-11-25T17:31:44",
              "fill_or_kill": false,
              "extensions": []
            }
          ],
          [
            1,
            {
              "fee": {
                "amount": 7256,
                "asset_id": "1.3.0"
              },
              "seller": "1.2.134639",
              "amount_to_sell": {
                "amount": 10496980,
                "asset_id": "1.3.860"
              },
              "min_to_receive": {
                "amount": 63643107,
                "asset_id": "1.3.1152"
              },
              "expiration": "1963-11-25T17:31:44",
              "fill_or_kill": false,
              "extensions": []
            }
          ]
        ],
        "extensions": [],
        "signatures": [
          "1f4b67e6fa4cc4d14eb29d26972cdb8c66ef9bb640fa8dad3e41ffe0dec9f99b1213be42172ec0a9dd9c3249aae91f71f62dd8a2d0798d8e6a610525b8f604f84b"
        ],
        "operation_results": [
          [
            2,
            {
              "amount": "9655005309",
              "asset_id": "1.3.1152"
            }
          ],
          [
            2,
            {
              "amount": 534088260,
              "asset_id": "1.3.0"
            }
          ],
          [
            2,
            {
              "amount": 10496980,
              "asset_id": "1.3.860"
            }
          ],
          [
            1,
            "1.7.4536797"
          ],
          [
            1,
            "1.7.4536798"
          ],
          [
            1,
            "1.7.4536799"
          ]
        ]
      },
      {
        "ref_block_num": 39337,
        "ref_block_prefix": 1199529617,
        "expiration": "2017-05-06T04:28:51",
        "operations": [
          [
            0,
            {
              "fee": {
                "amount": 138278,
                "asset_id": "1.3.0"
              },
              "from": "1.2.152540",
              "to": "1.2.20067",
              "amount": {
                "amount": "11845500000",
                "asset_id": "1.3.0"
              },
              "memo": {
                "from": "BTS7zt24RA1B4NTfahx7PNFe2Gmhc8DVukH6nhZkQk2w2i4BEfKNy",
                "to": "BTS8citBkJYULm8oRsscFbU277GwPMm2NaELESncQqBgynyoKeFK8",
                "nonce": "14340955258448188367",
                "message": "94b2c49ca4a1dd69cbc2975abfd26a753095f18cc1891fe66481f1d16e8e347e"
              },
              "extensions": []
            }
          ]
        ],
        "extensions": [],
        "signatures": [
          "1f1d99caaf147a7fef2f40e0d64850d681860f8aaedb074ed037d5b1ee9355fd6226b9bcf4e25ad7dc3e511fce7d4db7bd84cd193085abf972dd125a96715f0e0d"
        ],
        "operation_results": [
          [
            1,
            "2.9.16017504"
          ]
        ]
      }
    ]
  }
}
root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_objects", [["2.9.16017504"]]], "method": "call", "id": 10}' http://localhost:8090/
rpc | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   239  100   134  100   105   171k   134k --:--:-- --:--:-- --:--:--  130k
{
  "id": 10,
  "result": [
    {
      "id": "2.9.16017504",
      "account": "1.2.152540",
      "operation_id": "1.11.15756547",
      "sequence": 4475,
      "next": "2.9.16015622"
    }
  ]
}
root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_objects", [["1.11.15756547"]]], "method": "call", "id": 10}' http://localhost:8090/
/rpc | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   637  100   531  100   106   540k   107k --:--:-- --:--:-- --:--:--  518k
{
  "id": 10,
  "result": [
    {
      "id": "1.11.15756547",
      "op": [
        0,
        {
          "fee": {
            "amount": 138278,
            "asset_id": "1.3.0"
          },
          "from": "1.2.152540",
          "to": "1.2.20067",
          "amount": {
            "amount": "11845500000",
            "asset_id": "1.3.0"
          },
          "memo": {
            "from": "BTS7zt24RA1B4NTfahx7PNFe2Gmhc8DVukH6nhZkQk2w2i4BEfKNy",
            "to": "BTS8citBkJYULm8oRsscFbU277GwPMm2NaELESncQqBgynyoKeFK8",
            "nonce": "14340955258448188367",
            "message": "94b2c49ca4a1dd69cbc2975abfd26a753095f18cc1891fe66481f1d16e8e347e"
          },
          "extensions": []
        }
      ],
      "result": [
        0,
        {}
      ],
      "block_num": 16292266,
      "trx_in_block": 1,
      "op_in_trx": 0,
      "virtual_op": 59614
    }
  ]
}
root@alfredo:~# 

Return account_transaction_history_object in get_block for transfers.
@xeroc
Copy link
Member

xeroc commented May 15, 2017

looking good!
Does this also work for very old blocks?
I am a little uncertain about the amount of data stored in the database

@oxarbitrage
Copy link
Member Author

thanks. can you send me block number example to test ?

@xeroc
Copy link
Member

xeroc commented Jul 31, 2017

Can we merge this PR?

@pmconrad pmconrad changed the base branch from master to develop July 31, 2017 09:58
@oxarbitrage
Copy link
Member Author

hi @xeroc , not exactly as it is, let me make some changes.

@abitmore abitmore added the 2a Discussion Needed Prompt for team to discuss at next stand up. label Apr 17, 2018
@oxarbitrage oxarbitrage deleted the patch-8 branch August 23, 2018 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2a Discussion Needed Prompt for team to discuss at next stand up.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants