-
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 (#1)
- 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 - added many tests for verification - removed overly strict check of prev_sig on unchained beacon
- Loading branch information
1 parent
9855eea
commit 32831d3
Showing
9 changed files
with
712 additions
and
248 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 crate::{Transport, TransportError}; | ||
use reqwest::blocking::Client; | ||
use reqwest::StatusCode; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum HttpError { | ||
#[error("not found")] | ||
NotFound, | ||
#[error("unexpected")] | ||
Unexpected, | ||
} | ||
|
||
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.