hindol / vm-agent

An agent for the cloud.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VM Agent Clojars Project cljdoc badge

VM Agent is an agent that runs in an Azure VM and selectively exposes some APIs of the blockchain client running alongside it.

This project features,

Getting Started

  • Install the Clojure CLI tools, preferably in a *nix environment (Windows Subsystem for Linux works fine.) Outside WSL, Windows support is experimental at this point.

  • Build the project and create a Docker image in one step,

      > clojure -A:pack mach.pack.alpha.jib \
                --image-name $DOCKER_REGISTRY/vm-agent:0.1.0 \
                --image-type docker \
                -m vm-agent.server
    

    $DOCKER_REGISTRY is any registry where you want to host the image. For Azure Container Registry, use <registry>.azurecr.io.

  • Start the server,

      > docker run $DOCKER_REGISTRY/vm-agent:0.1.0
    
  • Try one of the examples.

Examples

curl -i \
     -H 'Accept: application/json' \
     http://localhost:8890/besu/block-number

Note: There are known networking limitations when running Docker on Windows. Try these workarounds,

  1. Run Docker in a Vagrant VM.
  2. Run cURL in a container that is attached to the same network.

Currently, these APIs are exposed,

#{["/besu/genesis"              :get    (conj common-interceptors besu/read-genesis)]
  ["/besu/genesis"              :put    (conj common-interceptors besu/create-genesis)]
  ["/besu/block-number"         :get    (conj common-interceptors besu/read-block-number)]
  ["/besu/syncing"              :get    (conj common-interceptors besu/syncing)]
  ["/besu/public-key"           :get    (conj common-interceptors besu/read-public-key)]
  ["/besu/address"              :get    (conj common-interceptors besu/read-address)]
  ["/besu/enode-url"            :get    (conj common-interceptors besu/read-enode-url)]
  ["/besu/accounts/"            :get    (conj common-interceptors besu/read-accounts)]
  ["/besu/peers/"               :get    (conj common-interceptors besu/read-peers)]
  ["/besu/peers/"               :post   (conj common-interceptors besu/add-peer)]
  ["/besu/peers/"               :delete (conj common-interceptors besu/remove-peer)]
  ["/besu/validators/"          :get    (conj common-interceptors besu/read-validators)]
  ["/besu/validators/"          :post   (conj common-interceptors besu/add-validator)]
  ["/besu/validators/"          :delete (conj common-interceptors besu/remove-validator)]
  ["/besu/send-raw-transaction" :post   (conj common-interceptors besu/send-raw-transaction)]

Take a look at the handlers. The code is well documented.

Clojure Crash Course

Check out Clojure in 15 Minutes.

About

An agent for the cloud.


Languages

Language:Clojure 100.0%