Documentation
¶
Index ¶
- Constants
- type CancelSubscription
- type FixedNodeRegistry
- func (f *FixedNodeRegistry) AddNode(node Node)
- func (r *FixedNodeRegistry) GetNode(nodeId uint32) (*Node, error)
- func (r *FixedNodeRegistry) GetNodes() ([]Node, error)
- func (f *FixedNodeRegistry) OnChangedNode(nodeId uint32) (<-chan Node, CancelSubscription)
- func (f *FixedNodeRegistry) OnNewNodes() (<-chan []Node, CancelSubscription)
- type Node
- type NodeRegistry
- type NodesContract
- type SmartContractRegistry
- func (s *SmartContractRegistry) GetNode(nodeId uint32) (*Node, error)
- func (s *SmartContractRegistry) GetNodes() ([]Node, error)
- func (s *SmartContractRegistry) OnChangedNode(nodeId uint32) (<-chan Node, CancelSubscription)
- func (s *SmartContractRegistry) OnNewNodes() (<-chan []Node, CancelSubscription)
- func (s *SmartContractRegistry) SetContractForTest(contract NodesContract)
- func (s *SmartContractRegistry) Start(ctx context.Context) error
Constants ¶
View Source
const (
CONTRACT_CALL_TIMEOUT = 10 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FixedNodeRegistry ¶
type FixedNodeRegistry struct {
// contains filtered or unexported fields
}
TODO: Delete this or move to a test file
func NewFixedNodeRegistry ¶
func NewFixedNodeRegistry(nodes []Node) *FixedNodeRegistry
func (*FixedNodeRegistry) AddNode ¶
func (f *FixedNodeRegistry) AddNode(node Node)
func (*FixedNodeRegistry) GetNode ¶
func (r *FixedNodeRegistry) GetNode(nodeId uint32) (*Node, error)
func (*FixedNodeRegistry) GetNodes ¶
func (r *FixedNodeRegistry) GetNodes() ([]Node, error)
func (*FixedNodeRegistry) OnChangedNode ¶
func (f *FixedNodeRegistry) OnChangedNode( nodeId uint32, ) (<-chan Node, CancelSubscription)
func (*FixedNodeRegistry) OnNewNodes ¶
func (f *FixedNodeRegistry) OnNewNodes() (<-chan []Node, CancelSubscription)
type Node ¶
type NodeRegistry ¶
type NodeRegistry interface {
GetNodes() ([]Node, error)
GetNode(uint32) (*Node, error)
OnNewNodes() (<-chan []Node, CancelSubscription)
OnChangedNode(uint32) (<-chan Node, CancelSubscription)
}
* The NodeRegistry is responsible for fetching the list of nodes from the registry contract and notifying listeners when the list of nodes changes.
type NodesContract ¶
type NodesContract interface {
AllNodes(opts *bind.CallOpts) ([]abis.NodesNodeWithId, error)
}
* A dumbed down interface of abis.NodesCaller for generating mocks
type SmartContractRegistry ¶
type SmartContractRegistry struct {
// contains filtered or unexported fields
}
* The SmartContractRegistry notifies listeners of changes to the nodes by polling the contract and diffing the returned node list with what is currently in memory.
This allows it to operate statelessly and not require a database, with a trade-off for latency.
Given how infrequently this list changes, that trade-off seems acceptable.
func NewSmartContractRegistry ¶
func NewSmartContractRegistry( ethclient bind.ContractCaller, logger *zap.Logger, options config.ContractsOptions, ) (*SmartContractRegistry, error)
func (*SmartContractRegistry) GetNode ¶
func (s *SmartContractRegistry) GetNode(nodeId uint32) (*Node, error)
func (*SmartContractRegistry) GetNodes ¶
func (s *SmartContractRegistry) GetNodes() ([]Node, error)
func (*SmartContractRegistry) OnChangedNode ¶
func (s *SmartContractRegistry) OnChangedNode( nodeId uint32, ) (<-chan Node, CancelSubscription)
func (*SmartContractRegistry) OnNewNodes ¶
func (s *SmartContractRegistry) OnNewNodes() (<-chan []Node, CancelSubscription)
func (*SmartContractRegistry) SetContractForTest ¶
func (s *SmartContractRegistry) SetContractForTest(contract NodesContract)
Click to show internal directories.
Click to hide internal directories.