Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ jobs:
key: ccache-${{ runner.os }}-${{ github.sha }}
restore-keys: ccache-${{ runner.os }}-
- name: Checkout Bitcoin Core
run: git clone --depth 1 --branch master https://github.com/bitcoin/bitcoin.git
run: |
git clone --depth 1 https://github.com/bitcoin/bitcoin.git
# DO NOT MERGE: switch to bitcoin/bitcoin#33922 PR branch
cd bitcoin
git fetch --depth 1 origin pull/33922/head:pr-33922
git checkout pr-33922
- name: Build Bitcoin Core
run: |
cd bitcoin
Expand Down
5 changes: 5 additions & 0 deletions capnp/mining.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
createNewBlock @4 (context :Proxy.Context, options: BlockCreateOptions, cooldown: Bool = true) -> (result: BlockTemplate);
checkBlock @5 (context :Proxy.Context, block: Data, options: BlockCheckOptions) -> (reason: Text, debug: Text, result: Bool);
interrupt @6 () -> ();
getMemoryLoad @7 (context :Proxy.Context) -> (result: MemoryLoad);
}

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

struct MemoryLoad $Proxy.wrap("interfaces::MemoryLoad") {
usage @0 :UInt64;
}

struct BlockWaitOptions $Proxy.wrap("node::BlockWaitOptions") {
timeout @0 : Float64 = .maxDouble $Proxy.name("timeout");
feeThreshold @1 : Int64 = .maxMoney $Proxy.name("fee_threshold");
Expand Down
9 changes: 8 additions & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn mining_constants() {
);
}

/// isTestChain, isInitialBlockDownload, getTip.
/// isTestChain, isInitialBlockDownload, getTip, getMemoryLoad.
#[tokio::test]
#[serial_test::parallel]
async fn mining_basic_queries() {
Expand All @@ -96,6 +96,13 @@ async fn mining_basic_queries() {
let tip_hash = tip.get_hash().unwrap();
assert_eq!(tip_hash.len(), 32, "block hash must be 32 bytes");
assert!(tip.get_height() >= 0, "height must be non-negative");

// getMemoryLoad
let mut req = mining.get_memory_load_request();
req.get().get_context().unwrap().set_thread(thread.clone());
let resp = req.send().promise.await.unwrap();
let memory_load = resp.get().unwrap().get_result().unwrap();
let _usage: u64 = memory_load.get_usage();
})
.await;
}
Expand Down
Loading