-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example and rename function for consistency
- Loading branch information
Showing
4 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use bitcoincore_zmq::subscribe_single_async; | ||
use futures_util::StreamExt; | ||
|
||
fn main() { | ||
let mut stream = subscribe_single_async("tcp://127.0.0.1:28332").unwrap(); | ||
|
||
// This is a small example to demonstrate subscribe_single_async, it is okay here to use | ||
// block_on, but not in production environments as this defeats the purpose of async. | ||
futures::executor::block_on(async { | ||
while let Some(msg) = stream.next().await { | ||
match msg { | ||
Ok(msg) => println!("Received message: {msg}"), | ||
Err(err) => println!("Error receiving message: {err}"), | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters