Skip to content

eugene-eko2000/rust_sample

Repository files navigation

Blockclock Backend & Solver

This is a service that provides the blockclock backend and solver functionality.

Building

  1. Make sure that docker and gcloud are installed on your local machine.
  2. Run ./build_image.sh.
    1. Choose the environment from the prompt Use prod if you're updating the production version.
    2. It might ask for logging in to Google account. Use your stxn accounbt for login.
    3. The docker image will be built.
  3. If you encounter error due to a lack of gcloud permissions, ping the gcloud admin, we'll grant necessary permissions.

Deploying

  1. Modify the ./deploy.sh script if you need to change some params, e.g. contract addresses.
  2. Login to the google cloud console with your stxn account.
  3. ssh into the blockclock-solver VM.
  4. Copy the deploy.sh into the default home directory. Replace existing script if it exists.
  5. Run the ./deploy.sh on the VM

API Description

  1. /onboard

    The POST request, to be called by the app to add a new time keeper.

    Body:

    {
        "time_keeper": "<time_keeper_address>",
        "avatar": "<time_keeper_name>",
    }
  2. /add_time_sig

    Thre POST request, to be called every time when the time leeper issues a new time signature.

    Body:

    {
      "epoch": "<Unix epoch in nanoseconds>",
      "time_keeper": "<The time keeper address>",
      "signature": "<ECDSA signature, 65 bytes>"
    }
  3. /claim_avatar

    The POST request, should be called when the time keeper claims a new name.

    Body:

    {
      "time_keeper": "<Address>",
      "avatar": "<New name>"
    }
  4. /list_time_sigs

    The GET request, debug output of all existing time signatures in tne memory pool.

    Params: None

  5. /get_time_margin

    The GET request, returns the current time margin used for mean time computing. Expected response JSON:

    {
        "time_margin": "<margin in nanoseconds>"
    }
  6. /get_time_keepers_count

    The GET request, returns a number of time keepers contributing to the blockclock. Expected response JSON example:

    {
        "count": 42
    }
  7. /update_referral_code

    The POST request, updates the account's referral code. Can be used for setting a custom referral code.

    Body:

    {
        "time_keeper": "<Address>",
        "referral_code": "<A new referral code>"
    }
  8. /update_referred_from

    The POST request, updates the referral code that made referral for this account.

    Body:

    {
        "time_keeper": "<Address>",
        "referred_from": "<A referral code of this account's referrer>"
    }
  9. /write_referral

    The POST request, puts a device's ID and a referral code into referrers table. Expected on the making referral process, to be called by the referral web app.

    Body:

    {
        "refkey": "<Device ID, computed by the referral web app>",
        "refvalue": "<Referral code>"
    }
  10. /read_referral

    The GET request, requests a referral ID of the referrer who referred this user. Expected to be called by the application on the onboarding. The retrtieved referral ID is to be stored afterwards.

    Request:

    /read_referral?ref_key=<device ID>

    Expected response:

    {
        "refkey": "<Device ID>",
        "refvalue": "<Referral code>"
    }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published