Documentation ¶
Overview ¶
Package client implements a very simple wrapper for GoShimmer's web API.
Index ¶
- Variables
- type BasicAuth
- type GoShimmerAPI
- func (api *GoShimmerAPI) BaseURL() string
- func (api *GoShimmerAPI) BroadcastCollectiveBeacon(payload []byte) (string, error)
- func (api *GoShimmerAPI) Data(data []byte) (string, error)
- func (api *GoShimmerAPI) FindMessageByID(base58EncodedIDs []string) (*webapi_message.FindByIDResponse, error)
- func (api *GoShimmerAPI) GetAllMana() (*webapi_mana.GetAllManaResponse, error)
- func (api *GoShimmerAPI) GetAllowedManaPledgeNodeIDs() (*webapi_value.AllowedManaPledgeResponse, error)
- func (api *GoShimmerAPI) GetAttachments(base58EncodedTxnID string) (*webapi_value.AttachmentsResponse, error)
- func (api *GoShimmerAPI) GetCommittee() (*webapi_drng.CommitteeResponse, error)
- func (api *GoShimmerAPI) GetConsensusEventLogs(nodeIDs []string) (*webapi_mana.GetEventLogsResponse, error)
- func (api *GoShimmerAPI) GetMana(shortNodeID string) (*webapi_mana.GetManaResponse, error)
- func (api *GoShimmerAPI) GetManaFullNodeID(fullNodeID string) (*webapi_mana.GetManaResponse, error)
- func (api *GoShimmerAPI) GetManaPercentile(fullNodeID string) (*webapi_mana.GetPercentileResponse, error)
- func (api *GoShimmerAPI) GetNHighestAccessMana(n int) (*webapi_mana.GetNHighestResponse, error)
- func (api *GoShimmerAPI) GetNHighestConsensusMana(n int) (*webapi_mana.GetNHighestResponse, error)
- func (api *GoShimmerAPI) GetNeighbors(knownPeers bool) (*webapi_autopeering.Response, error)
- func (api *GoShimmerAPI) GetOnlineAccessMana() (*webapi_mana.GetOnlineResponse, error)
- func (api *GoShimmerAPI) GetOnlineConsensusMana() (*webapi_mana.GetOnlineResponse, error)
- func (api *GoShimmerAPI) GetOwnMana() (*webapi_mana.GetManaResponse, error)
- func (api *GoShimmerAPI) GetPastConsensusManaVector(t int64) (*webapi_mana.PastConsensusManaVectorResponse, error)
- func (api *GoShimmerAPI) GetPastConsensusVectorMetadata() (*webapi_mana.PastConsensusVectorMetadataResponse, error)
- func (api *GoShimmerAPI) GetPending(outputID string) (*webapi_mana.PendingResponse, error)
- func (api *GoShimmerAPI) GetRandomness() (*webapi_drng.RandomnessResponse, error)
- func (api *GoShimmerAPI) GetTransactionByID(base58EncodedTxnID string) (*webapi_value.GetTransactionByIDResponse, error)
- func (api *GoShimmerAPI) GetUnspentOutputs(addresses []string) (*webapi_value.UnspentOutputsResponse, error)
- func (api *GoShimmerAPI) Info() (*webapi_info.Response, error)
- func (api *GoShimmerAPI) Missing() (*webapi_tools_message.MissingResponse, error)
- func (api *GoShimmerAPI) PastConeExist(base58EncodedMessageID string) (*webapi_tools_message.PastconeResponse, error)
- func (api *GoShimmerAPI) SendFaucetRequest(base58EncodedAddr string) (*webapi_faucet.Response, error)
- func (api *GoShimmerAPI) SendPayload(payload []byte) (string, error)
- func (api *GoShimmerAPI) SendTransaction(txnBytes []byte) (string, error)
- func (api *GoShimmerAPI) SendTransactionByJSON(txn webapi_value.SendTransactionByJSONRequest) (string, error)
- func (api *GoShimmerAPI) ToggleSpammer(enable bool, mpm int) (*webapi_spammer.Response, error)
- func (api *GoShimmerAPI) ValueObjects() (*webapi_tools_value.ObjectsResponse, 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) BaseURL ¶ added in v0.2.0
func (api *GoShimmerAPI) BaseURL() string
BaseURL returns the baseURL of the API.
func (*GoShimmerAPI) BroadcastCollectiveBeacon ¶ added in v0.2.0
func (api *GoShimmerAPI) BroadcastCollectiveBeacon(payload []byte) (string, error)
BroadcastCollectiveBeacon sends the given collective beacon (payload) by creating a message in the backend.
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 message in the backend.
func (*GoShimmerAPI) FindMessageByID ¶ added in v0.2.0
func (api *GoShimmerAPI) FindMessageByID(base58EncodedIDs []string) (*webapi_message.FindByIDResponse, error)
FindMessageByID finds messages by the given base58 encoded IDs. The messages are returned in the same order as the given IDs. Non available messages are empty at their corresponding index.
func (*GoShimmerAPI) GetAllMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetAllMana() (*webapi_mana.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() (*webapi_value.AllowedManaPledgeResponse, error)
GetAllowedManaPledgeNodeIDs returns the list of allowed mana pledge IDs.
func (*GoShimmerAPI) GetAttachments ¶ added in v0.2.0
func (api *GoShimmerAPI) GetAttachments(base58EncodedTxnID string) (*webapi_value.AttachmentsResponse, error)
GetAttachments gets the attachments of a transaction ID
func (*GoShimmerAPI) GetCommittee ¶ added in v0.2.0
func (api *GoShimmerAPI) GetCommittee() (*webapi_drng.CommitteeResponse, error)
GetCommittee gets the current committee.
func (*GoShimmerAPI) GetConsensusEventLogs ¶ added in v0.5.0
func (api *GoShimmerAPI) GetConsensusEventLogs(nodeIDs []string) (*webapi_mana.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) (*webapi_mana.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) (*webapi_mana.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) (*webapi_mana.GetPercentileResponse, error)
GetManaPercentile returns the mana percentile for access and consensus mana of a node.
func (*GoShimmerAPI) GetNHighestAccessMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetNHighestAccessMana(n int) (*webapi_mana.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) (*webapi_mana.GetNHighestResponse, error)
GetNHighestConsensusMana returns the N highest consensus mana holders in the network, sorted in descending order.
func (*GoShimmerAPI) GetNeighbors ¶
func (api *GoShimmerAPI) GetNeighbors(knownPeers bool) (*webapi_autopeering.Response, error)
GetNeighbors gets the chosen/accepted neighbors. If knownPeers is set, also all known peers to the node are returned additionally.
func (*GoShimmerAPI) GetOnlineAccessMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetOnlineAccessMana() (*webapi_mana.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() (*webapi_mana.GetOnlineResponse, error)
GetOnlineConsensusMana returns the sorted list of online consensus mana of nodes.
func (*GoShimmerAPI) GetOwnMana ¶ added in v0.5.0
func (api *GoShimmerAPI) GetOwnMana() (*webapi_mana.GetManaResponse, error)
GetOwnMana returns the access and consensus mana of the node this api client is communicating with.
func (*GoShimmerAPI) GetPastConsensusManaVector ¶ added in v0.5.0
func (api *GoShimmerAPI) GetPastConsensusManaVector(t int64) (*webapi_mana.PastConsensusManaVectorResponse, error)
GetPastConsensusManaVector returns the consensus base mana vector of a time in the past.
func (*GoShimmerAPI) GetPastConsensusVectorMetadata ¶ added in v0.5.0
func (api *GoShimmerAPI) GetPastConsensusVectorMetadata() (*webapi_mana.PastConsensusVectorMetadataResponse, error)
GetPastConsensusVectorMetadata returns the consensus base mana vector metadata of a time in the past.
func (*GoShimmerAPI) GetPending ¶ added in v0.5.0
func (api *GoShimmerAPI) GetPending(outputID string) (*webapi_mana.PendingResponse, error)
GetPending returns the mana (bm2) that will be pledged by spending the output specified.
func (*GoShimmerAPI) GetRandomness ¶ added in v0.2.0
func (api *GoShimmerAPI) GetRandomness() (*webapi_drng.RandomnessResponse, error)
GetRandomness gets the current randomness.
func (*GoShimmerAPI) GetTransactionByID ¶ added in v0.2.0
func (api *GoShimmerAPI) GetTransactionByID(base58EncodedTxnID string) (*webapi_value.GetTransactionByIDResponse, error)
GetTransactionByID gets the transaction of a transaction ID
func (*GoShimmerAPI) GetUnspentOutputs ¶ added in v0.2.0
func (api *GoShimmerAPI) GetUnspentOutputs(addresses []string) (*webapi_value.UnspentOutputsResponse, error)
GetUnspentOutputs return unspent output IDs of addresses
func (*GoShimmerAPI) Info ¶ added in v0.2.0
func (api *GoShimmerAPI) Info() (*webapi_info.Response, error)
Info gets the info of the node.
func (*GoShimmerAPI) Missing ¶ added in v0.2.4
func (api *GoShimmerAPI) Missing() (*webapi_tools_message.MissingResponse, error)
Missing returns all the missing messages and their count.
func (*GoShimmerAPI) PastConeExist ¶ added in v0.2.2
func (api *GoShimmerAPI) PastConeExist(base58EncodedMessageID string) (*webapi_tools_message.PastconeResponse, error)
PastConeExist checks that all of the messages in the past cone of a message are existing on the node down to the genesis. Returns the number of messages in the past cone as well.
func (*GoShimmerAPI) SendFaucetRequest ¶ added in v0.2.0
func (api *GoShimmerAPI) SendFaucetRequest(base58EncodedAddr string) (*webapi_faucet.Response, error)
SendFaucetRequest requests funds from faucet nodes by sending a faucet request payload message.
func (*GoShimmerAPI) SendPayload ¶ added in v0.2.0
func (api *GoShimmerAPI) SendPayload(payload []byte) (string, error)
SendPayload send a message with the given payload.
func (*GoShimmerAPI) SendTransaction ¶ added in v0.2.0
func (api *GoShimmerAPI) SendTransaction(txnBytes []byte) (string, error)
SendTransaction sends the transaction(bytes) to the Value Tangle and returns transaction ID.
func (*GoShimmerAPI) SendTransactionByJSON ¶ added in v0.2.2
func (api *GoShimmerAPI) SendTransactionByJSON(txn webapi_value.SendTransactionByJSONRequest) (string, error)
SendTransactionByJSON sends the transaction(JSON) to the Value Tangle and returns transaction ID and message ID.
func (*GoShimmerAPI) ToggleSpammer ¶
func (api *GoShimmerAPI) ToggleSpammer(enable bool, mpm int) (*webapi_spammer.Response, error)
ToggleSpammer toggles the node internal spammer.
func (*GoShimmerAPI) ValueObjects ¶ added in v0.2.4
func (api *GoShimmerAPI) ValueObjects() (*webapi_tools_value.ObjectsResponse, error)
ValueObjects returns the list of value objects.
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.