Package pkg/client
Overview
The client
package exposes go APIs to facilitate interactions with the Pocket network.
It includes lower-level interfaces for working with transactions and subscribing to events generally, as well as higher-level interfaces for tracking blocks and broadcasting protocol-specific transactions.
Features
Interface | Description |
---|---|
SupplierClient | A high-level client for use by the "supplier" actor. |
TxClient | A high-level client used to build, sign, and broadcast transaction from cosmos-sdk messages. |
TxContext | Abstracts and encapsulates the transaction building, signing, encoding, and broadcasting concerns. |
BlockClient | Exposes methods for receiving notifications about newly committed blocks. |
DelegationClient | Exposes methods for receiving notifications about new delegation changes from application. |
EventsQueryClient | Encapsulates blockchain event subscriptions. |
Connection | A transport agnostic communication channel for sending and receiving messages. |
Dialer | Abstracts the establishment of connections. |
Architecture Overview
Figure 1: A legend for the component diagrams in this document.
Figure 2: An overview which articulates the dependency relationships between the various client interfaces and their subcompnents.
Figure 3: An overview of how client subcomponents interact with the network.
Installation
go get github.com/pokt-network/poktroll/pkg/client
Usage
Basic Example
// TODO_DOCUMENT: Code example showcasing the use of TxClient or any other primary interface.
Advanced Usage
// TODO_DOCUMENT: Example illustrating advanced features or edge cases of the package.
Configuration
- TxClientOption: Function type that modifies the
TxClient
allowing for flexible and optional configurations. - EventsQueryClientOption: Modifies the
EventsQueryClient
to apply custom behaviors or configurations.
API Reference
For the complete API details, see the godoc.
Best Practices
- Use Abstractions: Instead of directly communicating with blockchain platforms, leverage the provided interfaces for consistent and error-free interactions.
- Stay Updated: With evolving blockchain technologies, ensure to keep the package updated for any new features or security patches.
FAQ
How does the TxClient
interface differ from TxContext
?
While TxClient
is centered around signing and broadcasting transactions, TxContext
consolidates operational dependencies for the transaction lifecycle, like building, encoding, and querying.
Can I extend or customize the provided interfaces?
Yes, the package is designed with modularity in mind. You can either implement the interfaces based on your requirements or extend them for additional functionalities.