GithubHelp home page GithubHelp logo

rustdcr's Introduction

rustdcr's People

Contributors

metaclips avatar

Watchers

 avatar  avatar  avatar

Forkers

xsanchezz

rustdcr's Issues

Track RPC methods

This issues tracks RPC method that are to be integrated in RustDCR. It is fairly easy to implement RPC methods by fulfilling some rust macros rules.
To create a RPC command, there are chain command macro generators and chain notification macro generators that can be called upon to easily generate RPC client commands and notification.

Client Commands

To create client commands, we

  • Generate a future/async type of the RPC command using the build future macros the macros should entail the name of the RPC command with an appended tag Future (example, GetBlock command should be named GetBlockFuture in the build_future macros). build_future macros should also include a Result return type of whatever type the command is to receive from the RPC server (example, GetBlock is to receive a Result<i64, Error>) as its second parameter.
    An on_message function MUST also be created for the the specific future type which handles decoding the data returned by the server to a a required type. GetBlockCount on_message function example
  • Generate a command using the command generator macros which
    • Takes the documentation of the chain command as it's first parameter
    • Function name of the RPC command
    • Future type of the RPC command which was generated in step 1
    • RPC command to be sent to the server as a string
    • Array of pointer &[] of JSON value to be sent to the RPC server, example provided. NOTE we should take note of the order of value parameters while sending.
    • The macros last parameter is the input parameter(s) that MUST be passed by the specific command and is to be marshalled and sent to the server. get_block_verbose contains two input parameter block_hash and verbose_tx which must be passed by the client. to generate the get_block_verbose we pass
     command_generator!(
        "get_block_verbose returns a data structure from the server with information
        about a block given its hash.",
        get_block_verbose,
        future_type::GetBlockVerboseFuture,
        commands::METHOD_GET_BLOCK,
        &[
            serde_json::json!(block_hash),
            serde_json::json!(true),
            serde_json::json!(verbose_tx)
        ],
        block_hash: String,
        verbose_tx: bool
    );

where the 5th parameter is the array containing, block_hash, true (as boolean), verbose_tx and the 6th and 7th parameter, block_hash verbose_tx is the function input parameter of get_block_verbose with stated types. The generated function becomes

pub async fn get_block_verbose(&mut self, block_hash: String, verbose_tx: bool) -> Result<future_type::GetBlockVerboseFuture, RpcClientError>

Client Notification

  • We generate a future type
  • We use a notification_generator macros which entails
    • Documentation as a string
    • Notification function name
    • Future type
    • RPC Command as a string
    • Array of pointer &[] of JSON value to be sent to the RPC server
    • The next input parameter should entail NotificationHandlers that must either be defined using the either_defined() (ensures at least one of the notification handler specified is defined) or all notification handler are defined using all_defined()
    • Last input should consist all function parameters
      Some notification macros are defined here

More here #10

Add continuous integration

Add continuous integration to perform cargo clippy, cargo check, cargo build and code coverage in our codebase

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.