wctl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteLedger   = "/ledger"
	RouteAccount  = "/accounts"
	RouteContract = "/contract"
	RouteTxList   = "/tx"
	RouteTxSend   = "/tx/send"

	RouteWSBroadcaster  = "/poll/broadcaster"
	RouteWSConsensus    = "/poll/consensus"
	RouteWSStake        = "/poll/stake"
	RouteWSAccounts     = "/poll/accounts"
	RouteWSContracts    = "/poll/contract"
	RouteWSTransactions = "/poll/tx"
	RouteWSMetrics      = "/poll/metrics"

	ReqPost = "POST"
	ReqGet  = "GET"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	PublicKey string `json:"public_key"`
	Balance   uint64 `json:"balance"`
	Stake     uint64 `json:"stake"`

	IsContract bool   `json:"is_contract"`
	NumPages   uint64 `json:"num_mem_pages,omitempty"`
}

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(b []byte) error

type Client

type Client struct {
	Config

	edwards25519.PrivateKey
	edwards25519.PublicKey
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config Config) (*Client, error)

func (*Client) EstablishWS

func (c *Client) EstablishWS(path string, query url.Values) (*websocket.Conn, error)

EstablishWS will create a websocket connection.

func (*Client) GetAccount

func (c *Client) GetAccount(accountID string) (Account, error)

func (*Client) GetContractCode

func (c *Client) GetContractCode(contractID string) (string, error)

func (*Client) GetContractPages

func (c *Client) GetContractPages(contractID string, index *uint64) (string, error)

func (*Client) GetLedgerStatus

func (c *Client) GetLedgerStatus(senderID *string, creatorID *string, offset *uint64, limit *uint64) (LedgerStatusResponse, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(txID string) (Transaction, error)

func (*Client) ListTransactions

func (c *Client) ListTransactions(senderID *string, creatorID *string, offset *uint64, limit *uint64) ([]Transaction, error)

func (*Client) PollAccounts

func (c *Client) PollAccounts(stop <-chan struct{}, accountID *string) (<-chan []byte, error)

func (*Client) PollContracts

func (c *Client) PollContracts(stop <-chan struct{}, contractID *string) (<-chan []byte, error)

func (*Client) PollLoggerSink

func (c *Client) PollLoggerSink(stop <-chan struct{}, sinkRoute string) (<-chan []byte, error)

func (*Client) PollTransactions

func (c *Client) PollTransactions(stop <-chan struct{}, txID *string, senderID *string, creatorID *string, tag *byte) (<-chan []byte, error)

func (*Client) Request

func (c *Client) Request(path string, method string, body MarshalableJSON) ([]byte, error)

func (*Client) RequestJSON

func (c *Client) RequestJSON(path string, method string, body MarshalableJSON, out UnmarshalableJSON) error

Request will make a request to a given path, with a given body and return result in out.

func (*Client) SendTransaction

func (c *Client) SendTransaction(tag byte, payload []byte) (SendTransactionResponse, error)

type Config

type Config struct {
	APIHost    string
	APIPort    uint16
	PrivateKey edwards25519.PrivateKey
	UseHTTPS   bool
}

type LedgerStatusResponse

type LedgerStatusResponse struct {
	PublicKey     string   `json:"public_key"`
	HostAddress   string   `json:"address"`
	PeerAddresses []string `json:"peers"`

	RootID     string `json:"root_id"`
	RoundID    uint64 `json:"round_id"`
	Difficulty uint64 `json:"difficulty"`
}

func (*LedgerStatusResponse) UnmarshalJSON

func (l *LedgerStatusResponse) UnmarshalJSON(b []byte) error

type MarshalableJSON

type MarshalableJSON interface {
	MarshalJSON() ([]byte, error)
}

type SendTransactionRequest

type SendTransactionRequest struct {
	Sender    string `json:"sender"`
	Tag       byte   `json:"tag"`
	Payload   string `json:"payload"`
	Signature string `json:"signature"`
}

func (*SendTransactionRequest) MarshalJSON

func (s *SendTransactionRequest) MarshalJSON() ([]byte, error)

type SendTransactionResponse

type SendTransactionResponse struct {
	ID       string   `json:"tx_id"`
	Parents  []string `json:"parent_ids"`
	Critical bool     `json:"is_critical"`
}

func (*SendTransactionResponse) UnmarshalJSON

func (s *SendTransactionResponse) UnmarshalJSON(b []byte) error

type Transaction

type Transaction struct {
	ID string `json:"id"`

	Sender  string `json:"sender"`
	Creator string `json:"creator"`

	Parents []string `json:"parents"`

	Timestamp uint64 `json:"timestamp"`

	Tag     byte   `json:"tag"`
	Payload []byte `json:"payload"`

	AccountsMerkleRoot string `json:"accounts_root"`

	SenderSignature  string `json:"sender_signature"`
	CreatorSignature string `json:"creator_signature"`

	Depth uint64 `json:"depth"`
}

func (*Transaction) ParseJSON

func (t *Transaction) ParseJSON(v *fastjson.Value)

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(b []byte) error

type TransactionList

type TransactionList []Transaction

func (*TransactionList) UnmarshalJSON

func (t *TransactionList) UnmarshalJSON(b []byte) error

type UnmarshalableJSON

type UnmarshalableJSON interface {
	UnmarshalJSON([]byte) error
}

Jump to

Keyboard shortcuts

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