srv

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PegnetdDefault = "http://localhost:8070"
)

Defaults for the factomd and factom-walletd endpoints.

Variables

View Source
var (
	ErrorTokenNotFound = jrpc.NewError(-32800, "Token Not Found",
		"token may be invalid, or not yet issued or tracked")
	ErrorTransactionNotFound = jrpc.NewError(-32803, "Transaction Not Found",
		"no matching tx-id was found")
	ErrorInvalidTransaction = jrpc.NewError(-32804, "Invalid Transaction", nil)
	ErrorTokenSyncing       = jrpc.NewError(-32805, "Token Syncing",
		"token is in the process of syncing")
	ErrorNoEC = jrpc.NewError(-32806, "No Entry Credits",
		"not configured with entry credits")
	ErrorPendingDisabled = jrpc.NewError(-32807, "Pending Transactions Disabled",
		"fatd is not tracking pending transactions")
	ErrorAddressNotFound = jrpc.NewError(-32808, "Address Not Found",
		"address may be invalid, or not yet tracked")
	ErrorNotFound = jrpc.NewError(-32809, "Not Found",
		"could not find what you were looking for")
)

Functions

This section is empty.

Types

type APIServer

type APIServer struct {
	Node   *node.Pegnetd
	Config *viper.Viper
}

APIServer is to avoid the need of keeping state objects in a global space. It can hold the full pegnet node, since that will give us complete access to not only the node related database, but also the FactomClient for factomd interaction.

func NewAPIServer

func NewAPIServer(conf *viper.Viper, n *node.Pegnetd) *APIServer

func (*APIServer) Start

func (s *APIServer) Start(stop <-chan struct{}) (done <-chan struct{})

Start the server in its own goroutine. If stop is closed, the server is closed and any goroutines will exit. The done channel is closed when the server exits for any reason. If the done channel is closed before the stop channel is closed, an error occurred. Errors are logged.

type Client

type Client struct {
	PegnetdServer string
	jrpc.Client
}

Client makes RPC requests to pegnetd's APIs. Client embeds a jsonrpc2.Client, and thus also the http.Client. Use jsonrpc2.Client's BasicAuth settings to set up BasicAuth and http.Client's transport settings to configure TLS.

func NewClient

func NewClient() *Client

NewClient returns a pointer to a Client initialized with the default localhost endpoints for factomd and factom-walletd, and 15 second timeouts for each of the http.Clients.

func (*Client) Request

func (c *Client) Request(method string, params, result interface{}) error

Request makes a request to pegnetd's v1 API.

type Params

type Params interface {
	IsValid() error
	ValidChainID() *factom.Bytes32
	HasIncludePending() bool
}

type ParamsGetBank added in v0.5.0

type ParamsGetBank struct {
	Height int32 `json:"height,omitempty"`
}

func (ParamsGetBank) HasIncludePending added in v0.5.0

func (p ParamsGetBank) HasIncludePending() bool

func (ParamsGetBank) IsValid added in v0.5.0

func (p ParamsGetBank) IsValid() error

func (ParamsGetBank) ValidChainID added in v0.5.0

func (p ParamsGetBank) ValidChainID() *factom.Bytes32

type ParamsGetGlobalRichList added in v0.4.0

type ParamsGetGlobalRichList struct {
	Count int `json:"count,omitempty"`
}

func (ParamsGetGlobalRichList) HasIncludePending added in v0.4.0

func (p ParamsGetGlobalRichList) HasIncludePending() bool

func (ParamsGetGlobalRichList) IsValid added in v0.4.0

func (p ParamsGetGlobalRichList) IsValid() error

func (ParamsGetGlobalRichList) ValidChainID added in v0.4.0

func (p ParamsGetGlobalRichList) ValidChainID() *factom.Bytes32

type ParamsGetMiningDominance added in v0.5.0

type ParamsGetMiningDominance struct {
	Start int `json:"start,omitempty"`
	Stop  int `json:"stop,omitempty"`
}

func (ParamsGetMiningDominance) HasIncludePending added in v0.5.0

func (p ParamsGetMiningDominance) HasIncludePending() bool

func (ParamsGetMiningDominance) IsValid added in v0.5.0

func (p ParamsGetMiningDominance) IsValid() error

func (ParamsGetMiningDominance) ValidChainID added in v0.5.0

func (p ParamsGetMiningDominance) ValidChainID() *factom.Bytes32

type ParamsGetPegnetBalances

type ParamsGetPegnetBalances struct {
	Address string `json:"address,omitempty"`
}

func (ParamsGetPegnetBalances) HasIncludePending

func (p ParamsGetPegnetBalances) HasIncludePending() bool

func (ParamsGetPegnetBalances) IsValid

func (p ParamsGetPegnetBalances) IsValid() error

func (ParamsGetPegnetBalances) ValidChainID

func (p ParamsGetPegnetBalances) ValidChainID() *factom.Bytes32

type ParamsGetPegnetRates

type ParamsGetPegnetRates struct {
	Height uint32 `json:"height,omitempty"`
}

func (ParamsGetPegnetRates) HasIncludePending

func (ParamsGetPegnetRates) HasIncludePending() bool

func (ParamsGetPegnetRates) IsValid

func (p ParamsGetPegnetRates) IsValid() error

func (ParamsGetPegnetRates) ValidChainID

func (ParamsGetPegnetRates) ValidChainID() *factom.Bytes32

type ParamsGetPegnetTransaction added in v0.2.1

type ParamsGetPegnetTransaction struct {
	Hash       string `json:"entryhash,omitempty"`
	Address    string `json:"address,omitempty"`
	Height     int    `json:"height,omitempty"`
	Offset     int    `json:"offset,omitempty"`
	Desc       bool   `json:"desc,omitempty"`
	Transfer   bool   `json:"transfer,omitempty"`
	Conversion bool   `json:"conversion,omitempty"`
	Coinbase   bool   `json:"coinbase,omitempty"`
	Burn       bool   `json:"burn,omitempty"`
	Asset      string `json:"asset,omitempty"`

	// TxID is in the format #-[Entryhash], where '#' == tx index
	TxID string `json:"txid,omitempty"`
	// contains filtered or unexported fields
}

ParamsGetPegnetTransaction are the parameters for retrieving transactions from the history system. You need to specify exactly one of either `hash`, `address`, or `height`. `offset` is the value from a previous query's `nextoffset`. `desc` returns transactions in newest->oldest order

func (ParamsGetPegnetTransaction) HasIncludePending added in v0.2.1

func (p ParamsGetPegnetTransaction) HasIncludePending() bool

func (ParamsGetPegnetTransaction) IsValid added in v0.2.1

func (p ParamsGetPegnetTransaction) IsValid() error

func (ParamsGetPegnetTransaction) ValidChainID added in v0.2.1

func (p ParamsGetPegnetTransaction) ValidChainID() *factom.Bytes32

type ParamsGetPegnetTransactionStatus added in v0.2.1

type ParamsGetPegnetTransactionStatus struct {
	Hash *factom.Bytes32 `json:"entryhash,omitempty"`
}

func (ParamsGetPegnetTransactionStatus) HasIncludePending added in v0.2.1

func (p ParamsGetPegnetTransactionStatus) HasIncludePending() bool

func (ParamsGetPegnetTransactionStatus) IsValid added in v0.2.1

func (ParamsGetPegnetTransactionStatus) ValidChainID added in v0.2.1

type ParamsGetRichList added in v0.4.0

type ParamsGetRichList struct {
	Asset string `json:"asset,omitempty"`
	Count int    `json:"count,omitempty"`
}

func (ParamsGetRichList) HasIncludePending added in v0.4.0

func (p ParamsGetRichList) HasIncludePending() bool

func (ParamsGetRichList) IsValid added in v0.4.0

func (p ParamsGetRichList) IsValid() error

func (ParamsGetRichList) ValidChainID added in v0.4.0

func (p ParamsGetRichList) ValidChainID() *factom.Bytes32

type ParamsGetTransaction

type ParamsGetTransaction struct {
	ParamsToken
	Hash    *factom.Bytes32 `json:"entryhash"`
	TxIndex uint64          `json:"txindex,omitempty"`
}

ParamsGetTransaction is used to query for a single particular transaction with the given Entry Hash.

func (ParamsGetTransaction) IsValid

func (p ParamsGetTransaction) IsValid() error

type ParamsSendTransaction

type ParamsSendTransaction struct {
	ParamsToken
	ExtIDs  []factom.Bytes `json:"extids,omitempty"`
	Content factom.Bytes   `json:"content,omitempty"`
	Raw     factom.Bytes   `json:"raw,omitempty"`
	DryRun  bool           `json:"dryrun,omitempty"`
	// contains filtered or unexported fields
}

func (ParamsSendTransaction) Entry

func (*ParamsSendTransaction) IsValid

func (p *ParamsSendTransaction) IsValid() error

type ParamsToken

type ParamsToken struct {
	ChainID *factom.Bytes32 `json:"chainid,omitempty"`
}

ParamsToken scopes a request down to a single FAT token using either the ChainID or both the TokenID and the IssuerChainID.

func (ParamsToken) HasIncludePending

func (p ParamsToken) HasIncludePending() bool

func (ParamsToken) IsValid

func (p ParamsToken) IsValid() error

func (ParamsToken) ValidChainID

func (p ParamsToken) ValidChainID() *factom.Bytes32

type PegnetdProperties added in v0.5.0

type PegnetdProperties struct {
	BuildVersion  string `json:"buildversion"`
	BuildCommit   string `json:"buildcommit"`
	SQLiteVersion string `json:"sqliteversion"`
	GolangVersion string `json:"golang"`
}

type ResultGetIssuance added in v0.1.1

type ResultGetIssuance struct {
	SyncStatus ResultGetSyncStatus   `json:"syncstatus"`
	Issuance   ResultPegnetTickerMap `json:"issuance"`
}

type ResultGetRichList added in v0.4.0

type ResultGetRichList struct {
	Address string `json:"address"`
	Amount  uint64 `json:"amount"`
	Equiv   uint64 `json:"pusd"`
}

type ResultGetSyncStatus

type ResultGetSyncStatus struct {
	Sync    uint32 `json:"syncheight"`
	Current int32  `json:"factomheight"`
}

type ResultGetTransactionStatus added in v0.2.1

type ResultGetTransactionStatus struct {
	Height   uint32 `json:"height"`
	Executed uint32 `json:"executed"`
}

type ResultGetTransactions added in v0.2.1

type ResultGetTransactions struct {
	Actions    interface{} `json:"actions"`
	Count      int         `json:"count"`
	NextOffset int         `json:"nextoffset"`
}

ResultGetTransactions returns history entries. `Actions` contains []pegnet.HistoryTransaction. `Count` is the total number of possible transactions `NextOffset` returns the offset to use to get the next set of records.

0 means no more records available

type ResultGlobalRichList added in v0.4.0

type ResultGlobalRichList struct {
	Address string `json:"address"`
	Equiv   uint64 `json:"pusd"`
}

type ResultPegnetTickerMap

type ResultPegnetTickerMap map[fat2.PTicker]uint64

TODO: This is incompatible with FAT.

func (ResultPegnetTickerMap) MarshalJSON

func (r ResultPegnetTickerMap) MarshalJSON() ([]byte, error)

func (*ResultPegnetTickerMap) UnmarshalJSON

func (r *ResultPegnetTickerMap) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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