Documentation ¶
Index ¶
- Variables
- type AccountResult
- type AccountSubscription
- type BankStats
- type BlockResult
- type BlockSubscribeFilter
- type BlockSubscribeFilterAll
- type BlockSubscribeFilterMentionsAccountOrProgram
- type BlockSubscribeOpts
- type BlockSubscription
- type Client
- func (cl *Client) AccountSubscribe(account solana.PublicKey, commitment rpc.CommitmentType) (*AccountSubscription, error)
- func (cl *Client) AccountSubscribeWithOpts(account solana.PublicKey, commitment rpc.CommitmentType, ...) (*AccountSubscription, error)
- func (cl *Client) BlockSubscribe(filter BlockSubscribeFilter, opts *BlockSubscribeOpts) (*BlockSubscription, error)
- func (c *Client) Close()
- func (cl *Client) LogsSubscribe(filter LogsSubscribeFilterType, commitment rpc.CommitmentType) (*LogSubscription, error)
- func (cl *Client) LogsSubscribeMentions(mentions solana.PublicKey, commitment rpc.CommitmentType) (*LogSubscription, error)
- func (cl *Client) ParsedBlockSubscribe(filter BlockSubscribeFilter, opts *BlockSubscribeOpts) (*ParsedBlockSubscription, error)
- func (cl *Client) ProgramSubscribe(programID solana.PublicKey, commitment rpc.CommitmentType) (*ProgramSubscription, error)
- func (cl *Client) ProgramSubscribeWithOpts(programID solana.PublicKey, commitment rpc.CommitmentType, ...) (*ProgramSubscription, error)
- func (cl *Client) RootSubscribe() (*RootSubscription, error)
- func (cl *Client) SignatureSubscribe(signature solana.Signature, commitment rpc.CommitmentType) (*SignatureSubscription, error)
- func (cl *Client) SlotSubscribe() (*SlotSubscription, error)
- func (cl *Client) SlotsUpdatesSubscribe() (*SlotsUpdatesSubscription, error)
- func (cl *Client) VoteSubscribe() (*VoteSubscription, error)
- type LogResult
- type LogSubscription
- type LogsSubscribeFilterType
- type Options
- type ParsedBlockResult
- type ParsedBlockSubscription
- type ProgramResult
- type ProgramSubscription
- type RootResult
- type RootSubscription
- type SignatureResult
- type SignatureSubscription
- func (sw *SignatureSubscription) Err() <-chan error
- func (sw *SignatureSubscription) Recv(ctx context.Context) (*SignatureResult, error)
- func (sw *SignatureSubscription) RecvWithTimeout(timeout time.Duration) (*SignatureResult, error)
- func (sw *SignatureSubscription) Response() <-chan *SignatureResult
- func (sw *SignatureSubscription) Unsubscribe()
- type SlotResult
- type SlotSubscription
- type SlotsUpdatesResult
- type SlotsUpdatesSubscription
- type SlotsUpdatesType
- type Subscription
- type VoteResult
- type VoteSubscription
Constants ¶
This section is empty.
Variables ¶
var DefaultHandshakeTimeout = 45 * time.Second
var ErrSubscriptionClosed = errors.New("subscription closed")
var ErrTimeout = fmt.Errorf("timeout waiting for confirmation")
Functions ¶
This section is empty.
Types ¶
type AccountResult ¶
type AccountSubscription ¶
type AccountSubscription struct {
// contains filtered or unexported fields
}
func (*AccountSubscription) Err ¶ added in v1.10.0
func (sw *AccountSubscription) Err() <-chan error
func (*AccountSubscription) Recv ¶
func (sw *AccountSubscription) Recv(ctx context.Context) (*AccountResult, error)
func (*AccountSubscription) Response ¶ added in v1.10.0
func (sw *AccountSubscription) Response() <-chan *AccountResult
func (*AccountSubscription) Unsubscribe ¶
func (sw *AccountSubscription) Unsubscribe()
type BlockResult ¶ added in v1.3.0
type BlockResult struct { Context struct { Slot uint64 } `json:"context"` Value struct { Slot uint64 `json:"slot"` Err interface{} `json:"err,omitempty"` Block *rpc.GetBlockResult `json:"block,omitempty"` } `json:"value"` }
type BlockSubscribeFilter ¶ added in v1.3.0
type BlockSubscribeFilter interface {
// contains filtered or unexported methods
}
func NewBlockSubscribeFilterAll ¶ added in v1.3.0
func NewBlockSubscribeFilterAll() BlockSubscribeFilter
type BlockSubscribeFilterAll ¶ added in v1.3.0
type BlockSubscribeFilterAll string
type BlockSubscribeFilterMentionsAccountOrProgram ¶ added in v1.3.0
type BlockSubscribeFilterMentionsAccountOrProgram struct {
Pubkey solana.PublicKey `json:"pubkey"`
}
func NewBlockSubscribeFilterMentionsAccountOrProgram ¶ added in v1.3.0
func NewBlockSubscribeFilterMentionsAccountOrProgram(pubkey solana.PublicKey) *BlockSubscribeFilterMentionsAccountOrProgram
type BlockSubscribeOpts ¶ added in v1.3.0
type BlockSubscribeOpts struct { Commitment rpc.CommitmentType Encoding solana.EncodingType `json:"encoding,omitempty"` // Level of transaction detail to return. TransactionDetails rpc.TransactionDetailsType // Whether to populate the rewards array. If parameter not provided, the default includes rewards. Rewards *bool // Max transaction version to return in responses. // If the requested block contains a transaction with a higher version, an error will be returned. MaxSupportedTransactionVersion *uint64 }
type BlockSubscription ¶ added in v1.3.0
type BlockSubscription struct {
// contains filtered or unexported fields
}
func (*BlockSubscription) Err ¶ added in v1.10.0
func (sw *BlockSubscription) Err() <-chan error
func (*BlockSubscription) Recv ¶ added in v1.3.0
func (sw *BlockSubscription) Recv(ctx context.Context) (*BlockResult, error)
func (*BlockSubscription) Response ¶ added in v1.10.0
func (sw *BlockSubscription) Response() <-chan *BlockResult
func (*BlockSubscription) Unsubscribe ¶ added in v1.3.0
func (sw *BlockSubscription) Unsubscribe()
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func Connect ¶ added in v0.3.3
Connect creates a new websocket client connecting to the provided endpoint.
func ConnectWithOptions ¶ added in v1.5.0
func ConnectWithOptions(ctx context.Context, rpcEndpoint string, opt *Options) (c *Client, err error)
ConnectWithOptions creates a new websocket client connecting to the provided endpoint with a http header if available The http header can be helpful to pass basic authentication params as prescribed ref https://github.com/gorilla/websocket/issues/209
func (*Client) AccountSubscribe ¶
func (cl *Client) AccountSubscribe( account solana.PublicKey, commitment rpc.CommitmentType, ) (*AccountSubscription, error)
AccountSubscribe subscribes to an account to receive notifications when the lamports or data for a given account public key changes.
func (*Client) AccountSubscribeWithOpts ¶
func (cl *Client) AccountSubscribeWithOpts( account solana.PublicKey, commitment rpc.CommitmentType, encoding solana.EncodingType, ) (*AccountSubscription, error)
AccountSubscribe subscribes to an account to receive notifications when the lamports or data for a given account public key changes.
func (*Client) BlockSubscribe ¶ added in v1.3.0
func (cl *Client) BlockSubscribe( filter BlockSubscribeFilter, opts *BlockSubscribeOpts, ) (*BlockSubscription, error)
NOTE: Unstable, disabled by default
Subscribe to receive notification anytime a new block is Confirmed or Finalized.
**This subscription is unstable and only available if the validator was started with the `--rpc-pubsub-enable-block-subscription` flag. The format of this subscription may change in the future**
func (*Client) LogsSubscribe ¶
func (cl *Client) LogsSubscribe( filter LogsSubscribeFilterType, commitment rpc.CommitmentType, ) (*LogSubscription, error)
LogsSubscribe subscribes to transaction logging.
func (*Client) LogsSubscribeMentions ¶
func (cl *Client) LogsSubscribeMentions( mentions solana.PublicKey, commitment rpc.CommitmentType, ) (*LogSubscription, error)
LogsSubscribe subscribes to all transactions that mention the provided Pubkey.
func (*Client) ParsedBlockSubscribe ¶ added in v1.12.0
func (cl *Client) ParsedBlockSubscribe( filter BlockSubscribeFilter, opts *BlockSubscribeOpts, ) (*ParsedBlockSubscription, error)
NOTE: Unstable, disabled by default
Subscribe to receive notification anytime a new block is Confirmed or Finalized.
**This subscription is unstable and only available if the validator was started with the `--rpc-pubsub-enable-block-subscription` flag. The format of this subscription may change in the future**
func (*Client) ProgramSubscribe ¶
func (cl *Client) ProgramSubscribe( programID solana.PublicKey, commitment rpc.CommitmentType, ) (*ProgramSubscription, error)
ProgramSubscribe subscribes to a program to receive notifications when the lamports or data for a given account owned by the program changes.
func (*Client) ProgramSubscribeWithOpts ¶
func (cl *Client) ProgramSubscribeWithOpts( programID solana.PublicKey, commitment rpc.CommitmentType, encoding solana.EncodingType, filters []rpc.RPCFilter, ) (*ProgramSubscription, error)
ProgramSubscribe subscribes to a program to receive notifications when the lamports or data for a given account owned by the program changes.
func (*Client) RootSubscribe ¶
func (cl *Client) RootSubscribe() (*RootSubscription, error)
SignatureSubscribe subscribes to receive notification anytime a new root is set by the validator.
func (*Client) SignatureSubscribe ¶
func (cl *Client) SignatureSubscribe( signature solana.Signature, commitment rpc.CommitmentType, ) (*SignatureSubscription, error)
SignatureSubscribe subscribes to a transaction signature to receive notification when the transaction is confirmed On signatureNotification, the subscription is automatically cancelled
func (*Client) SlotSubscribe ¶
func (cl *Client) SlotSubscribe() (*SlotSubscription, error)
SlotSubscribe subscribes to receive notification anytime a slot is processed by the validator.
func (*Client) SlotsUpdatesSubscribe ¶ added in v0.3.3
func (cl *Client) SlotsUpdatesSubscribe() (*SlotsUpdatesSubscription, error)
SlotsUpdatesSubscribe (UNSTABLE) subscribes to receive a notification from the validator on a variety of updates on every slot.
This subscription is unstable; the format of this subscription may change in the future and it may not always be supported.
func (*Client) VoteSubscribe ¶
func (cl *Client) VoteSubscribe() (*VoteSubscription, error)
VoteSubscribe (UNSTABLE, disabled by default) subscribes to receive notification anytime a new vote is observed in gossip. These votes are pre-consensus therefore there is no guarantee these votes will enter the ledger.
This subscription is unstable and only available if the validator was started with the --rpc-pubsub-enable-vote-subscription flag. The format of this subscription may change in the future.
type LogResult ¶
type LogResult struct { Context struct { Slot uint64 } `json:"context"` Value struct { // The transaction signature. Signature solana.Signature `json:"signature"` // Error if transaction failed, null if transaction succeeded. Err interface{} `json:"err"` // Array of log messages the transaction instructions output // during execution, null if simulation failed before the transaction // was able to execute (for example due to an invalid blockhash // or signature verification failure) Logs []string `json:"logs"` } `json:"value"` }
type LogSubscription ¶
type LogSubscription struct {
// contains filtered or unexported fields
}
func (*LogSubscription) Err ¶ added in v1.10.0
func (sw *LogSubscription) Err() <-chan error
func (*LogSubscription) Recv ¶
func (sw *LogSubscription) Recv(ctx context.Context) (*LogResult, error)
func (*LogSubscription) Response ¶ added in v1.10.0
func (sw *LogSubscription) Response() <-chan *LogResult
func (*LogSubscription) Unsubscribe ¶
func (sw *LogSubscription) Unsubscribe()
type LogsSubscribeFilterType ¶
type LogsSubscribeFilterType string
const ( // Subscribe to all transactions except for simple vote transactions. LogsSubscribeFilterAll LogsSubscribeFilterType = "all" // Subscribe to all transactions including simple vote transactions. LogsSubscribeFilterAllWithVotes LogsSubscribeFilterType = "allWithVotes" )
type ParsedBlockResult ¶ added in v1.12.0
type ParsedBlockResult struct { Context struct { Slot uint64 } `json:"context"` Value struct { Slot uint64 `json:"slot"` Err interface{} `json:"err,omitempty"` Block *rpc.GetParsedBlockResult `json:"block,omitempty"` } `json:"value"` }
type ParsedBlockSubscription ¶ added in v1.12.0
type ParsedBlockSubscription struct {
// contains filtered or unexported fields
}
func (*ParsedBlockSubscription) Err ¶ added in v1.12.0
func (sw *ParsedBlockSubscription) Err() <-chan error
func (*ParsedBlockSubscription) Recv ¶ added in v1.12.0
func (sw *ParsedBlockSubscription) Recv(ctx context.Context) (*ParsedBlockResult, error)
func (*ParsedBlockSubscription) Response ¶ added in v1.12.0
func (sw *ParsedBlockSubscription) Response() <-chan *ParsedBlockResult
func (*ParsedBlockSubscription) Unsubscribe ¶ added in v1.12.0
func (sw *ParsedBlockSubscription) Unsubscribe()
type ProgramResult ¶
type ProgramResult struct { Context struct { Slot uint64 } `json:"context"` Value rpc.KeyedAccount `json:"value"` }
type ProgramSubscription ¶
type ProgramSubscription struct {
// contains filtered or unexported fields
}
func (*ProgramSubscription) Err ¶ added in v1.10.0
func (sw *ProgramSubscription) Err() <-chan error
func (*ProgramSubscription) Recv ¶
func (sw *ProgramSubscription) Recv(ctx context.Context) (*ProgramResult, error)
func (*ProgramSubscription) Response ¶ added in v1.10.0
func (sw *ProgramSubscription) Response() <-chan *ProgramResult
func (*ProgramSubscription) Unsubscribe ¶
func (sw *ProgramSubscription) Unsubscribe()
type RootResult ¶
type RootResult uint64
type RootSubscription ¶
type RootSubscription struct {
// contains filtered or unexported fields
}
func (*RootSubscription) Err ¶ added in v1.10.0
func (sw *RootSubscription) Err() <-chan error
func (*RootSubscription) Recv ¶
func (sw *RootSubscription) Recv(ctx context.Context) (*RootResult, error)
func (*RootSubscription) Response ¶ added in v1.10.0
func (sw *RootSubscription) Response() <-chan *RootResult
func (*RootSubscription) Unsubscribe ¶
func (sw *RootSubscription) Unsubscribe()
type SignatureResult ¶
type SignatureResult struct { Context struct { Slot uint64 } `json:"context"` Value struct { Err interface{} `json:"err"` } `json:"value"` }
type SignatureSubscription ¶
type SignatureSubscription struct {
// contains filtered or unexported fields
}
func (*SignatureSubscription) Err ¶ added in v1.7.0
func (sw *SignatureSubscription) Err() <-chan error
func (*SignatureSubscription) Recv ¶
func (sw *SignatureSubscription) Recv(ctx context.Context) (*SignatureResult, error)
func (*SignatureSubscription) RecvWithTimeout ¶ added in v1.7.0
func (sw *SignatureSubscription) RecvWithTimeout(timeout time.Duration) (*SignatureResult, error)
func (*SignatureSubscription) Response ¶ added in v1.7.0
func (sw *SignatureSubscription) Response() <-chan *SignatureResult
func (*SignatureSubscription) Unsubscribe ¶
func (sw *SignatureSubscription) Unsubscribe()
type SlotResult ¶
type SlotSubscription ¶
type SlotSubscription struct {
// contains filtered or unexported fields
}
func (*SlotSubscription) Err ¶ added in v1.10.0
func (sw *SlotSubscription) Err() <-chan error
func (*SlotSubscription) Recv ¶
func (sw *SlotSubscription) Recv(ctx context.Context) (*SlotResult, error)
func (*SlotSubscription) Response ¶ added in v1.10.0
func (sw *SlotSubscription) Response() <-chan *SlotResult
func (*SlotSubscription) Unsubscribe ¶
func (sw *SlotSubscription) Unsubscribe()
type SlotsUpdatesResult ¶ added in v0.3.3
type SlotsUpdatesResult struct { // The parent slot. Parent uint64 `json:"parent"` // The newly updated slot. Slot uint64 `json:"slot"` // The Unix timestamp of the update. Timestamp *solana.UnixTimeMilliseconds `json:"timestamp"` // The update type. Type SlotsUpdatesType `json:"type"` // Extra stats provided when a bank is frozen. Stats *BankStats `json:"stats"` }
type SlotsUpdatesSubscription ¶ added in v0.3.3
type SlotsUpdatesSubscription struct {
// contains filtered or unexported fields
}
func (*SlotsUpdatesSubscription) Err ¶ added in v1.10.0
func (sw *SlotsUpdatesSubscription) Err() <-chan error
func (*SlotsUpdatesSubscription) Recv ¶ added in v0.3.3
func (sw *SlotsUpdatesSubscription) Recv(ctx context.Context) (*SlotsUpdatesResult, error)
func (*SlotsUpdatesSubscription) Response ¶ added in v1.10.0
func (sw *SlotsUpdatesSubscription) Response() <-chan *SlotsUpdatesResult
func (*SlotsUpdatesSubscription) Unsubscribe ¶ added in v0.3.3
func (sw *SlotsUpdatesSubscription) Unsubscribe()
type SlotsUpdatesType ¶ added in v0.3.3
type SlotsUpdatesType string
const ( SlotsUpdatesFirstShredReceived SlotsUpdatesType = "firstShredReceived" SlotsUpdatesCompleted SlotsUpdatesType = "completed" SlotsUpdatesCreatedBank SlotsUpdatesType = "createdBank" SlotsUpdatesFrozen SlotsUpdatesType = "frozen" SlotsUpdatesDead SlotsUpdatesType = "dead" SlotsUpdatesOptimisticConfirmation SlotsUpdatesType = "optimisticConfirmation" SlotsUpdatesRoot SlotsUpdatesType = "root" )
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe()
type VoteResult ¶
type VoteResult struct { // The vote hash. Hash solana.Hash `json:"hash"` // The slots covered by the vote. Slots []uint64 `json:"slots"` // The timestamp of the vote. Timestamp *solana.UnixTimeSeconds `json:"timestamp,omitempty"` }
type VoteSubscription ¶
type VoteSubscription struct {
// contains filtered or unexported fields
}
func (*VoteSubscription) Err ¶ added in v1.10.0
func (sw *VoteSubscription) Err() <-chan error
func (*VoteSubscription) Recv ¶
func (sw *VoteSubscription) Recv(ctx context.Context) (*VoteResult, error)
func (*VoteSubscription) Response ¶ added in v1.10.0
func (sw *VoteSubscription) Response() <-chan *VoteResult
func (*VoteSubscription) Unsubscribe ¶
func (sw *VoteSubscription) Unsubscribe()