2019-12-04 17:52:00 +00:00
|
|
|
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
#include <graphene/chain/sidechain_address_object.hpp>
|
|
|
|
|
|
|
|
|
|
#include <fc/log/logger.hpp>
|
|
|
|
|
|
2019-12-04 17:52:00 +00:00
|
|
|
namespace graphene { namespace peerplays_sidechain {
|
|
|
|
|
|
2020-02-04 18:31:45 +00:00
|
|
|
sidechain_net_handler::sidechain_net_handler(peerplays_sidechain_plugin& _plugin, const boost::program_options::variables_map& options) :
|
|
|
|
|
plugin(_plugin),
|
|
|
|
|
database(_plugin.database())
|
2019-12-18 18:30:38 +00:00
|
|
|
{
|
2019-12-04 17:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sidechain_net_handler::~sidechain_net_handler() {
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-04 18:31:45 +00:00
|
|
|
graphene::peerplays_sidechain::sidechain_type sidechain_net_handler::get_sidechain() {
|
|
|
|
|
return sidechain;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
std::vector<std::string> sidechain_net_handler::get_sidechain_addresses() {
|
2019-12-04 17:52:00 +00:00
|
|
|
std::vector<std::string> result;
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
switch (sidechain) {
|
|
|
|
|
case sidechain_type::bitcoin:
|
|
|
|
|
{
|
2020-02-04 18:31:45 +00:00
|
|
|
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
|
2019-12-18 18:30:38 +00:00
|
|
|
const auto& sidechain_addresses_by_sidechain_idx = sidechain_addresses_idx.indices().get<by_sidechain>();
|
|
|
|
|
const auto& sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
|
|
|
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
|
|
|
|
[&result] (const sidechain_address_object& sao) {
|
|
|
|
|
result.push_back(sao.address);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-12-04 17:52:00 +00:00
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_data& sed) {
|
|
|
|
|
ilog( __FUNCTION__ );
|
|
|
|
|
ilog( "sidechain_event_data:" );
|
|
|
|
|
ilog( " sidechain: ${sidechain}", ( "sidechain", sed.sidechain ) );
|
|
|
|
|
ilog( " transaction_id: ${transaction_id}", ( "transaction_id", sed.transaction_id ) );
|
|
|
|
|
ilog( " from: ${from}", ( "from", sed.from ) );
|
|
|
|
|
ilog( " to: ${to}", ( "to", sed.to ) );
|
|
|
|
|
ilog( " amount: ${amount}", ( "amount", sed.amount ) );
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 17:52:00 +00:00
|
|
|
} } // graphene::peerplays_sidechain
|
|
|
|
|
|