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

Added annotated_signed_block #936 #945

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

maslenitsa93
Copy link

@maslenitsa93 maslenitsa93 commented Aug 28, 2018

#936

Checklists

Use testnet.

Check refactored cli_wallet's get_block (based on database_api's get_block):

Run following cli-wallet script (note: run it after block 4 applied):

./cli_wallet --server-rpc-endpoint=ws://127.0.0.1:8091
set_password qwer
unlock qwer
import_key 5JVFFWRLwz6JoP9kguuRFfytToGU6cLgBVTL9t6NB3D3BQLbUBS
get_block 4

Result:

{
  ...
  "timestamp": ...,
  ...
  "transactions": [{
      ...
      "expiration": ...,
      "operations": [[
          "pow2", ...
        ]
      ],
      "extensions": [],
      "signatures": [
        ...
      ]
    }
  ],
  "block_id": "0000000000000000000000000000000000000000",
  "signing_key": "GLS1111111111111111111111111111111114T1Anm",
  "transaction_ids": []
}

Check new method get_block_with_virtual_ops

  1. Run this HTML script in browser before block 80 applied (note: this is a block applying after all hardforks):
<script src="node_modules/golos-js/dist/golos.min.js"></script>
Hello world
<script>
golos.config.set('websocket', 'ws://127.0.0.1:8091');
golos.api.send("operation_history", {"method": "get_block_with_virtual_ops", "params":[80]},
    function (err, result) {
document.body.innerHTML += '<pre>' + JSON.stringify(result, null, 2) + "</pre>";
});
</script>

Result:

{
  "previous": "0000000000000000000000000000000000000000",
  "timestamp": "1970-01-01T00:00:00",
  "witness": "",
  "transaction_merkle_root": "0000000000000000000000000000000000000000",
  "extensions": [],
  "witness_signature": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "transactions": [],
  "block_id": "0000000000000000000000000000000000000000",
  "signing_key": "GLS1111111111111111111111111111111114T1Anm",
  "transaction_ids": []
}
  1. Now wait for this block and run again. Result:
{
  ...
  "timestamp": "2018-08-28T03:35:57",
  ...
  "_virtual_operations": [
    {
      "trx_in_block": 65535,
      "op_in_trx": 0,
      "virtual_op": 1,
      "op": [
        "producer_reward",
        ...
      ]
    }
  ]
}

Check refactored set_block_applied_callback

After all hardforks applied, run:

<script src="node_modules/golos-js/dist/golos.min.js"></script>
Hello world
<script>
golos.config.set('websocket', 'ws://127.0.0.1:8091');
golos.api.send("database_api", {"method": "set_block_applied_callback", "params":["full"]},
    function (err, result) {
document.body.innerHTML += '<pre>' + JSON.stringify(result, null, 2) + "</pre>";
});
</script>

Result:

{
  ...
  "timestamp": ...,
  ...
  "transaction_ids": [],
  "_virtual_operations": [
    {
      "trx_in_block": 65535,
      "op_in_trx": 0,
      "virtual_op": 1,
      "op": [
        "producer_reward",
        ...
      ]
    }
  ]
}

}
}

annotated_signed_block::annotated_signed_block(const signed_block& block, block_operations& ops)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(..., const block_operations& ops)


annotated_signed_block(const signed_block& block);

annotated_signed_block(const signed_block& block, block_operations& ops);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(..., const block_operations& ops)

auto sb = database.fetch_block_by_number(block_num);
if (!sb.valid()) {
return result;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what else ?


const auto& idx = database.get_index<operation_index>().indices().get<by_location>();
auto itr = idx.lower_bound(block_num);
block_operations ops;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result._virtual_operations = block_operations();

op.op_in_trx = itr->op_in_trx;
op.virtual_op = itr->virtual_op;
op.op = fc::raw::unpack<protocol::operation>(itr->serialized_op);
ops.push_back(op);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result._virtual_operations.push_back(op);

ops.push_back(op);
}
}
result._virtual_operations = ops;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove line.

@maslenitsa93 maslenitsa93 requested review from afalaleev and removed request for afalaleev August 28, 2018 05:00
@maslenitsa93
Copy link
Author

Fixing problem. 5 min.

@maslenitsa93 maslenitsa93 requested a review from afalaleev August 28, 2018 05:15
@maslenitsa93
Copy link
Author

Fixed. Review, please.

@afalaleev afalaleev modified the milestones: 0.19.0, 0.18.5 Aug 28, 2018
@afalaleev afalaleev changed the base branch from golos-v0.19.0 to golos-v0.18.5 August 28, 2018 12:09
@afalaleev
Copy link
Member

Rebase changes to one commit and change HEAD from golos-v0.19.0 to golos-v0.18.5

@maslenitsa93 maslenitsa93 force-pushed the 936-extend-get_ops_in_block branch 6 times, most recently from e7225a7 to ee96922 Compare August 28, 2018 12:47
@maslenitsa93 maslenitsa93 force-pushed the 936-extend-get_ops_in_block branch 5 times, most recently from e903797 to 8905450 Compare August 28, 2018 15:47
@maslenitsa93 maslenitsa93 force-pushed the 936-extend-get_ops_in_block branch 2 times, most recently from 1435b6a to 8905450 Compare August 28, 2018 15:49
@afalaleev afalaleev merged commit 43d2301 into golos-v0.18.5 Aug 28, 2018
@afalaleev afalaleev deleted the 936-extend-get_ops_in_block branch August 28, 2018 16:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants