forked from input-output-hk/mithril
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request input-output-hk#1349 from input-output-hk/ensemble…
…/1311-mithril-client-common-crates-publish Mithril client and common crates preparation for publication
- Loading branch information
Showing
13 changed files
with
107 additions
and
31 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,6 +1,63 @@ | ||
# Mithril Client | ||
# Mithril-client ![crates.io](https://img.shields.io/crates/v/mithril-client.svg) [![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](LICENSE-APACHE) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq) | ||
|
||
## Documentation | ||
:rocket: The documentation is available at [`Mithril client library`](https://mithril.network/doc/next/manual/developer-docs/nodes/mithril-client-library) with Mithril | ||
**This is a work in progress** 🛠 | ||
|
||
:bulb: A guide on how to [`Bootstrap a Cardano Node`](https://mithril.network/doc/manual/getting-started/bootstrap-cardano-node) with Mithril | ||
* `mithril-client` defines all the tooling necessary to manipulate Mithril certified types available from a Mithril aggregator. | ||
|
||
* The different types of available data certified by Mithril are: | ||
* Snapshot: list, get and download tarball. | ||
* Mithril stake distribution: list and get. | ||
* Certificate: list, get, and chain validation. | ||
|
||
## Example | ||
|
||
Below is a basic example of how to use most of the functions exposed by the Mithril client library: | ||
|
||
```rust | ||
use mithril_client::{ClientBuilder, MessageBuilder}; | ||
use std::path::Path; | ||
|
||
#[tokio::main] | ||
async fn main() -> mithril_client::MithrilResult<()> { | ||
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?; | ||
|
||
let snapshots = client.snapshot().list().await?; | ||
|
||
let last_digest = snapshots.first().unwrap().digest.as_ref(); | ||
let snapshot = client.snapshot().get(last_digest).await?.unwrap(); | ||
|
||
let certificate = client | ||
.certificate() | ||
.verify_chain(&snapshot.certificate_hash) | ||
.await?; | ||
|
||
// Note: the directory must already exist, and the user running this code must have read/write access to it. | ||
let target_directory = Path::new("YOUR_TARGET_DIRECTORY"); | ||
client | ||
.snapshot() | ||
.download_unpack(&snapshot, target_directory) | ||
.await?; | ||
|
||
let message = MessageBuilder::new() | ||
.compute_snapshot_message(&certificate, target_directory) | ||
.await?; | ||
assert!(certificate.match_message(&message)); | ||
|
||
Ok(()) | ||
} | ||
``` | ||
|
||
## Getting Help | ||
First, check our [Developer documentation](https://mithril.network/doc/manual/developer-docs/nodes/mithril-client-library). | ||
|
||
If you need more information, feel free to join IOG's Technical Community [discord server](https://discord.gg/5kaErDKDRq). | ||
|
||
## Contributing | ||
|
||
Thanks for considering contributing and help us on creating the Mithril protocol! | ||
|
||
The best way to contribute right now is to try things out and provide feedback, | ||
but we also accept contributions to the documentation and obviously to the | ||
code itself. | ||
|
||
When contributing to this project and interacting with others, please follow our [Code of Conduct](https://github.com/input-output-hk/mithril/blob/main/CODE-OF-CONDUCT.md) and our [Contributing Guidelines](https://github.com/input-output-hk/mithril/blob/main/CONTRIBUTING.md). |
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,6 @@ | ||
# Mithril-common ![crates.io](https://img.shields.io/crates/v/mithril-common.svg) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq) | ||
|
||
|
||
**This is a work in progress** 🛠 | ||
|
||
This crate contains common utility types and testing infrastructure used in the implementation of the Mithril nodes. |
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