/api-rpc-pegnet

Haskell JSON-RPC client for PegNet

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Haskell JSON-RPC client for PegNet

Build Status License

A JSON-RPC Haskell client for the PegNet API. Each response has special ADT(algebraic data type) that automatically converted from JSON response. Using Remote Monad pattern multiple request can be batched and executed simulatenously, following more robust approach and reducing usage of expensive RPC calls.

Choosing a batching strategy. There are two strategies:

  • Weak - a single command or a single procedure, or
  • Strong - a sequence of commands, optionally terminated by a procedure

Installation

You can install package from Hackage and build with Cabal, but we recommend to use Stack tool. Add to you dependencies in stack.yaml and cabal file dependency - api-rpc-factom.

To run and test fromrepository

  1. Build with stack
$ stack build
  1. Load REPL with stack for evaluation
$ stack repl
  1. execute required methods

Usage

for basic daemon functionality

  1. import with
import PegNet.RPC.Api

or load in REPL.

  1. build communication session with
weakSession (traceSendAPI "" $ clientSendAPI endpoint)
  1. run required methods inside RPC monad

Retreiving a sync status

-- build communication session
let s = weakSession (traceSendAPI "" $ clientSendAPI endpoint)

-- run Remote Monad
h <- send s $ do
         -- run specific events by executing exposed
         h <- reqGetSyncStatus
         return h
-- show converted ADT
print h
-- or use for special business logic