Replace string_to_hex with boost::algorithm::hex

This commit is contained in:
Vlad Dobromyslov 2022-08-03 11:10:30 +03:00
parent 776dc729b5
commit 7f3e7e876a

View file

@ -23,18 +23,6 @@
namespace graphene { namespace peerplays_sidechain { namespace graphene { namespace peerplays_sidechain {
std::string string_to_hex(const std::string& in)
{
std::stringstream ss;
ss << std::hex << std::setfill('0');
for (size_t i = 0; in.length() > i; ++i) {
ss << std::setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(in[i]));
}
return ss.str();
}
ethereum_rpc_client::ethereum_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls) : ethereum_rpc_client::ethereum_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls) :
rpc_client(url, user_name, password, debug_rpc_calls) { rpc_client(url, user_name, password, debug_rpc_calls) {
} }
@ -91,7 +79,7 @@ std::string ethereum_rpc_client::get_transaction_receipt(const std::string& para
data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), owner.second)).str(); data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), owner.second)).str();
} }
data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), object_id.size())).str(); data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), object_id.size())).str();
data += string_to_hex(object_id) + std::string( (64 - object_id.size() * 2 % 64), '0' ); data += boost::algorithm::hex(object_id) + std::string( (64 - object_id.size() * 2 % 64), '0' );
return data; return data;
}(); }();
@ -668,7 +656,7 @@ std::string sidechain_net_handler_ethereum::create_primary_wallet_transaction(co
data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), owner.second)).str(); data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), owner.second)).str();
} }
data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), object_id.size())).str(); data += (boost::format("%x") % boost::io::group(std::setw(64), std::setfill('0'), object_id.size())).str();
data += string_to_hex(object_id) + std::string( (64 - object_id.size() * 2 % 64), '0' ); data += boost::algorithm::hex(object_id) + std::string( (64 - object_id.size() * 2 % 64), '0' );
return data; return data;
}(); }();