Documentation
¶
Index ¶
- Constants
- func ExecuteTransaction(ctx context.Context, signer TransactionSigner, logger *zap.Logger, ...) error
- func NewClient(ctx context.Context, wsUrl string) (*ethclient.Client, error)
- func NewNodeRegistryAdmin(logger *zap.Logger, client *ethclient.Client, signer TransactionSigner, ...) (*nodeRegistryAdmin, error)
- func WaitForTransaction(ctx context.Context, logger *zap.Logger, client *ethclient.Client, ...) (*types.Receipt, error)
- type BlockchainPublisher
- func (m *BlockchainPublisher) Close()
- func (m *BlockchainPublisher) PublishGroupMessage(ctx context.Context, groupID [32]byte, message []byte) (*gm.GroupMessageBroadcasterMessageSent, error)
- func (m *BlockchainPublisher) PublishIdentityUpdate(ctx context.Context, inboxId [32]byte, identityUpdate []byte) (*iu.IdentityUpdateBroadcasterIdentityUpdateCreated, error)
- type ChainClient
- type IBlockchainPublisher
- type INodeRegistryAdmin
- type INodeRegistryCaller
- type LogStreamBuilder
- type LogStreamer
- type NonceContext
- type NonceManager
- type OpenConnectionsLimiter
- type PrivateKeySigner
- type RatesAdmin
- type SQLBackedNonceManager
- type TransactionSigner
Constants ¶
const ( MaxConcurrentRequests = 64 BestGuessConcurrency = 32 )
MaxConcurrentRequests the blockchain mempool can usually only hold 64 transactions from the same fromAddress
const ( RATE_REGISTRY_MESSAGE_FEE_KEY = "xmtp.rateRegistry.messageFee" RATE_REGISTRY_STORAGE_FEE_KEY = "xmtp.rateRegistry.storageFee" RATE_REGISTRY_CONGESTION_FEE_KEY = "xmtp.rateRegistry.congestionFee" RATE_REGISTRY_TARGET_RATE_PER_MINUTE_KEY = "xmtp.rateRegistry.targetRatePerMinute" )
const (
NODE_REGISTRY_MAX_CANONICAL_NODES_KEY = "xmtp.nodeRegistry.maxCanonicalNodes"
)
Variables ¶
This section is empty.
Functions ¶
func ExecuteTransaction ¶ added in v0.3.0
func ExecuteTransaction( ctx context.Context, signer TransactionSigner, logger *zap.Logger, client *ethclient.Client, txFunc func(*bind.TransactOpts) (*types.Transaction, error), eventParser func(*types.Log) (interface{}, error), logHandler func(interface{}), ) error
ExecuteTransaction is a helper function that: - estimates the gas required for the transaction - checks if the sender has enough balance to cover the gas cost - executes a transaction - waits for it to be mined - processes the event logs
func NewNodeRegistryAdmin ¶
func NewNodeRegistryAdmin( logger *zap.Logger, client *ethclient.Client, signer TransactionSigner, contractsOptions config.ContractsOptions, ) (*nodeRegistryAdmin, error)
func WaitForTransaction ¶
func WaitForTransaction( ctx context.Context, logger *zap.Logger, client *ethclient.Client, timeout time.Duration, pollSleep time.Duration, hash common.Hash, ) (*types.Receipt, error)
Waits for the given transaction hash to have been submitted to the chain and soft confirmed
Types ¶
type BlockchainPublisher ¶
type BlockchainPublisher struct {
// contains filtered or unexported fields
}
Can publish to the blockchain, signing messages using the provided signer
func NewBlockchainPublisher ¶
func NewBlockchainPublisher( ctx context.Context, logger *zap.Logger, client *ethclient.Client, signer TransactionSigner, contractOptions config.ContractsOptions, nonceManager NonceManager, ) (*BlockchainPublisher, error)
func (*BlockchainPublisher) Close ¶ added in v0.3.0
func (m *BlockchainPublisher) Close()
func (*BlockchainPublisher) PublishGroupMessage ¶
func (m *BlockchainPublisher) PublishGroupMessage( ctx context.Context, groupID [32]byte, message []byte, ) (*gm.GroupMessageBroadcasterMessageSent, error)
func (*BlockchainPublisher) PublishIdentityUpdate ¶
func (m *BlockchainPublisher) PublishIdentityUpdate( ctx context.Context, inboxId [32]byte, identityUpdate []byte, ) (*iu.IdentityUpdateBroadcasterIdentityUpdateCreated, error)
type ChainClient ¶
type ChainClient interface {
ethereum.BlockNumberReader
ethereum.LogFilterer
ethereum.ChainIDReader
ethereum.ChainReader
}
type IBlockchainPublisher ¶
type IBlockchainPublisher interface {
PublishIdentityUpdate(
ctx context.Context,
inboxId [32]byte,
identityUpdate []byte,
) (*iu.IdentityUpdateBroadcasterIdentityUpdateCreated, error)
PublishGroupMessage(
ctx context.Context,
groupdId [32]byte,
message []byte,
) (*gm.GroupMessageBroadcasterMessageSent, error)
}
type INodeRegistryAdmin ¶ added in v0.3.0
type INodeRegistryAdmin interface {
AddNode(
ctx context.Context,
owner string,
signingKeyPub *ecdsa.PublicKey,
httpAddress string,
) (uint32, error)
AddToNetwork(ctx context.Context, nodeId uint32) error
RemoveFromNetwork(ctx context.Context, nodeId uint32) error
SetHttpAddress(ctx context.Context, nodeId uint32, httpAddress string) error
SetMaxCanonical(ctx context.Context, limit uint8) error
}
type INodeRegistryCaller ¶ added in v0.3.0
type INodeRegistryCaller interface {
GetAllNodes(ctx context.Context) ([]noderegistry.INodeRegistryNodeWithId, error)
GetNode(ctx context.Context, nodeId uint32) (noderegistry.INodeRegistryNode, error)
OwnerOf(ctx context.Context, nodeId uint32) (common.Address, error)
GetMaxCanonicalNodes(
ctx context.Context,
) (uint8, error)
}
func NewNodeRegistryCaller ¶
func NewNodeRegistryCaller( logger *zap.Logger, client *ethclient.Client, contractsOptions config.ContractsOptions, ) (INodeRegistryCaller, error)
type LogStreamBuilder ¶
type LogStreamBuilder interface {
ListenForContractEvent(
fromBlock uint64,
contractAddress common.Address,
topic common.Hash,
) <-chan types.Log
Build() (LogStreamer, error)
}
Construct a raw blockchain listener that can be used to listen for events across many contract event types
type LogStreamer ¶
type NonceContext ¶ added in v0.3.0
type NonceManager ¶ added in v0.3.0
type OpenConnectionsLimiter ¶ added in v0.3.0
type OpenConnectionsLimiter struct {
// contains filtered or unexported fields
}
OpenConnectionsLimiter controls the number of concurrent requests
func NewOpenConnectionsLimiter ¶ added in v0.3.0
func NewOpenConnectionsLimiter(maxConcurrent int) *OpenConnectionsLimiter
NewOpenConnectionsLimiter initializes a OpenConnectionsLimiter with a limit
type PrivateKeySigner ¶
type PrivateKeySigner struct {
// contains filtered or unexported fields
}
* PrivateKeySigner is a naive and not secure implementation of the TransactionSigner interface.
It is meant to be used in tests only *
func NewPrivateKeySigner ¶
func NewPrivateKeySigner(privateKeyString string, chainID int) (*PrivateKeySigner, error)
func (*PrivateKeySigner) FromAddress ¶
func (s *PrivateKeySigner) FromAddress() common.Address
func (*PrivateKeySigner) SignerFunc ¶
func (s *PrivateKeySigner) SignerFunc() bind.SignerFn
type RatesAdmin ¶ added in v0.3.0
type RatesAdmin struct {
// contains filtered or unexported fields
}
* A RatesAdmin is a struct responsible for calling admin functions on the RatesRegistry contract *
func NewRatesAdmin ¶ added in v0.3.0
func NewRatesAdmin( logger *zap.Logger, client *ethclient.Client, signer TransactionSigner, contractsOptions config.ContractsOptions, ) (*RatesAdmin, error)
type SQLBackedNonceManager ¶ added in v0.3.0
type SQLBackedNonceManager struct {
// contains filtered or unexported fields
}
func NewSQLBackedNonceManager ¶ added in v0.3.0
func NewSQLBackedNonceManager(db *sql.DB, logger *zap.Logger) *SQLBackedNonceManager
func (*SQLBackedNonceManager) FastForwardNonce ¶ added in v0.3.0
func (*SQLBackedNonceManager) GetNonce ¶ added in v0.3.0
func (s *SQLBackedNonceManager) GetNonce(ctx context.Context) (*NonceContext, error)