types

package
v0.0.0-...-dec31c8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalError

func MarshalError(err error) []byte

MarshalError takes an error and returns a marshaled APIErrorResponse

func MarshalErrorStrings

func MarshalErrorStrings(errlist ...string) []byte

MarshalErrorStrings takes a list of strings, and returns a marshaled APIErrorResponse

func RequireFields

func RequireFields(m interface{}, params ...string) error

RequireFields iterates over object `m` and returns error if any fields listed in `params` are nil/zero value

Types

type APIErrorResponse

type APIErrorResponse struct {
	Errors []string `json:"errors,omitempty"`
}

APIErrorResponse is a struct for returning errors in the API

type Actor

type Actor struct {
	Kind      string                               `json:"kind"`
	ActorType string                               `json:"role,omitempty"`
	Address   string                               `json:"address,omitempty"`
	Code      cid.Cid                              `json:"code,omitempty"`
	Nonce     *big.Int                             `json:"nonce,omitempty"`
	Balance   *big.Int                             `json:"balance,omitempty"`
	Exports   map[string]ReadableFunctionSignature `json:"exports"` // exports by function name
	Head      cid.Cid                              `json:"head,omitempty"`
}

Actor is a struct for a Filecoin actor

func (Actor) MarshalJSON

func (o Actor) MarshalJSON() ([]byte, error)

MarshalJSON marshals Actor into JSON

type BitswapStats

type BitswapStats struct{}

BitswapStats contains Bitswap related stats for a Filecoin node

type Block

type Block struct {
	Kind   string `json:"kind"`
	ID     cid.Cid
	Header BlockHeader `json:"header"`
}

Block is the internal struct for a Filecoin block

func (Block) MarshalJSON

func (o Block) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Block struct

type BlockHeader

type BlockHeader struct {
	Kind                  string    `json:"kind"`
	Miner                 string    `json:"minerAddress,omitempty"`
	Tickets               [][]byte  `json:"tickets,omitempty"`
	ElectionProof         []byte    `json:"electionProof,omitempty"`
	Parents               []cid.Cid `json:"parents,omitempty"`
	ParentWeight          *big.Int  `json:"parentWeight,omitempty"`
	Height                uint64    `json:"height,omitempty"`
	ParentStateRoot       cid.Cid   `json:"parentStateRoot,omitempty"`
	ParentMessageReceipts cid.Cid   `json:"parentMessageReceipts,omitempty"`
	Messages              cid.Cid   `json:"messages,omitempty"`
	BLSAggregate          []byte    `json:"blsAggregate,omitempty"`
	Timestamp             uint64    `json:"timestamp,omitempty"`
	BlockSig              []byte    `json:"blockSig,omitempty"`
}

BlockHeader is the internal struct for a Filecoin blockheader

func (BlockHeader) MarshalJSON

func (o BlockHeader) MarshalJSON() ([]byte, error)

MarshalJSON marshals a BlockHeader struct

type Message

type Message struct {
	Kind       string   `json:"kind"`
	ID         string   `json:"id,omitempty"`
	Nonce      uint64   `json:"nonce,omitempty"`
	From       string   `json:"from,omitempty"`
	To         string   `json:"to,omitempty"`
	Value      *big.Int `json:"value,omitempty"`    // in AttoFIL
	GasPrice   *big.Int `json:"gasPrice,omitempty"` // in AttoFIL
	GasLimit   uint64   `json:"gasLimit,omitempty"` // in GasUnits
	Method     string   `json:"method,omitempty"`
	Parameters []string `json:"parameters,omitempty"`
}

Message is a struct representing a Filecoin message. Parameter are parameters for the Method from the HTTP request and are passed to the Callback unparsed.

func (*Message) Bind

func (m *Message) Bind(r *http.Request) error

Bind does any additional setup needed for binding an http request body to a Message object

func (Message) MarshalJSON

func (m Message) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Message struct

type Node

type Node struct {
	Kind         string       `json:"kind"`
	ID           string       `json:"id,omitempty"`
	Addresses    []string     `json:"addresses,omitempty"`
	Version      string       `json:"version,omitempty"`
	Commit       string       `json:"commit,omitempty"`
	Protocol     Protocol     `json:"protocol,omitempty"`
	BitswapStats BitswapStats `json:"bitswapStats,omitempty"`
}

Node contains the Node level Filecoin information

func (Node) MarshalJSON

func (n Node) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Node struct

type Protocol

type Protocol struct {
	AutosealInterval uint64   `json:"autosealInterval,omitempty"`
	SectorSizes      []uint64 `json:"sectorSizes,omitempty"`
}

Protocol contains protocol-related settings for a Filecoin node

type ReadableFunctionSignature

type ReadableFunctionSignature struct {
	Params []string `json:"params"`
	Return []string `json:"return"`
}

ReadableFunctionSignature represents a function signature definition for exported Filecoin functions, i.e. those that can be invoked by a message send

type SignedMessage

type SignedMessage struct {
	Kind       string   `json:"kind"`
	ID         string   `json:"id,omitempty"`
	Nonce      uint64   `json:"nonce,omitempty"`
	From       string   `json:"from,omitempty"`
	To         string   `json:"to,omitempty"`
	Value      *big.Int `json:"value,omitempty"`    // in AttoFIL
	GasPrice   *big.Int `json:"gasPrice,omitempty"` // in AttoFIL
	GasLimit   uint64   `json:"gasLimit,omitempty"` // in GasUnits
	Method     string   `json:"method,omitempty"`
	Parameters []string `json:"parameters"`
	Signature  string   `json:"signature,omitempty"`
}

SignedMessage is a struct representing a signed message to be posted in the message pool. Unlike filecoin implementations, this does not embed Message and add Sigature, because of the need to marshal as JSON. Embedding Message causes json.Marshal to strip the Signature field. This is unlikely to be fixed: https://github.com/golang/go/issues/31167

func (*SignedMessage) Bind

func (sm *SignedMessage) Bind(r *http.Request) error

Bind does any additional setup needed for binding an http request body to a SignedMessage object

func (*SignedMessage) MarshalJSON

func (sm *SignedMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshals a SignedMessage struct

Jump to

Keyboard shortcuts

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