Naming changes and reintroducing key prefix to contract libraries. (#202)

This commit is contained in:
Ravin Perera
2020-12-23 19:23:46 +05:30
committed by GitHub
parent e835e18d18
commit 8dc20bdab0
8 changed files with 107 additions and 99 deletions

View File

@@ -196,9 +196,8 @@ int main(int argc, char **argv)
hplog::init();
LOG_INFO << "Hot Pocket " << util::HP_VERSION;
LOG_INFO << "Role: "
<< (conf::cfg.node.role == conf::ROLE::OBSERVER ? "Observer" : "Validator");
LOG_INFO << "Public key: " << conf::cfg.node.pub_key_hex.substr(2); // Public key without 'ed' prefix.
LOG_INFO << "Role: " << (conf::cfg.node.role == conf::ROLE::OBSERVER ? "Observer" : "Validator");
LOG_INFO << "Public key: " << conf::cfg.node.pub_key_hex;
LOG_INFO << "Contract: " << conf::cfg.contract.id << " (" << conf::cfg.contract.version << ")";
if (ledger::init() == -1 ||

View File

@@ -80,7 +80,7 @@ namespace msg::controlmsg::json
for (const auto &v : d[field_name].array_range())
{
std::string hex_pubkey = "ed" + v.as<std::string>();
std::string_view hex_pubkey = v.as<std::string_view>();
std::string bin_pubkey;
bin_pubkey.resize(crypto::PFXD_PUBKEY_BYTES);
if (util::hex2bin(

View File

@@ -258,7 +258,7 @@ namespace sc
std::ostringstream os;
os << "{\"version\":\"" << util::HP_VERSION
<< "\",\"pubkey\":\"" << conf::cfg.node.pub_key_hex.substr(2)
<< "\",\"pubkey\":\"" << conf::cfg.node.pub_key_hex
<< "\",\"ts\":" << ctx.args.time
<< ",\"readonly\":" << (ctx.args.readonly ? "true" : "false");
@@ -440,8 +440,8 @@ namespace sc
std::string pubkeyhex;
util::bin2hex(
pubkeyhex,
reinterpret_cast<const unsigned char *>(npl_msg.pubkey.data()) + 1, // Skip first byte for key type prefix.
npl_msg.pubkey.length() - 1);
reinterpret_cast<const unsigned char *>(npl_msg.pubkey.data()),
npl_msg.pubkey.length());
// Writing the public key to the contract's fd (Skip first byte for key type prefix).
if (write(writefd, pubkeyhex.data(), pubkeyhex.size()) == -1)

View File

@@ -166,8 +166,8 @@ namespace unl
std::string pubkeyhex;
util::bin2hex(
pubkeyhex,
reinterpret_cast<const unsigned char *>(pk->data()) + 1,
pk->length() - 1);
reinterpret_cast<const unsigned char *>(pk->data()),
pk->length());
os << "\"" << pubkeyhex << "\"";
}