node

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package node provides a client for the node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Txs               Txs    `json:"tx"`
	Hash              string `json:"hash"`
	NextBlockHash     string `json:"nextblockhash"`
	PreviousBlockHash string `json:"previousblockhash"`
}

Block is a block

type BlockWrapper

type BlockWrapper struct {
	Txs  json.RawMessage `json:"tx"`
	Hash string          `json:"hash"`
}

BlockWrapper is a wrapper for a block

type ChainInfo

type ChainInfo struct {
	Chain                string     `json:"chain"`
	Blocks               int        `json:"blocks"`
	Headers              int        `json:"headers"`
	BestBlockHash        string     `json:"bestblockhash"`
	Difficulty           float64    `json:"difficulty"`
	MedianTime           int        `json:"mediantime"`
	VerificationProgress float64    `json:"verificationprogress"`
	ChainWork            string     `json:"chainwork"`
	Pruned               bool       `json:"pruned"`
	SoftForks            []SoftFork `json:"softforks"`
}

ChainInfo is the chain info

type Client

type Client struct {
	Client   http.Client
	Host     string
	User     string
	Password string
}

Client is the node client

func NewClient

func NewClient() *Client

NewClient returns a new node client

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, hash string) (*Block, error)

GetBlock returns a block

func (*Client) GetBlockHeaders

func (c *Client) GetBlockHeaders(ctx context.Context, from string, count int) ([]Block, error)

GetBlockHeaders returns a list of block headers

func (*Client) GetChainInfo

func (c *Client) GetChainInfo(ctx context.Context) (*ChainInfo, error)

GetChainInfo returns the chain info

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, url string) (*http.Request, error)

NewRequest returns a new request

type SoftFork

type SoftFork struct {
	ID      string `json:"id"`
	Version int    `json:"version"`
	Reject  reject `json:"reject"`
}

SoftFork is a soft fork

type Tx

type Tx struct {
	Hex  string `json:"hex"`
	Hash string `json:"hash"`
}

Tx is a transaction

type Txs

type Txs []Tx

Txs is a list of transactions

Jump to

Keyboard shortcuts

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