client

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2017 License: Apache-2.0 Imports: 8 Imported by: 1

README

faircoin rpcclient

A thin wrapper around the FairCoin rpc calls:

Usage

package main

import (
    faircoin "github.com/mmoya/faircoin_rpcclient"
)

func main() {
    c := faircoin.NewClient("http://127.0.0.1:40405", faircoin.CookieCredential())

    activeCvns, err := c.GetActiveCVNs()
    if err != nil {
        log.Fatal("GetActiveCVNs: ", err)
    }

    fmt.Println(activeCvns)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveCvns

type ActiveCvns struct {
	Count         int
	CurrentHeight int
	Cvns          []Cvn
}

ActiveCvns is the response of getactivecvn rpc call

type Block

type Block struct {
	Hash              string
	Confirmations     int
	Size              int
	Height            int
	Version           int
	Payload           string
	PayloadHash       string
	MerkleRoot        string
	Time              int64
	MedianTime        int64
	Creator           string
	CreatorSignature  string
	Signatures        int
	AdminSignatures   int
	ChainSignature    string
	AdminMultiSig     string
	MissingCreatorIds []string
	AdminSignerIds    []string
	Tx                []string
	PreviousBlockHash string
	NextBlockHash     string
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client of FairCoin RPC service

func NewClient

func NewClient(url string, cred *Credential) *Client

NewClient returns a FairCoin RPC client

func (*Client) GetActiveCVNs

func (c *Client) GetActiveCVNs() (*ActiveCvns, error)

GetActiveCVNs is the wrapper around getactivecvn rpc

func (*Client) GetBlock

func (c *Client) GetBlock(hash string, verbose bool, mode int) (*Block, error)

GetBlock is the wrapper around getblock rpc

func (*Client) GetBlockCount

func (c *Client) GetBlockCount() (int, error)

GetBlockCount is the wrapper around getblockcount rpc

func (*Client) GetBlockHash

func (c *Client) GetBlockHash(index int) (string, error)

GetBlockHash is the wrapper around getblockhash rpc

type Credential

type Credential struct {
	// contains filtered or unexported fields
}

Credential holds a credential to connect to FairCoin2 RPC service

func CookieCredential

func CookieCredential() *Credential

CookieCredential reads credential from default cookie

func NewCredential

func NewCredential(user, password string) *Credential

type Cvn

type Cvn struct {
	NodeID             string
	PubKey             string
	HeightAdded        int
	PredictedNextBlock int
	LastBlocksSigned   int
}

Cvn is the state of a CVN as returned by getactivecvn rpc call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL