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

Commit

Permalink
Merge pull request #950 from GolosChain/golos-v0.18.5
Browse files Browse the repository at this point in the history
Golos v0.18.5
  • Loading branch information
afalaleev authored Sep 4, 2018
2 parents 9ee5f5f + f8bb091 commit 88088b7
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 71 deletions.
2 changes: 2 additions & 0 deletions libraries/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ list(APPEND CURRENT_TARGET_HEADERS
include/golos/api/vote_state.hpp
include/golos/api/account_vote.hpp
include/golos/api/discussion_helper.hpp
include/golos/api/block_objects.hpp
)

list(APPEND CURRENT_TARGET_SOURCES
account_api_object.cpp
discussion_helper.cpp
chain_api_properties.cpp
witness_api_object.cpp
block_objects.cpp
)

if(BUILD_SHARED_LIBRARIES)
Expand Down
24 changes: 24 additions & 0 deletions libraries/api/block_objects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <golos/api/block_objects.hpp>

namespace golos { namespace api {

block_operation::block_operation() = default;

annotated_signed_block::annotated_signed_block() = default;

annotated_signed_block::annotated_signed_block(const signed_block& block)
: signed_block(block) {
block_id = id();
signing_key = signee();
transaction_ids.reserve(transactions.size());
for (const signed_transaction& tx : transactions) {
transaction_ids.push_back(tx.id());
}
}

annotated_signed_block::annotated_signed_block(const signed_block& block, const block_operations& ops)
: annotated_signed_block(block) {
_virtual_operations = ops;
}

} } // golos::api
58 changes: 58 additions & 0 deletions libraries/api/include/golos/api/block_objects.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#pragma once

#include <golos/chain/account_object.hpp>
#include <golos/chain/database.hpp>
#include <golos/chain/operation_notification.hpp>
#include <golos/chain/steem_object_types.hpp>
#include <golos/protocol/types.hpp>

namespace golos { namespace api {

using namespace golos::protocol;
using golos::chain::operation_notification;

// block_operation used in block_applied_callback to represent virtual operations.
// default operation type have no position info (trx, op_in_trx)
struct block_operation {

block_operation();

block_operation(const operation_notification& o) :
trx_in_block(o.trx_in_block),
op_in_trx(o.op_in_trx),
virtual_op(o.virtual_op),
op(o.op) {};

uint32_t trx_in_block = 0;
uint16_t op_in_trx = 0;
uint32_t virtual_op = 0;
operation op;
};

using block_operations = std::vector<block_operation>;

struct annotated_signed_block : public signed_block {

annotated_signed_block();

annotated_signed_block(const signed_block& block);

annotated_signed_block(const signed_block& block, const block_operations& ops);

annotated_signed_block(const annotated_signed_block& block) = default;

block_id_type block_id;
public_key_type signing_key;
vector<transaction_id_type> transaction_ids;

// name field starting with _ coz it's not directly related to block
optional<block_operations> _virtual_operations;
};

} } // golos::api


FC_REFLECT((golos::api::block_operation),
(trx_in_block)(op_in_trx)(virtual_op)(op))
FC_REFLECT_DERIVED((golos::api::annotated_signed_block), ((golos::chain::signed_block)),
(block_id)(signing_key)(transaction_ids)(_virtual_operations))
2 changes: 1 addition & 1 deletion libraries/protocol/include/golos/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
#pragma once

#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 18, 4))
#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 18, 5))
#define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION (hardfork_version(STEEMIT_BLOCKCHAIN_VERSION))

#ifdef STEEMIT_BUILD_TESTNET
Expand Down
3 changes: 2 additions & 1 deletion libraries/wallet/include/golos/wallet/remote_node_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <golos/api/account_api_object.hpp>
#include <golos/api/account_vote.hpp>
#include <golos/api/block_objects.hpp>
#include <golos/api/discussion.hpp>
#include <golos/api/vote_state.hpp>

Expand Down Expand Up @@ -46,7 +47,7 @@ using namespace golos::api;
* Class is used by wallet to send formatted API calls to database_api plugin on remote node.
*/
struct remote_database_api {
optional< database_api::signed_block > get_block( uint32_t );
optional< golos::api::annotated_signed_block > get_block( uint32_t );
optional< block_header > get_block_header( uint32_t );
fc::variant_object get_config();
database_api::dynamic_global_property_object get_dynamic_global_properties();
Expand Down
14 changes: 1 addition & 13 deletions libraries/wallet/include/golos/wallet/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ namespace golos { namespace wallet {
string ws_server = "ws://localhost:8091";
};

struct signed_block_with_info: public signed_block {
signed_block_with_info(const signed_block& block);
signed_block_with_info(const signed_block_with_info& block) = default;

block_id_type block_id;
public_key_type signing_key;
vector<transaction_id_type> transaction_ids;
};

struct key_with_data {
std::string account;
std::string type;
Expand Down Expand Up @@ -262,7 +253,7 @@ namespace golos { namespace wallet {
*
* @returns Public block data on the blockchain
*/
optional<signed_block_with_info> get_block(uint32_t num);
optional<golos::api::annotated_signed_block> get_block(uint32_t num);

/** Returns sequence of operations included/generated in a specified block
*
Expand Down Expand Up @@ -1345,9 +1336,6 @@ namespace golos { namespace wallet {

FC_REFLECT((golos::wallet::wallet_data), (cipher_keys)(ws_server))

FC_REFLECT_DERIVED((golos::wallet::signed_block_with_info), ((golos::chain::signed_block)),
(block_id)(signing_key)(transaction_ids))

FC_REFLECT( (golos::wallet::brain_key_info), (brain_priv_key)(wif_priv_key) (pub_key))

FC_REFLECT( (golos::wallet::plain_keys), (checksum)(keys) )
Expand Down
11 changes: 1 addition & 10 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ namespace golos { namespace wallet {
return my->copy_wallet_file(destination_filename);
}

optional<signed_block_with_info> wallet_api::get_block(uint32_t num) {
optional<golos::api::annotated_signed_block> wallet_api::get_block(uint32_t num) {
return my->_remote_database_api->get_block( num );
}

Expand Down Expand Up @@ -1644,15 +1644,6 @@ fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_st
return std::make_pair( public_key_type( priv.get_public_key() ), key_to_wif( priv ) );
}

signed_block_with_info::signed_block_with_info(const signed_block& block): signed_block(block) {
block_id = id();
signing_key = signee();
transaction_ids.reserve(transactions.size());
for (const signed_transaction& tx : transactions) {
transaction_ids.push_back(tx.id());
}
}

witness_api::feed_history_api_object wallet_api::get_feed_history()const {
return my->_remote_witness_api->get_feed_history();
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/account_history/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ if (options.count(name)) { \
}

void plugin::set_program_options(bpo::options_description& cli, bpo::options_description& cfg) {
cli.add_options()(
cfg.add_options()(
"track-account-range",
bpo::value<std::vector<std::string>>()->composing()->multitoken(),
"Defines a range of accounts to track as a json pair [\"from\",\"to\"] [from,to]. "
Expand All @@ -525,7 +525,6 @@ if (options.count(name)) { \
"Defines a individual account to track (in addition to ranges). "
"Can be specified multiple times"
);
cfg.add(cli);
}

void plugin::plugin_initialize(const bpo::variables_map& options) {
Expand Down
34 changes: 4 additions & 30 deletions plugins/database_api/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <golos/protocol/get_config.hpp>
#include <golos/protocol/exceptions.hpp>
#include <golos/chain/operation_notification.hpp>
#include <golos/api/block_objects.hpp>

#include <fc/smart_ref_impl.hpp>

Expand All @@ -15,6 +16,8 @@

namespace golos { namespace plugins { namespace database_api {

using golos::api::annotated_signed_block;
using golos::api::block_operations;

template<typename arg>
struct callback_info {
Expand Down Expand Up @@ -49,31 +52,6 @@ using pending_tx_callback_info = callback_info<const signed_transaction&>;
using pending_tx_callback = pending_tx_callback_info::callback_t;


// block_operation used in block_applied_callback to represent virtual operations.
// default operation type have no position info (trx, op_in_trx)
struct block_operation {
block_operation(const operation_notification& o) :
trx_in_block(o.trx_in_block),
op_in_trx(o.op_in_trx),
virtual_op(o.virtual_op),
op(o.op) {};

uint32_t trx_in_block = 0;
uint16_t op_in_trx = 0;
uint32_t virtual_op = 0;
operation op;
};

using block_operations = std::vector<block_operation>;

struct block_with_vops : public signed_block {
block_with_vops(signed_block b, block_operations ops): signed_block(b), _virtual_operations(ops) {
};

// name field starting with _ coz it's not directly related to block
block_operations _virtual_operations;
};

struct virtual_operations {
virtual_operations(uint32_t block_num, block_operations ops): block_num(block_num), operations(ops) {
};
Expand Down Expand Up @@ -243,7 +221,7 @@ DEFINE_API(plugin, set_block_applied_callback) {
r = fc::variant(virtual_operations(block.block_num(), my->get_block_vops()));
break;
case full:
r = fc::variant(block_with_vops(block, my->get_block_vops()));
r = fc::variant(annotated_signed_block(block, my->get_block_vops()));
break;
default:
break;
Expand Down Expand Up @@ -926,9 +904,5 @@ void plugin::plugin_startup() {
} } } // golos::plugins::database_api

FC_REFLECT((golos::plugins::database_api::virtual_operations), (block_num)(operations))
FC_REFLECT((golos::plugins::database_api::block_operation),
(trx_in_block)(op_in_trx)(virtual_op)(op))
FC_REFLECT_DERIVED((golos::plugins::database_api::block_with_vops), ((golos::protocol::signed_block)),
(_virtual_operations))
FC_REFLECT_ENUM(golos::plugins::database_api::block_applied_callback_result_type,
(block)(header)(virtual_ops)(full))
2 changes: 1 addition & 1 deletion plugins/debug_node/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void plugin::set_program_options (
boost::program_options::options_description &cli,
boost::program_options::options_description &cfg
) {
cli.add_options()
cfg.add_options()
("debug-node-edit-script,e",
boost::program_options::value< std::vector< std::string > >()->composing(),
"Database edits to apply on startup (may specify multiple times)")
Expand Down
3 changes: 1 addition & 2 deletions plugins/follow/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,9 @@ namespace golos {

void plugin::set_program_options(boost::program_options::options_description& cli,
boost::program_options::options_description& cfg) {
cli.add_options()
cfg.add_options()
("follow-max-feed-size", boost::program_options::value<uint32_t>()->default_value(500),
"Set the maximum size of cached feed for an account");
cfg.add(cli);
}

void plugin::plugin_initialize(const boost::program_options::variables_map& options) {
Expand Down
3 changes: 1 addition & 2 deletions plugins/market_history/market_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,13 @@ namespace golos {
boost::program_options::options_description &cli,
boost::program_options::options_description &cfg
) {
cli.add_options()
cfg.add_options()
("market-history-bucket-size",
boost::program_options::value<string>()->default_value("[15,60,300,3600,86400]"),
"Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers")
("market-history-buckets-per-size",
boost::program_options::value<uint32_t>()->default_value(5760),
"How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)");
cfg.add(cli);
}

void market_history_plugin::plugin_initialize(const boost::program_options::variables_map &options) {
Expand Down
3 changes: 1 addition & 2 deletions plugins/mongo_db/mongo_db_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace mongo_db {
boost::program_options::options_description &cli,
boost::program_options::options_description &cfg
) {
cli.add_options()
cfg.add_options()
("mongodb-uri",
boost::program_options::value<string>()->default_value("mongodb://127.0.0.1:27017/Golos"),
"Mongo DB connection string")
Expand All @@ -71,7 +71,6 @@ namespace mongo_db {
("mongodb-store-wso-history",
boost::program_options::value<unsigned int>()->default_value(100),
"Mode of storing witness_schedule_object history for each N block");
cfg.add(cli);
}

void mongo_db_plugin::plugin_initialize(const boost::program_options::variables_map &options) {
Expand Down
3 changes: 2 additions & 1 deletion plugins/network_broadcast_api/network_broadcast_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ namespace golos {

DEFINE_API(network_broadcast_api_plugin, broadcast_transaction_synchronous) {
PLUGIN_API_VALIDATE_ARGS(
(std::string, unused) // TODO: remove in HF
(signed_transaction, trx)
(uint32_t, max_block_age, 0)
);
if (n_args >= 2) {
if (n_args >= 3) {
GOLOS_CHECK_PARAM(max_block_age, GOLOS_CHECK_VALUE(!check_max_block_age(max_block_age), "Invalid value"));
}

Expand Down
1 change: 1 addition & 0 deletions plugins/operation_history/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ target_link_libraries (
graphene_time
chainbase
fc
golos::api
)

target_include_directories(golos_${CURRENT_TARGET}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <appbase/application.hpp>
#include <golos/plugins/chain/plugin.hpp>

#include <golos/api/block_objects.hpp>
#include <golos/chain/database.hpp>
#include <boost/program_options.hpp>

Expand All @@ -38,10 +39,15 @@
namespace golos { namespace plugins { namespace operation_history {
using namespace chain;

using golos::api::annotated_signed_block;
using golos::api::block_operation;
using golos::api::block_operations;

using plugins::json_rpc::void_type;
using plugins::json_rpc::msg_pack;
using plugins::json_rpc::msg_pack_transfer;

DEFINE_API_ARGS(get_block_with_virtual_ops, msg_pack, annotated_signed_block)
DEFINE_API_ARGS(get_ops_in_block, msg_pack, std::vector<applied_operation>)
DEFINE_API_ARGS(get_transaction, msg_pack, annotated_signed_transaction)

Expand Down Expand Up @@ -70,6 +76,8 @@ namespace golos { namespace plugins { namespace operation_history {
void plugin_shutdown() override;

DECLARE_API(
(get_block_with_virtual_ops)

/**
* @brief Get sequence of operations included/generated within a particular block
* @param block_num Height of the block whose generated virtual operations should be returned
Expand Down
Loading

0 comments on commit 88088b7

Please sign in to comment.