core_rpc_server: return ID of submitted block
This commit is contained in:
parent
1ce32d8536
commit
842478c5a9
|
@ -2115,7 +2115,8 @@ namespace cryptonote
|
||||||
// Fixing of high orphan issue for most pools
|
// Fixing of high orphan issue for most pools
|
||||||
// Thanks Boolberry!
|
// Thanks Boolberry!
|
||||||
block b;
|
block b;
|
||||||
if(!parse_and_validate_block_from_blob(blockblob, b))
|
crypto::hash blk_id;
|
||||||
|
if(!parse_and_validate_block_from_blob(blockblob, b, blk_id))
|
||||||
{
|
{
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB;
|
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB;
|
||||||
error_resp.message = "Wrong block blob";
|
error_resp.message = "Wrong block blob";
|
||||||
|
@ -2138,6 +2139,7 @@ namespace cryptonote
|
||||||
error_resp.message = "Block not accepted";
|
error_resp.message = "Block not accepted";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
res.block_id = epee::string_tools::pod_to_hex(blk_id);
|
||||||
res.status = CORE_RPC_STATUS_OK;
|
res.status = CORE_RPC_STATUS_OK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace cryptonote
|
||||||
// advance which version they will stop working with
|
// advance which version they will stop working with
|
||||||
// Don't go over 32767 for any of these
|
// Don't go over 32767 for any of these
|
||||||
#define CORE_RPC_VERSION_MAJOR 3
|
#define CORE_RPC_VERSION_MAJOR 3
|
||||||
#define CORE_RPC_VERSION_MINOR 12
|
#define CORE_RPC_VERSION_MINOR 13
|
||||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||||
|
|
||||||
|
@ -1068,8 +1068,11 @@ namespace cryptonote
|
||||||
|
|
||||||
struct response_t: public rpc_response_base
|
struct response_t: public rpc_response_base
|
||||||
{
|
{
|
||||||
|
std::string block_id;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_PARENT(rpc_response_base)
|
KV_SERIALIZE_PARENT(rpc_response_base)
|
||||||
|
KV_SERIALIZE(block_id)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<response_t> response;
|
typedef epee::misc_utils::struct_init<response_t> response;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import math
|
||||||
import monotonic
|
import monotonic
|
||||||
import util_resources
|
import util_resources
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import string
|
||||||
|
|
||||||
"""Test daemon mining RPC calls
|
"""Test daemon mining RPC calls
|
||||||
|
|
||||||
|
@ -52,6 +53,11 @@ Control the behavior with these environment variables:
|
||||||
from framework.daemon import Daemon
|
from framework.daemon import Daemon
|
||||||
from framework.wallet import Wallet
|
from framework.wallet import Wallet
|
||||||
|
|
||||||
|
def assert_non_null_hash(s):
|
||||||
|
assert len(s) == 64 # correct length
|
||||||
|
assert all((c in string.hexdigits for c in s)) # is parseable as hex
|
||||||
|
assert s != ('0' * 64) # isn't null hash
|
||||||
|
|
||||||
class MiningTest():
|
class MiningTest():
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.reset()
|
self.reset()
|
||||||
|
@ -250,6 +256,8 @@ class MiningTest():
|
||||||
block_hash = hashes[i]
|
block_hash = hashes[i]
|
||||||
assert len(block_hash) == 64
|
assert len(block_hash) == 64
|
||||||
res = daemon.submitblock(blocks[i])
|
res = daemon.submitblock(blocks[i])
|
||||||
|
submitted_block_id = res.block_id
|
||||||
|
assert_non_null_hash(submitted_block_id)
|
||||||
res = daemon.get_height()
|
res = daemon.get_height()
|
||||||
assert res.height == height + i + 1
|
assert res.height == height + i + 1
|
||||||
assert res.hash == block_hash
|
assert res.hash == block_hash
|
||||||
|
@ -346,6 +354,8 @@ class MiningTest():
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
for h in range(len(block_hashes)):
|
for h in range(len(block_hashes)):
|
||||||
res = daemon.submitblock(blocks[h])
|
res = daemon.submitblock(blocks[h])
|
||||||
|
submitted_block_id = res.block_id
|
||||||
|
assert_non_null_hash(submitted_block_id)
|
||||||
t0 = time.time() - t0
|
t0 = time.time() - t0
|
||||||
res = daemon.get_info()
|
res = daemon.get_info()
|
||||||
assert height == res.height
|
assert height == res.height
|
||||||
|
|
Loading…
Reference in New Issue