Skip to content

Commit 45ea30a

Browse files
committed
mining: add getMemoryLoad capnp definition and test coverage
1 parent 202285b commit 45ea30a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

capnp/mining.capnp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
2323
createNewBlock @4 (context :Proxy.Context, options: BlockCreateOptions, cooldown: Bool = true) -> (result: BlockTemplate);
2424
checkBlock @5 (context :Proxy.Context, block: Data, options: BlockCheckOptions) -> (reason: Text, debug: Text, result: Bool);
2525
interrupt @6 () -> ();
26+
getMemoryLoad @7 (context :Proxy.Context) -> (result: MemoryLoad);
2627
}
2728

2829
interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {
@@ -44,6 +45,10 @@ struct BlockCreateOptions $Proxy.wrap("node::BlockCreateOptions") {
4445
coinbaseOutputMaxAdditionalSigops @2 :UInt64 = .defaultCoinbaseOutputMaxAdditionalSigops $Proxy.name("coinbase_output_max_additional_sigops");
4546
}
4647

48+
struct MemoryLoad $Proxy.wrap("interfaces::MemoryLoad") {
49+
usage @0 :UInt64;
50+
}
51+
4752
struct BlockWaitOptions $Proxy.wrap("node::BlockWaitOptions") {
4853
timeout @0 : Float64 = .maxDouble $Proxy.name("timeout");
4954
feeThreshold @1 : Int64 = .maxMoney $Proxy.name("fee_threshold");

tests/test.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn mining_constants() {
6969
);
7070
}
7171

72-
/// isTestChain, isInitialBlockDownload, getTip.
72+
/// isTestChain, isInitialBlockDownload, getTip, getMemoryLoad.
7373
#[tokio::test]
7474
#[serial_test::parallel]
7575
async fn mining_basic_queries() {
@@ -96,6 +96,13 @@ async fn mining_basic_queries() {
9696
let tip_hash = tip.get_hash().unwrap();
9797
assert_eq!(tip_hash.len(), 32, "block hash must be 32 bytes");
9898
assert!(tip.get_height() >= 0, "height must be non-negative");
99+
100+
// getMemoryLoad
101+
let mut req = mining.get_memory_load_request();
102+
req.get().get_context().unwrap().set_thread(thread.clone());
103+
let resp = req.send().promise.await.unwrap();
104+
let memory_load = resp.get().unwrap().get_result().unwrap();
105+
let _usage: u64 = memory_load.get_usage();
99106
})
100107
.await;
101108
}

0 commit comments

Comments
 (0)