Documentation
¶
Index ¶
- Constants
- func NewClient(ctx context.Context, rpcUrl string) (*ethclient.Client, error)
- func WaitForTransaction(ctx context.Context, logger *zap.Logger, client *ethclient.Client, ...) (*types.Receipt, error)
- type BlockchainPublisher
- func (m *BlockchainPublisher) PublishGroupMessage(ctx context.Context, groupID [32]byte, message []byte) (*groupmessages.GroupMessagesMessageSent, error)
- func (m *BlockchainPublisher) PublishIdentityUpdate(ctx context.Context, inboxId [32]byte, identityUpdate []byte) (*identityupdates.IdentityUpdatesIdentityUpdateCreated, error)
- type ChainClient
- type ContractConfig
- type IBlockchainPublisher
- type LogStreamBuilder
- type LogStreamer
- type NodeRegistry
- type NodeRegistryAdmin
- func (n *NodeRegistryAdmin) AddNode(ctx context.Context, owner string, signingKeyPub *ecdsa.PublicKey, ...) error
- func (n *NodeRegistryAdmin) UpdateHealth(ctx context.Context, nodeId int64, health bool) error
- func (n *NodeRegistryAdmin) UpdateHttpAddress(ctx context.Context, nodeId int64, address string) error
- type NodeRegistryCaller
- type PrivateKeySigner
- type RpcLogStreamBuilder
- type RpcLogStreamer
- type TransactionSigner
Constants ¶
const ( BACKFILL_BLOCKS = uint64(1000) // Don't index very new blocks to account for reorgs // Setting to 0 since we are talking about L2s with low reorg risk LAG_FROM_HIGHEST_BLOCK = uint64(0) ERROR_SLEEP_TIME = 100 * time.Millisecond NO_LOGS_SLEEP_TIME = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
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, ) (*BlockchainPublisher, error)
func (*BlockchainPublisher) PublishGroupMessage ¶
func (m *BlockchainPublisher) PublishGroupMessage( ctx context.Context, groupID [32]byte, message []byte, ) (*groupmessages.GroupMessagesMessageSent, error)
func (*BlockchainPublisher) PublishIdentityUpdate ¶
func (m *BlockchainPublisher) PublishIdentityUpdate( ctx context.Context, inboxId [32]byte, identityUpdate []byte, ) (*identityupdates.IdentityUpdatesIdentityUpdateCreated, error)
type ChainClient ¶
type ChainClient interface {
ethereum.BlockNumberReader
ethereum.LogFilterer
ethereum.ChainIDReader
ethereum.ChainReader
}
type ContractConfig ¶ added in v0.2.2
type ContractConfig struct {
FromBlock uint64
ContractAddress common.Address
Topics []common.Hash
EventChannel chan<- types.Log
// contains filtered or unexported fields
}
Struct defining all the information required to filter events from logs
type IBlockchainPublisher ¶
type IBlockchainPublisher interface {
PublishIdentityUpdate(
ctx context.Context,
inboxId [32]byte,
identityUpdate []byte,
) (*identityupdates.IdentityUpdatesIdentityUpdateCreated, error)
PublishGroupMessage(
ctx context.Context,
groupdId [32]byte,
message []byte,
) (*groupmessages.GroupMessagesMessageSent, 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 NodeRegistry ¶
type NodeRegistryAdmin ¶
type NodeRegistryAdmin struct {
// contains filtered or unexported fields
}
* A NodeRegistryAdmin is a struct responsible for calling admin functions on the node registry *
func NewNodeRegistryAdmin ¶
func NewNodeRegistryAdmin( logger *zap.Logger, client *ethclient.Client, signer TransactionSigner, contractsOptions config.ContractsOptions, ) (*NodeRegistryAdmin, error)
func (*NodeRegistryAdmin) UpdateHealth ¶
func (*NodeRegistryAdmin) UpdateHttpAddress ¶
type NodeRegistryCaller ¶
type NodeRegistryCaller struct {
// contains filtered or unexported fields
}
* A NodeRegistryCaller is a struct responsible for calling public functions on the node registry *
func NewNodeRegistryCaller ¶
func NewNodeRegistryCaller( logger *zap.Logger, client *ethclient.Client, contractsOptions config.ContractsOptions, ) (*NodeRegistryCaller, error)
func (*NodeRegistryCaller) GetAllNodes ¶
func (n *NodeRegistryCaller) GetAllNodes( ctx context.Context, ) ([]nodes.NodesNodeWithId, error)
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 RpcLogStreamBuilder ¶
type RpcLogStreamBuilder struct {
// contains filtered or unexported fields
}
The builder that allows you to configure contract events to listen for
func NewRpcLogStreamBuilder ¶
func (*RpcLogStreamBuilder) Build ¶
func (c *RpcLogStreamBuilder) Build() (*RpcLogStreamer, error)
type RpcLogStreamer ¶
type RpcLogStreamer struct {
// contains filtered or unexported fields
}
* A RpcLogStreamer is a naive implementation of the ChainStreamer interface. It queries a remote blockchain node for log events to backfill history, and then streams new events, to get a complete history of events on a chain. *
func NewRpcLogStreamer ¶
func NewRpcLogStreamer( ctx context.Context, client ChainClient, logger *zap.Logger, watchers []ContractConfig, ) *RpcLogStreamer
func (*RpcLogStreamer) Client ¶ added in v0.2.0
func (r *RpcLogStreamer) Client() ChainClient
func (*RpcLogStreamer) GetNextPage ¶ added in v0.2.2
func (r *RpcLogStreamer) GetNextPage( config ContractConfig, fromBlock uint64, ) (logs []types.Log, nextBlock *uint64, err error)
func (*RpcLogStreamer) Start ¶
func (r *RpcLogStreamer) Start()
func (*RpcLogStreamer) Stop ¶ added in v0.1.1
func (r *RpcLogStreamer) Stop()