Jayant Krishnamurthy 2 年之前
父節點
當前提交
e1741477f7
共有 3 個文件被更改,包括 11 次插入2 次删除
  1. 1 0
      pyth-rng/src/api/revelation.rs
  2. 10 0
      pyth-rng/src/ethereum.rs
  3. 0 2
      pyth-rng/src/main.rs

+ 1 - 0
pyth-rng/src/api/revelation.rs

@@ -45,6 +45,7 @@ pub async fn revelation(
         .await
         .map_err(|e| RestError::TemporarilyUnavailable)?;
 
+    // sequence_number == 0 means the request does not exist.
     if r.sequence_number != 0 {
         let value = &state
             .state

+ 10 - 0
pyth-rng/src/ethereum.rs

@@ -36,6 +36,8 @@ abigen!(PythRandom, "src/abi.json");
 pub type PythContract = PythRandom<SignerMiddleware<Provider<Http>, LocalWallet>>;
 
 impl PythContract {
+    // TODO: this method requires a private key to instantiate the contract. This key
+    // shouldn't be required for read-only uses (e.g., when the server is running).
     pub async fn from_opts(opts: &EthereumOptions) -> Result<PythContract, Box<dyn Error>> {
         let provider = Provider::<Http>::try_from(&opts.geth_rpc_addr)?;
         let chain_id = provider.get_chainid().await?;
@@ -52,6 +54,10 @@ impl PythContract {
         ))
     }
 
+    /// Submit a request for a random number to the contract.
+    ///
+    /// This method is a version of the autogenned `request` method that parses the emitted logs
+    /// to return the sequence number of the created Request.
     pub async fn request_wrapper(
         &self,
         provider: &Address,
@@ -79,6 +85,10 @@ impl PythContract {
         }
     }
 
+    /// Reveal the generated random number to the contract.
+    ///
+    /// This method is a version of the autogenned `reveal` method that parses the emitted logs
+    /// to return the generated random number.
     pub async fn reveal_wrapper(
         &self,
         provider: &Address,

+ 0 - 2
pyth-rng/src/main.rs

@@ -2,11 +2,9 @@
 #![feature(slice_flatten)]
 
 use {
-    crate::state::PebbleHashChain,
     anyhow::Result,
     clap::Parser,
     std::error::Error,
-    utoipa::OpenApi,
 };
 
 pub mod api;