1
0
Fork 0
forked from lthn/blockchain

various improvements

This commit is contained in:
sowle 2024-09-23 05:13:26 +02:00
parent c82809a0b9
commit 37e62ac079
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
5 changed files with 21 additions and 7 deletions

View file

@ -123,6 +123,15 @@ namespace crypto
return generate_schnorr_sig(m, point_t(A), scalar_t(secret_a), result);
}
inline bool generate_schnorr_sig(const hash& m, const secret_key& secret_a, generic_schnorr_sig& result)
{
scalar_t secret_a_s(secret_a);
if (!secret_a_s.is_reduced())
return false;
point_t A = secret_a_s * c_point_G;
return generate_schnorr_sig_custom_generator(m, A, secret_a_s, result, c_point_G);
}
template<generator_tag gen = gt_G>
inline bool verify_schnorr_sig(const hash& m, const public_key& A, const generic_schnorr_sig& sig) noexcept;

View file

@ -843,7 +843,7 @@ namespace currency
struct asset_operation_ownership_proof_eth
{
crypto::eth_signature eth_sig;
crypto::eth_signature eth_sig; // 64 bytes
uint8_t version = 0;
BEGIN_VERSIONED_SERIALIZE(0, version)

View file

@ -950,6 +950,12 @@ namespace currency
}
}
//---------------------------------------------------------------
template<typename invocable_t>
typename std::enable_if_t<std::is_invocable_v<invocable_t, std::ostream&>, std::ostream&> operator<<(std::ostream& o, invocable_t callee)
{
callee(o);
return o;
}
//---------------------------------------------------------------
std::ostream& operator <<(std::ostream& o, const ref_by_id& r);
std::ostream& operator <<(std::ostream& o, const std::type_info& ti);

View file

@ -75,7 +75,8 @@ namespace currency
return true;
}
#define check_core_ready() check_core_ready_(LOCAL_FUNCTION_DEF__)
#define CHECK_CORE_READY() if(!check_core_ready()){res.status = API_RETURN_CODE_BUSY;return true;}
#define CHECK_CORE_READY() if (!check_core_ready()) {res.status = API_RETURN_CODE_BUSY; return true; }
#define CHECK_CORE_READY_WE() if (!check_core_ready()) {error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY; error_resp.message = "Core is busy."; return false; }
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res, connection_context& cntx)
{
@ -1001,7 +1002,7 @@ namespace currency
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
{
CHECK_CORE_READY();
CHECK_CORE_READY_WE();
if(req.size()!=1)
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
@ -1044,8 +1045,7 @@ namespace currency
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_submitblock2(const COMMAND_RPC_SUBMITBLOCK2::request& req, COMMAND_RPC_SUBMITBLOCK2::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
{
CHECK_CORE_READY();
CHECK_CORE_READY_WE();
block b = AUTO_VAL_INIT(b);
if (!parse_and_validate_block_from_blob(req.b, b))

View file

@ -238,8 +238,7 @@ bool t_unserializable_object_from_blob(t_object& to, const std::string& blob)
ss << blob;
binary_archive<false> ba(ss);
bool r = ::serialization::serialize(ba, to);
CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob");
return true;
return r;
}
//---------------------------------------------------------------
template<class t_object>