-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support RFC compliant and non-compliant g1/g2 swapped beacons
- replaced BLS12-381 lib with ZKcrypto's lib as it's lower level - changed the interface almost completely, so users don't need to know whether they're using a chained or unchained network
- Loading branch information
1 parent
9855eea
commit 09b22d4
Showing
10 changed files
with
388 additions
and
243 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
/Cargo.lock | ||
drand-client-rs.iml |
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 was deleted.
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
use reqwest::blocking::Client; | ||
use reqwest::StatusCode; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum HttpError { | ||
#[error("not found")] | ||
NotFound, | ||
#[error("unexpected")] | ||
Unexpected, | ||
} | ||
use crate::{Transport, TransportError}; | ||
|
||
pub struct HttpTransport { | ||
pub client: Client, | ||
} | ||
|
||
impl HttpTransport { | ||
pub fn fetch(&self, url: &str) -> Result<String, HttpError> { | ||
impl Transport for HttpTransport { | ||
fn fetch(&self, url: &str) -> Result<String, TransportError> { | ||
let res = self | ||
.client | ||
.get(url) | ||
.send() | ||
.map_err(|_| HttpError::Unexpected)?; | ||
.map_err(|_| TransportError::Unexpected)?; | ||
|
||
match res.status() { | ||
StatusCode::OK => res.text().map_err(|_| HttpError::Unexpected), | ||
StatusCode::OK => res.text().map_err(|_| TransportError::Unexpected), | ||
|
||
StatusCode::NOT_FOUND => Err(HttpError::NotFound), | ||
StatusCode::NOT_FOUND => Err(TransportError::NotFound), | ||
|
||
_ => Err(HttpError::Unexpected), | ||
_ => Err(TransportError::Unexpected), | ||
} | ||
} | ||
} | ||
|
||
pub fn new_http_transport() -> HttpTransport { | ||
HttpTransport { | ||
client: Client::new() | ||
} | ||
} |
Oops, something went wrong.