Просмотр исходного кода

darkfid: Attempt to expand blockchain RPCAPI

parazyd 3 лет назад
Родитель
Сommit
ed5d427ede
2 измененных файлов с 31 добавлено и 3 удалено
  1. 30 2
      bin/darkfid/src/rpc_blockchain.rs
  2. 1 1
      bin/faucetd/src/main.rs

+ 30 - 2
bin/darkfid/src/rpc_blockchain.rs

@@ -37,6 +37,13 @@ impl Darkfid {
     // Queries the blockchain database for a block in the given slot.
     // Queries the blockchain database for a block in the given slot.
     // Returns a readable block upon success.
     // Returns a readable block upon success.
     //
     //
+    // **Params:**
+    // * `array[0]`: `u64` slot ID
+    //
+    // **Returns:**
+    // * [`BlockInfo`](https://darkrenaissance.github.io/darkfi/development/darkfi/consensus/block/struct.BlockInfo.html)
+    //   struct as a JSON object
+    //
     // --> {"jsonrpc": "2.0", "method": "blockchain.get_slot", "params": [0], "id": 1}
     // --> {"jsonrpc": "2.0", "method": "blockchain.get_slot", "params": [0], "id": 1}
     // <-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
     // <-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
     pub async fn blockchain_get_slot(&self, id: Value, params: &[Value]) -> JsonResult {
     pub async fn blockchain_get_slot(&self, id: Value, params: &[Value]) -> JsonResult {
@@ -66,8 +73,15 @@ impl Darkfid {
     }
     }
 
 
     // RPCAPI:
     // RPCAPI:
-    // Queries the blockchain database for a block in the given slot.
-    // Returns a readable block upon success.
+    // Queries the blockchain database for a given transaction.
+    // Returns a serialized `Transaction` object.
+    //
+    // **Params:**
+    // * `array[0]`: Hex-encoded transaction hash string
+    //
+    // **Returns:**
+    // * Serialized [`Transaction`](https://darkrenaissance.github.io/darkfi/development/darkfi/tx/struct.Transaction.html)
+    //   object
     //
     //
     // --> {"jsonrpc": "2.0", "method": "blockchain.get_tx", "params": ["TxHash"], "id": 1}
     // --> {"jsonrpc": "2.0", "method": "blockchain.get_tx", "params": ["TxHash"], "id": 1}
     // <-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
     // <-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
@@ -111,6 +125,12 @@ impl Darkfid {
     // RPCAPI:
     // RPCAPI:
     // Queries the blockchain database to find the last known slot
     // Queries the blockchain database to find the last known slot
     //
     //
+    // **Params:**
+    // * `None`
+    //
+    // **Returns:**
+    // * `u64` ID of the last known slot
+    //
     // --> {"jsonrpc": "2.0", "method": "blockchain.last_known_slot", "params": [], "id": 1}
     // --> {"jsonrpc": "2.0", "method": "blockchain.last_known_slot", "params": [], "id": 1}
     // <-- {"jsonrpc": "2.0", "result": 1234, "id": 1}
     // <-- {"jsonrpc": "2.0", "result": 1234, "id": 1}
     pub async fn blockchain_last_known_slot(&self, id: Value, params: &[Value]) -> JsonResult {
     pub async fn blockchain_last_known_slot(&self, id: Value, params: &[Value]) -> JsonResult {
@@ -166,6 +186,14 @@ impl Darkfid {
     // Performs a lookup of zkas bincodes for a given contract ID and returns all of
     // Performs a lookup of zkas bincodes for a given contract ID and returns all of
     // them, including their namespace.
     // them, including their namespace.
     //
     //
+    // **Params:**
+    // * `array[0]`: base58-encoded contract ID string
+    //
+    // **Returns:**
+    // * `array[n]`: Pairs of: `zkas_namespace` string, serialized
+    //   [`ZkBinary`](https://darkrenaissance.github.io/darkfi/development/darkfi/zkas/decoder/struct.ZkBinary.html)
+    //   object
+    //
     // --> {"jsonrpc": "2.0", "method": "blockchain.lookup_zkas", "params": ["6Ef42L1KLZXBoxBuCDto7coi9DA2D2SRtegNqNU4sd74"], "id": 1}
     // --> {"jsonrpc": "2.0", "method": "blockchain.lookup_zkas", "params": ["6Ef42L1KLZXBoxBuCDto7coi9DA2D2SRtegNqNU4sd74"], "id": 1}
     // <-- {"jsonrpc": "2.0", "result": [["Foo", [...]], ["Bar", [...]]], "id": 1}
     // <-- {"jsonrpc": "2.0", "result": [["Foo", [...]], ["Bar", [...]]], "id": 1}
     pub async fn blockchain_lookup_zkas(&self, id: Value, params: &[Value]) -> JsonResult {
     pub async fn blockchain_lookup_zkas(&self, id: Value, params: &[Value]) -> JsonResult {

+ 1 - 1
bin/faucetd/src/main.rs

@@ -380,7 +380,7 @@ impl Faucetd {
     // * `array[1]`: n steps (`u64`) needed for VDF evaluation
     // * `array[1]`: n steps (`u64`) needed for VDF evaluation
     //
     //
     // --> {"jsonrpc": "2.0", "method": "challenge", "params": ["1DarkFi..."], "id": 1}
     // --> {"jsonrpc": "2.0", "method": "challenge", "params": ["1DarkFi..."], "id": 1}
-    // <-- {"jsonrpc": "2.0", "result": "["0x123...", 10000]", "id": 1}
+    // <-- {"jsonrpc": "2.0", "result": ["0x123...", 10000], "id": 1}
     async fn challenge(&self, id: Value, params: &[Value]) -> JsonResult {
     async fn challenge(&self, id: Value, params: &[Value]) -> JsonResult {
         const N_STEPS: u64 = 2_000_000;
         const N_STEPS: u64 = 2_000_000;