client

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0, BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package client implements a very simple wrapper for ZIPP's web API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadRequest defines the "bad request" error.
	ErrBadRequest = errors.New("bad request")
	// ErrInternalServerError defines the "internal server error" error.
	ErrInternalServerError = errors.New("internal server error")
	// ErrNotFound defines the "not found" error.
	ErrNotFound = errors.New("not found")
	// ErrUnauthorized defines the "unauthorized" error.
	ErrUnauthorized = errors.New("unauthorized")
	// ErrUnknownError defines the "unknown error" error.
	ErrUnknownError = errors.New("unknown error")
	// ErrNotImplemented defines the "operation not implemented/supported/available" error.
	ErrNotImplemented = errors.New("operation not implemented/supported/available")
)

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth struct {
	Enabled  bool   `json:"enabled,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth defines the basic-auth struct.

func (BasicAuth) Credentials

func (b BasicAuth) Credentials() (username, password string)

Credentials returns the username and password of a given BasicAuth.

func (BasicAuth) IsEnabled

func (b BasicAuth) IsEnabled() bool

IsEnabled returns the enabled state of a given BasicAuth.

type Option

type Option func(*ZIPPAPI)

Option is a function which sets the given option.

func WithBasicAuth

func WithBasicAuth(username, password string) Option

WithBasicAuth returns a new BasicAuth.

func WithHTTPClient

func WithHTTPClient(c http.Client) Option

WithHTTPClient sets the http Client.

type ZIPPAPI

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

ZIPPAPI is an API wrapper over the web API of ZIPP.

func NewZIPPAPI

func NewZIPPAPI(baseURL string, setters ...Option) *ZIPPAPI

NewZIPPAPI returns a new *ZIPPAPI with the given baseURL and options.

func (*ZIPPAPI) AddManualPeers

func (api *ZIPPAPI) AddManualPeers(peers []*manualpeering.KnownPeerToAdd) error

AddManualPeers adds the provided list of peers to the manual peering layer.

func (*ZIPPAPI) BaseURL

func (api *ZIPPAPI) BaseURL() string

BaseURL returns the baseURL of the API.

func (*ZIPPAPI) BroadcastFaucetRequest

func (api *ZIPPAPI) BroadcastFaucetRequest(base58EncodedAddr string, powTarget int, pledgeIDs ...string) (*jsonmodels.FaucetRequestResponse, error)

BroadcastFaucetRequest requests funds from faucet nodes by sending a faucet request payload block.

func (*ZIPPAPI) Data

func (api *ZIPPAPI) Data(data []byte) (string, error)

Data sends the given data (payload) by creating a block in the backend.

func (*ZIPPAPI) GetAddressOutputs

func (api *ZIPPAPI) GetAddressOutputs(base58EncodedAddress string) (*jsonmodels.GetAddressResponse, error)

GetAddressOutputs gets the spent and unspent outputs of an address.

func (*ZIPPAPI) GetAddressUnspentOutputs added in v0.1.2

func (api *ZIPPAPI) GetAddressUnspentOutputs(base58EncodedAddress string) (*jsonmodels.GetAddressResponse, error)

GetAddressUnspentOutputs gets the unspent outputs of an address.

func (*ZIPPAPI) GetAllMana

func (api *ZIPPAPI) GetAllMana() (*jsonmodels.GetAllManaResponse, error)

GetAllMana returns the mana perception of the node in the network.

func (*ZIPPAPI) GetAllowedManaPledgeNodeIDs added in v0.1.2

func (api *ZIPPAPI) GetAllowedManaPledgeNodeIDs() (*jsonmodels.AllowedManaPledgeResponse, error)

GetAllowedManaPledgeNodeIDs returns the list of allowed mana pledge IDs.

func (*ZIPPAPI) GetAutopeeringNeighbors

func (api *ZIPPAPI) GetAutopeeringNeighbors(knownPeers bool) (*jsonmodels.GetNeighborsResponse, error)

GetAutopeeringNeighbors gets the chosen/accepted neighbors. If knownPeers is set, also all known peers to the node are returned additionally.

func (*ZIPPAPI) GetBlock

func (api *ZIPPAPI) GetBlock(base58EncodedID string) (*jsonmodels.Block, error)

GetBlock is the handler for the /blocks/:blockID endpoint.

func (*ZIPPAPI) GetBlockMetadata

func (api *ZIPPAPI) GetBlockMetadata(base58EncodedID string) (*jsonmodels.BlockMetadata, error)

GetBlockMetadata is the handler for the /blocks/:blockID/metadata endpoint.

func (*ZIPPAPI) GetConflict

func (api *ZIPPAPI) GetConflict(base58EncodedConflictID string) (*jsonmodels.Conflict, error)

GetConflict gets the conflict information.

func (*ZIPPAPI) GetConflictChildren

func (api *ZIPPAPI) GetConflictChildren(base58EncodedConflictID string) (*jsonmodels.GetConflictChildrenResponse, error)

GetConflictChildren gets the children of a conflict.

func (*ZIPPAPI) GetConflictConflicts

func (api *ZIPPAPI) GetConflictConflicts(base58EncodedConflictID string) (*jsonmodels.GetConflictConflictsResponse, error)

GetConflictConflicts gets the conflict conflicts of a conflict.

func (*ZIPPAPI) GetConflictVoters

func (api *ZIPPAPI) GetConflictVoters(base58EncodedConflictID string) (*jsonmodels.GetConflictVotersResponse, error)

GetConflictVoters gets the Voters of a conflict.

func (*ZIPPAPI) GetConsensusEventLogs

func (api *ZIPPAPI) GetConsensusEventLogs(nodeIDs []string) (*jsonmodels.GetEventLogsResponse, error)

GetConsensusEventLogs returns the consensus event logs or the nodeIDs specified.

func (*ZIPPAPI) GetMana

func (api *ZIPPAPI) GetMana(shortNodeID string) (*jsonmodels.GetManaResponse, error)

GetMana returns the access and consensus mana a node has based on its shortNodeID.

func (*ZIPPAPI) GetManaFullNodeID added in v0.1.2

func (api *ZIPPAPI) GetManaFullNodeID(fullNodeID string) (*jsonmodels.GetManaResponse, error)

GetManaFullNodeID returns the access and consensus mana of the node specified in the argument. Note, that for the node to understand which nodeID we are referring to, short node ID is not sufficient.

func (*ZIPPAPI) GetManaPercentile

func (api *ZIPPAPI) GetManaPercentile(fullNodeID string) (*jsonmodels.GetPercentileResponse, error)

GetManaPercentile returns the mana percentile for access and consensus mana of a node.

func (*ZIPPAPI) GetManualPeers

func (api *ZIPPAPI) GetManualPeers(opts ...manualpeering.GetPeersOption) (
	peers []*manualpeering.KnownPeer, err error,
)

GetManualPeers gets the list of connected neighbors from the manual peering layer.

func (*ZIPPAPI) GetNHighestAccessMana

func (api *ZIPPAPI) GetNHighestAccessMana(n int) (*jsonmodels.GetNHighestResponse, error)

GetNHighestAccessMana returns the N highest access mana holders in the network, sorted in descending order.

func (*ZIPPAPI) GetNHighestConsensusMana

func (api *ZIPPAPI) GetNHighestConsensusMana(n int) (*jsonmodels.GetNHighestResponse, error)

GetNHighestConsensusMana returns the N highest consensus mana holders in the network, sorted in descending order.

func (*ZIPPAPI) GetOnlineAccessMana

func (api *ZIPPAPI) GetOnlineAccessMana() (*jsonmodels.GetOnlineResponse, error)

GetOnlineAccessMana returns the sorted list of online access mana of nodes.

func (*ZIPPAPI) GetOnlineConsensusMana

func (api *ZIPPAPI) GetOnlineConsensusMana() (*jsonmodels.GetOnlineResponse, error)

GetOnlineConsensusMana returns the sorted list of online consensus mana of nodes.

func (*ZIPPAPI) GetOutput

func (api *ZIPPAPI) GetOutput(base58EncodedOutputID string) (*jsonmodels.Output, error)

GetOutput gets the output corresponding to OutputID.

func (*ZIPPAPI) GetOutputConsumers

func (api *ZIPPAPI) GetOutputConsumers(base58EncodedOutputID string) (*jsonmodels.GetOutputConsumersResponse, error)

GetOutputConsumers gets the consumers of the output corresponding to OutputID.

func (*ZIPPAPI) GetOutputMetadata

func (api *ZIPPAPI) GetOutputMetadata(base58EncodedOutputID string) (*jsonmodels.OutputMetadata, error)

GetOutputMetadata gets the metadata of the output corresponding to OutputID.

func (*ZIPPAPI) GetOwnMana

func (api *ZIPPAPI) GetOwnMana() (*jsonmodels.GetManaResponse, error)

GetOwnMana returns the access and consensus mana of the node this api client is communicating with.

func (*ZIPPAPI) GetPeerFaultinessCount added in v0.1.2

func (api *ZIPPAPI) GetPeerFaultinessCount(peerID identity.ID) (int, error)

GetPeerFaultinessCount return number of time peer has been marked as faulty.

func (*ZIPPAPI) GetTransaction

func (api *ZIPPAPI) GetTransaction(base58EncodedTransactionID string) (*jsonmodels.Transaction, error)

GetTransaction gets the transaction of the corresponding to TransactionID.

func (*ZIPPAPI) GetTransactionAttachments

func (api *ZIPPAPI) GetTransactionAttachments(base58EncodedTransactionID string) (*jsonmodels.GetTransactionAttachmentsResponse, error)

GetTransactionAttachments gets the attachments (blockIDs) of the transaction corresponding to TransactionID.

func (*ZIPPAPI) GetTransactionMetadata

func (api *ZIPPAPI) GetTransactionMetadata(base58EncodedTransactionID string) (*jsonmodels.TransactionMetadata, error)

GetTransactionMetadata gets metadata of the transaction corresponding to TransactionID.

func (*ZIPPAPI) HealthCheck

func (api *ZIPPAPI) HealthCheck() error

HealthCheck checks whether the node is running and healthy.

func (*ZIPPAPI) Info

func (api *ZIPPAPI) Info() (*jsonmodels.InfoResponse, error)

Info gets the info of the node.

func (*ZIPPAPI) PostAddressUnspentOutputs

func (api *ZIPPAPI) PostAddressUnspentOutputs(base58EncodedAddresses []string) (*jsonmodels.PostAddressesUnspentOutputsResponse, error)

PostAddressUnspentOutputs gets the unspent outputs of several addresses.

func (*ZIPPAPI) PostTransaction

func (api *ZIPPAPI) PostTransaction(transactionBytes []byte) (*jsonmodels.PostTransactionResponse, error)

PostTransaction sends the transaction(bytes) to the Mesh and returns its transaction ID.

func (*ZIPPAPI) RateSetter

func (api *ZIPPAPI) RateSetter() (*jsonmodels.RateSetter, error)

RateSetter gets the ratesetter estimate and the rate-setter info.

func (*ZIPPAPI) RemoveManualPeers

func (api *ZIPPAPI) RemoveManualPeers(keys []ed25519.PublicKey) error

RemoveManualPeers remove the provided list of peers from the manual peering layer.

func (*ZIPPAPI) SendFaucetRequestAPI

func (api *ZIPPAPI) SendFaucetRequestAPI(base58EncodedAddr string, powTarget int, accessPledgeID, consensusPledgeID string) (*jsonmodels.FaucetAPIResponse, error)

SendFaucetRequestAPI requests funds from faucet nodes by sending a faucet request directly to the faucet node.

func (*ZIPPAPI) SendPayload

func (api *ZIPPAPI) SendPayload(payload []byte) (string, error)

SendPayload send a block with the given payload.

func (*ZIPPAPI) SleepRateSetterEstimate

func (api *ZIPPAPI) SleepRateSetterEstimate() error

SleepRateSetterEstimate gets the rate-setter estimate and the rate-setter info and later sleeps the estimated amount of time.

func (*ZIPPAPI) ToggleSpammer

func (api *ZIPPAPI) ToggleSpammer(enable bool, rate int, unit, imif string) (*jsonmodels.SpammerResponse, error)

ToggleSpammer toggles the node internal spammer.

Jump to

Keyboard shortcuts

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