api_v1

package
v0.0.0-...-f1ec097 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEndpoint = "localhost:9090"
View Source
const DefaultFee = 10

DefaultFee for transfer in the Spacemesh network

View Source
const DefaultGasLimit = 100

DefaultGasLimit for tranfer in the Spacemesh network

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Nonce   uint64
	Balance uint64
}

AccountInfo describes account sate

type Client

type Client struct {
	Endpoint string
	Verbose  func(string, ...interface{})
}

Client describes node client options

func (Client) New

func (c Client) New() *ClientAgent

New creates new node ClientAgent

type ClientAgent

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

func (*ClientAgent) GetAccountBalance

func (c *ClientAgent) GetAccountBalance(address types.Address) (balance uint64, err error)

GetAccountBalance returns account balance

func (*ClientAgent) GetAccountInfo

func (c *ClientAgent) GetAccountInfo(address types.Address) (acc AccountInfo, err error)

GetAccountInfo returns account state information

func (*ClientAgent) GetAccountNonce

func (c *ClientAgent) GetAccountNonce(address types.Address) (nonce uint64, err error)

GetAccountNonce returns account nonce

func (*ClientAgent) GetMiningStats

func (c *ClientAgent) GetMiningStats() (st MiningStats, err error)

GetMiningStats calls to node for the mining stats

func (*ClientAgent) GetNodeInfo

func (c *ClientAgent) GetNodeInfo() (info NodeInfo, err error)

GetNodeInfo calls to node for the integral node information

func (*ClientAgent) GetNodeStatus

func (c *ClientAgent) GetNodeStatus() (st NodeStatus, err error)

GetNodeStatus calls to node for the node status

func (*ClientAgent) GetTransactionInfo

func (c *ClientAgent) GetTransactionInfo(txid types.TransactionID) (info TransactionInfo, err error)

GetTransactionInfo returns whole transaction information by transaction id

func (*ClientAgent) GetTxList

func (c *ClientAgent) GetTxList(address types.Address, startLayer uint64) (txs []types.TransactionID, err error)

GetTxList lists network transfers from/to specified account

func (*ClientAgent) LuckyAccountInfo

func (c *ClientAgent) LuckyAccountInfo(address types.Address) (acc AccountInfo)

LuckyAccountInfo returns account state information. It panics if error occurred

func (*ClientAgent) LuckyCoinbase

func (c *ClientAgent) LuckyCoinbase(address types.Address)

LuckyCoinbase sets coinbase address. It panics on error

func (*ClientAgent) LuckyMiningStats

func (c *ClientAgent) LuckyMiningStats() (st MiningStats)

LuckyMiningStats calls to node for the mining stats. It panics on error

func (*ClientAgent) LuckyNodeInfo

func (c *ClientAgent) LuckyNodeInfo() (info NodeInfo)

LuckyNodeInfo calls to node for the integral node information. It panics on error

func (*ClientAgent) LuckyNodeStatus

func (c *ClientAgent) LuckyNodeStatus() (st NodeStatus)

LuckyNodeStatus calls to node for the node status. It panics on error

func (*ClientAgent) LuckyTransactionInfo

func (c *ClientAgent) LuckyTransactionInfo(txid types.TransactionID) (info TransactionInfo)

LuckyTransactionInfo returns whole transaction information by transaction id. It panics on error

func (*ClientAgent) LuckyTransfer

func (c *ClientAgent) LuckyTransfer(
	amount uint64,
	from types.Address, nonce uint64, key ed25519.PrivateKey,
	to types.Address,
	fee, gasLimit uint64) types.TransactionID

Transfer creates transaction and submits it to network. It panics on error

func (*ClientAgent) LuckyTxList

func (c *ClientAgent) LuckyTxList(address types.Address, startLayer uint64) (txs []types.TransactionID)

LuckyTxList lists network transfers from/to specified account. It panics on error

func (*ClientAgent) SetCoinbase

func (c *ClientAgent) SetCoinbase(address types.Address) (err error)

SetCoinbase sets coinbase address

func (*ClientAgent) Transfer

func (c *ClientAgent) Transfer(
	amount uint64,
	from types.Address, nonce uint64, key ed25519.PrivateKey,
	to types.Address,
	fee, gasLimit uint64) (txid types.TransactionID, err error)

Transfer creates transaction and submits it to network

type MiningStats

type MiningStats struct {
	Status   MiningStatus  `json:"status"`
	Coinbase types.Address `json:"-"`
	//SmeshingRemainingBytes int           `json:"remainingBytes,string"`
	DataDir string `json:"dataDir"`
}

MiningStats describes mining

type MiningStatus

type MiningStatus int

MiningStatus is enumeration of smesher mining statuses

const (
	MiningUnknown MiningStatus = iota
	MiningIdle
	MiningInProgress
	MiningDone
)

func (MiningStatus) String

func (st MiningStatus) String() string

type NodeInfo

type NodeInfo struct {
	NodeStatus
	MiningStats
}

NodeInfo is an integral node information

type NodeStatus

type NodeStatus struct {
	Synced       bool   `json:"synced"`
	SyncedLayer  uint64 `json:"syncedLayer,string"`
	CurrentLayer uint64 `json:"currentLayer,string"`
	//VerifiedLayer uint64 `json:"verifiedLayer,string"`
	Peers    uint64 `json:"peers,string"`
	MinPeers uint64 `json:"minPeers,string"`
	MaxPeers uint64 `json:"maxPeers,string"`
}

NodeStatus describes mesh node

type TransactionInfo

type TransactionInfo struct {
	Id        types.TransactionID
	From      types.Address
	To        types.Address
	Amount    uint64 `json:"amount,string"`
	Fee       uint64 `json:"fee,string"`
	Status    TxStatus
	Timestamp time.Time
	LayerId   uint64 `json:"layerId,string"`
}

TransactionInfo contains whole transaction information

type TxStatus

type TxStatus int

TxStatus describes mesh transaction status

const (
	TxNotfound TxStatus = iota
	TxRejected
	TxPending
	TxConfirmed
)

func (TxStatus) String

func (s TxStatus) String() string

String returns string representation of transaction status

Jump to

Keyboard shortcuts

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