Validator API (#504)

* Implemented more REST API endpoints.
 - Added many of the endpoints, which return 501 - Not Implemented
 - Created helper function to return a not implemented error
 - Created a parse_pubkey function to get a PublicKey from a hex string
 - Created a HTTP handler for the validator endpoints
 - Started implementing validator/duties endpoint.

* Fleshed out get validator duties.
 - Re-implemented the get validator duties function for the REST API
 - Added an 'as_hex_string' function to FakePublicKey, beacuse it was missing.

* Fixed small caching/state bug.

* Extended to array of API inputs.
 - Created  function for getting arrays from GET parameters.
 - Extended get validator duties function to support array of validator duties.

* Tidy API to be more consistent with recent decisions

* Addressing Paul's comments.
 - Cleaning up function to get list of proposers.
 - Removing unnecessary serde annotations
 - Clarifying error messages
 - Only accept pubkeys if they are '0x' prefixed.

* Fixed formatting with rustfmt.
This commit is contained in:
Luke Anderson
2019-08-28 00:40:35 +10:00
parent ce43a59fff
commit 328f11d564
7 changed files with 253 additions and 6 deletions

View File

@@ -61,6 +61,13 @@ impl FakePublicKey {
hex_encode(end_bytes)
}
/// Returns the point as a hex string of the SSZ encoding.
///
/// Note: the string is prefixed with `0x`.
pub fn as_hex_string(&self) -> String {
hex_encode(self.as_ssz_bytes())
}
// Returns itself
pub fn as_raw(&self) -> &Self {
self

View File

@@ -28,7 +28,7 @@ impl PublicKey {
/// Returns the underlying point as compressed bytes.
///
/// Identical to `self.as_uncompressed_bytes()`.
fn as_bytes(&self) -> Vec<u8> {
pub fn as_bytes(&self) -> Vec<u8> {
self.as_raw().as_bytes()
}