Skip to content

Commit b444668

Browse files
committed
mining: add getMemoryLoad capnp definition and test coverage
1 parent 33d0af5 commit b444668

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
@@ -182,7 +182,7 @@ fn mining_constants() {
182182
);
183183
}
184184

185-
/// isTestChain, isInitialBlockDownload, getTip.
185+
/// isTestChain, isInitialBlockDownload, getTip, getMemoryLoad.
186186
#[tokio::test]
187187
#[serial_test::parallel]
188188
async fn mining_basic_queries() {
@@ -216,6 +216,13 @@ async fn mining_basic_queries() {
216216
let tip_hash = tip.get_hash().unwrap();
217217
assert_eq!(tip_hash.len(), 32, "block hash must be 32 bytes");
218218
assert!(tip.get_height() >= 0, "height must be non-negative");
219+
220+
// getMemoryLoad
221+
let mut req = mining.get_memory_load_request();
222+
req.get().get_context().unwrap().set_thread(thread.clone());
223+
let resp = req.send().promise.await.unwrap();
224+
let memory_load = resp.get().unwrap().get_result().unwrap();
225+
let _usage: u64 = memory_load.get_usage();
219226
})
220227
.await;
221228
}

0 commit comments

Comments
 (0)