Documentation ¶
Overview ¶
Package client implements a very simple wrapper for GoShimmer's web API.
Index ¶
- Variables
- type BasicAuth
- type GoShimmerAPI
- func (api *GoShimmerAPI) AddManualPeers(peers []*manualpeering.KnownPeerToAdd) error
- func (api *GoShimmerAPI) BaseURL() string
- func (api *GoShimmerAPI) BroadcastFaucetRequest(base58EncodedAddr string, powTarget int, pledgeIDs ...string) (*jsonmodels.FaucetRequestResponse, error)
- func (api *GoShimmerAPI) Data(data []byte) (string, error)
- func (api *GoShimmerAPI) GetAddressOutputs(base58EncodedAddress string) (*jsonmodels.GetAddressResponse, error)
- func (api *GoShimmerAPI) GetAddressUnspentOutputs(base58EncodedAddress string) (*jsonmodels.GetAddressResponse, error)
- func (api *GoShimmerAPI) GetAllMana() (*jsonmodels.GetAllManaResponse, error)
- func (api *GoShimmerAPI) GetAllowedManaPledgeNodeIDs() (*jsonmodels.AllowedManaPledgeResponse, error)
- func (api *GoShimmerAPI) GetAutopeeringNeighbors(knownPeers bool) (*jsonmodels.GetNeighborsResponse, error)
- func (api *GoShimmerAPI) GetBlock(base58EncodedID string) (*jsonmodels.Block, error)
- func (api *GoShimmerAPI) GetBlockMetadata(base58EncodedID string) (*jsonmodels.BlockMetadata, error)
- func (api *GoShimmerAPI) GetConflict(base58EncodedConflictID string) (*jsonmodels.Conflict, error)
- func (api *GoShimmerAPI) GetConflictChildren(base58EncodedConflictID string) (*jsonmodels.GetConflictChildrenResponse, error)
- func (api *GoShimmerAPI) GetConflictConflicts(base58EncodedConflictID string) (*jsonmodels.GetConflictConflictsResponse, error)
- func (api *GoShimmerAPI) GetConflictVoters(base58EncodedConflictID string) (*jsonmodels.GetConflictVotersResponse, error)
- func (api *GoShimmerAPI) GetConsensusEventLogs(nodeIDs []string) (*jsonmodels.GetEventLogsResponse, error)
- func (api *GoShimmerAPI) GetMana(shortNodeID string) (*jsonmodels.GetManaResponse, error)
- func (api *GoShimmerAPI) GetManaFullNodeID(fullNodeID string) (*jsonmodels.GetManaResponse, error)
- func (api *GoShimmerAPI) GetManaPercentile(fullNodeID string) (*jsonmodels.GetPercentileResponse, error)
- func (api *GoShimmerAPI) GetManualPeers(opts ...manualpeering.GetPeersOption) (peers []*manualpeering.KnownPeer, err error)
- func (api *GoShimmerAPI) GetNHighestAccessMana(n int) (*jsonmodels.GetNHighestResponse, error)
- func (api *GoShimmerAPI) GetNHighestConsensusMana(n int) (*jsonmodels.GetNHighestResponse, error)
- func (api *GoShimmerAPI) GetOnlineAccessMana() (*jsonmodels.GetOnlineResponse, error)
- func (api *GoShimmerAPI) GetOnlineConsensusMana() (*jsonmodels.GetOnlineResponse, error)
- func (api *GoShimmerAPI) GetOutput(base58EncodedOutputID string) (*jsonmodels.Output, error)
- func (api *GoShimmerAPI) GetOutputConsumers(base58EncodedOutputID string) (*jsonmodels.GetOutputConsumersResponse, error)
- func (api *GoShimmerAPI) GetOutputMetadata(base58EncodedOutputID string) (*jsonmodels.OutputMetadata, error)
- func (api *GoShimmerAPI) GetOwnMana() (*jsonmodels.GetManaResponse, error)
- func (api *GoShimmerAPI) GetPeerFaultinessCount(peerID identity.ID) (int, error)
- func (api *GoShimmerAPI) GetTransaction(base58EncodedTransactionID string) (*jsonmodels.Transaction, error)
- func (api *GoShimmerAPI) GetTransactionAttachments(base58EncodedTransactionID string) (*jsonmodels.GetTransactionAttachmentsResponse, error)
- func (api *GoShimmerAPI) GetTransactionMetadata(base58EncodedTransactionID string) (*jsonmodels.TransactionMetadata, error)
- func (api *GoShimmerAPI) HealthCheck() error
- func (api *GoShimmerAPI) Info() (*jsonmodels.InfoResponse, error)
- func (api *GoShimmerAPI) PostAddressUnspentOutputs(base58EncodedAddresses []string) (*jsonmodels.PostAddressesUnspentOutputsResponse, error)
- func (api *GoShimmerAPI) PostTransaction(transactionBytes []byte) (*jsonmodels.PostTransactionResponse, error)
- func (api *GoShimmerAPI) RateSetter() (*jsonmodels.RateSetter, error)
- func (api *GoShimmerAPI) RemoveManualPeers(keys []ed25519.PublicKey) error
- func (api *GoShimmerAPI) SendFaucetRequestAPI(base58EncodedAddr string, powTarget int, ...) (*jsonmodels.FaucetAPIResponse, error)
- func (api *GoShimmerAPI) SendPayload(payload []byte) (string, error)
- func (api *GoShimmerAPI) SleepRateSetterEstimate() error
- func (api *GoShimmerAPI) ToggleSpammer(enable bool, rate int, unit, imif string) (*jsonmodels.SpammerResponse, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
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 = 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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
Credentials returns the username and password of a given BasicAuth.
type GoShimmerAPI ¶
type GoShimmerAPI struct {
// contains filtered or unexported fields
}
GoShimmerAPI is an API wrapper over the web API of GoShimmer.
func NewGoShimmerAPI ¶
func NewGoShimmerAPI(baseURL string, setters ...Option) *GoShimmerAPI
NewGoShimmerAPI returns a new *GoShimmerAPI with the given baseURL and options.
func (*GoShimmerAPI) AddManualPeers ¶ added in v0.5.8
func (api *GoShimmerAPI) AddManualPeers(peers []*manualpeering.KnownPeerToAdd) error
AddManualPeers adds the provided list of peers to the manual peering layer.
func (*GoShimmerAPI) BaseURL ¶ added in v0.2.0
func (api *GoShimmerAPI) BaseURL() string
BaseURL returns the baseURL of the API.
func (*GoShimmerAPI) BroadcastFaucetRequest ¶ added in v0.9.1
func (api *GoShimmerAPI) BroadcastFaucetRequest(base58EncodedAddr string, powTarget int, pledgeIDs ...string) (*jsonmodels.FaucetRequestResponse, error)
BroadcastFaucetRequest requests funds from faucet nodes by sending a faucet request payload block.
func (*GoShimmerAPI) Data ¶ added in v0.2.0
func (api *GoShimmerAPI) Data(data []byte) (string, error)
Data sends the given data (payload) by creating a block in the backend.
func (*GoShimmerAPI) GetAddressOutputs ¶ added in v0.6.0
func (api *GoShimmerAPI) GetAddressOutputs(base58EncodedAddress string) (*jsonmodels.GetAddressResponse, error)
GetAddressOutputs gets the spent and unspent outputs of an address.
func (*GoShimmerAPI) GetAddressUnspentOutputs ¶ added in v0.6.0
func (api *GoShimmerAPI) GetAddressUnspentOutputs(base58EncodedAddress string) (*jsonmodels.GetAddressResponse, error)
GetAddressUnspentOutputs gets the unspent outputs of an address.
func (*GoShimmerAPI) GetAllMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetAllMana() (*jsonmodels.GetAllManaResponse, error)
GetAllMana returns the mana perception of the node in the network.
func (*GoShimmerAPI) GetAllowedManaPledgeNodeIDs ¶ added in v0.5.0
func (api *GoShimmerAPI) GetAllowedManaPledgeNodeIDs() (*jsonmodels.AllowedManaPledgeResponse, error)
GetAllowedManaPledgeNodeIDs returns the list of allowed mana pledge IDs.
func (*GoShimmerAPI) GetAutopeeringNeighbors ¶ added in v0.5.8
func (api *GoShimmerAPI) 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 (*GoShimmerAPI) GetBlock ¶ added in v0.9.2
func (api *GoShimmerAPI) GetBlock(base58EncodedID string) (*jsonmodels.Block, error)
GetBlock is the handler for the /blocks/:blockID endpoint.
func (*GoShimmerAPI) GetBlockMetadata ¶ added in v0.9.2
func (api *GoShimmerAPI) GetBlockMetadata(base58EncodedID string) (*jsonmodels.BlockMetadata, error)
GetBlockMetadata is the handler for the /blocks/:blockID/metadata endpoint.
func (*GoShimmerAPI) GetConflict ¶ added in v0.9.2
func (api *GoShimmerAPI) GetConflict(base58EncodedConflictID string) (*jsonmodels.Conflict, error)
GetConflict gets the conflict information.
func (*GoShimmerAPI) GetConflictChildren ¶ added in v0.9.2
func (api *GoShimmerAPI) GetConflictChildren(base58EncodedConflictID string) (*jsonmodels.GetConflictChildrenResponse, error)
GetConflictChildren gets the children of a conflict.
func (*GoShimmerAPI) GetConflictConflicts ¶ added in v0.9.2
func (api *GoShimmerAPI) GetConflictConflicts(base58EncodedConflictID string) (*jsonmodels.GetConflictConflictsResponse, error)
GetConflictConflicts gets the conflict conflicts of a conflict.
func (*GoShimmerAPI) GetConflictVoters ¶ added in v0.9.2
func (api *GoShimmerAPI) GetConflictVoters(base58EncodedConflictID string) (*jsonmodels.GetConflictVotersResponse, error)
GetConflictVoters gets the Voters of a conflict.
func (*GoShimmerAPI) GetConsensusEventLogs ¶ added in v0.5.0
func (api *GoShimmerAPI) GetConsensusEventLogs(nodeIDs []string) (*jsonmodels.GetEventLogsResponse, error)
GetConsensusEventLogs returns the consensus event logs or the nodeIDs specified.
func (*GoShimmerAPI) GetMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetMana(shortNodeID string) (*jsonmodels.GetManaResponse, error)
GetMana returns the access and consensus mana a node has based on its shortNodeID.
func (*GoShimmerAPI) GetManaFullNodeID ¶ added in v0.5.0
func (api *GoShimmerAPI) 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 (*GoShimmerAPI) GetManaPercentile ¶ added in v0.5.0
func (api *GoShimmerAPI) GetManaPercentile(fullNodeID string) (*jsonmodels.GetPercentileResponse, error)
GetManaPercentile returns the mana percentile for access and consensus mana of a node.
func (*GoShimmerAPI) GetManualPeers ¶ added in v0.6.4
func (api *GoShimmerAPI) GetManualPeers(opts ...manualpeering.GetPeersOption) ( peers []*manualpeering.KnownPeer, err error, )
GetManualPeers gets the list of connected neighbors from the manual peering layer.
func (*GoShimmerAPI) GetNHighestAccessMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetNHighestAccessMana(n int) (*jsonmodels.GetNHighestResponse, error)
GetNHighestAccessMana returns the N highest access mana holders in the network, sorted in descending order.
func (*GoShimmerAPI) GetNHighestConsensusMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetNHighestConsensusMana(n int) (*jsonmodels.GetNHighestResponse, error)
GetNHighestConsensusMana returns the N highest consensus mana holders in the network, sorted in descending order.
func (*GoShimmerAPI) GetOnlineAccessMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetOnlineAccessMana() (*jsonmodels.GetOnlineResponse, error)
GetOnlineAccessMana returns the sorted list of online access mana of nodes.
func (*GoShimmerAPI) GetOnlineConsensusMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetOnlineConsensusMana() (*jsonmodels.GetOnlineResponse, error)
GetOnlineConsensusMana returns the sorted list of online consensus mana of nodes.
func (*GoShimmerAPI) GetOutput ¶ added in v0.6.0
func (api *GoShimmerAPI) GetOutput(base58EncodedOutputID string) (*jsonmodels.Output, error)
GetOutput gets the output corresponding to OutputID.
func (*GoShimmerAPI) GetOutputConsumers ¶ added in v0.6.0
func (api *GoShimmerAPI) GetOutputConsumers(base58EncodedOutputID string) (*jsonmodels.GetOutputConsumersResponse, error)
GetOutputConsumers gets the consumers of the output corresponding to OutputID.
func (*GoShimmerAPI) GetOutputMetadata ¶ added in v0.6.0
func (api *GoShimmerAPI) GetOutputMetadata(base58EncodedOutputID string) (*jsonmodels.OutputMetadata, error)
GetOutputMetadata gets the metadata of the output corresponding to OutputID.
func (*GoShimmerAPI) GetOwnMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetOwnMana() (*jsonmodels.GetManaResponse, error)
GetOwnMana returns the access and consensus mana of the node this api client is communicating with.
func (*GoShimmerAPI) GetPeerFaultinessCount ¶ added in v0.8.6
func (api *GoShimmerAPI) GetPeerFaultinessCount(peerID identity.ID) (int, error)
GetPeerFaultinessCount return number of time peer has been marked as faulty.
func (*GoShimmerAPI) GetTransaction ¶ added in v0.6.0
func (api *GoShimmerAPI) GetTransaction(base58EncodedTransactionID string) (*jsonmodels.Transaction, error)
GetTransaction gets the transaction of the corresponding to TransactionID.
func (*GoShimmerAPI) GetTransactionAttachments ¶ added in v0.6.0
func (api *GoShimmerAPI) GetTransactionAttachments(base58EncodedTransactionID string) (*jsonmodels.GetTransactionAttachmentsResponse, error)
GetTransactionAttachments gets the attachments (blockIDs) of the transaction corresponding to TransactionID.
func (*GoShimmerAPI) GetTransactionMetadata ¶ added in v0.6.0
func (api *GoShimmerAPI) GetTransactionMetadata(base58EncodedTransactionID string) (*jsonmodels.TransactionMetadata, error)
GetTransactionMetadata gets metadata of the transaction corresponding to TransactionID.
func (*GoShimmerAPI) HealthCheck ¶ added in v0.7.3
func (api *GoShimmerAPI) HealthCheck() error
HealthCheck checks whether the node is running and healthy.
func (*GoShimmerAPI) Info ¶ added in v0.2.0
func (api *GoShimmerAPI) Info() (*jsonmodels.InfoResponse, error)
Info gets the info of the node.
func (*GoShimmerAPI) PostAddressUnspentOutputs ¶ added in v0.6.0
func (api *GoShimmerAPI) PostAddressUnspentOutputs(base58EncodedAddresses []string) (*jsonmodels.PostAddressesUnspentOutputsResponse, error)
PostAddressUnspentOutputs gets the unspent outputs of several addresses.
func (*GoShimmerAPI) PostTransaction ¶ added in v0.6.0
func (api *GoShimmerAPI) PostTransaction(transactionBytes []byte) (*jsonmodels.PostTransactionResponse, error)
PostTransaction sends the transaction(bytes) to the Tangle and returns its transaction ID.
func (*GoShimmerAPI) RateSetter ¶ added in v0.9.1
func (api *GoShimmerAPI) RateSetter() (*jsonmodels.RateSetter, error)
RateSetter gets the ratesetter estimate and the rate-setter info.
func (*GoShimmerAPI) RemoveManualPeers ¶ added in v0.5.8
func (api *GoShimmerAPI) RemoveManualPeers(keys []ed25519.PublicKey) error
RemoveManualPeers remove the provided list of peers from the manual peering layer.
func (*GoShimmerAPI) SendFaucetRequestAPI ¶ added in v0.9.1
func (api *GoShimmerAPI) 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 (*GoShimmerAPI) SendPayload ¶ added in v0.2.0
func (api *GoShimmerAPI) SendPayload(payload []byte) (string, error)
SendPayload send a block with the given payload.
func (*GoShimmerAPI) SleepRateSetterEstimate ¶ added in v0.9.1
func (api *GoShimmerAPI) SleepRateSetterEstimate() error
SleepRateSetterEstimate gets the rate-setter estimate and the rate-setter info and later sleeps the estimated amount of time.
func (*GoShimmerAPI) ToggleSpammer ¶
func (api *GoShimmerAPI) ToggleSpammer(enable bool, rate int, unit, imif string) (*jsonmodels.SpammerResponse, error)
ToggleSpammer toggles the node internal spammer.
type Option ¶ added in v0.3.0
type Option func(*GoShimmerAPI)
Option is a function which sets the given option.
func WithBasicAuth ¶ added in v0.3.0
WithBasicAuth returns a new BasicAuth.
func WithHTTPClient ¶ added in v0.3.0
WithHTTPClient sets the http Client.