Documentation ¶
Index ¶
- Variables
- type Cluster
- type Config
- type Node
- func (n *Node) GetBlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (n *Node) GetNodes(ctx context.Context, hash common.Hash, number uint16, cutoff []common.Hash) ([][]byte, error)
- func (n *Node) GetReceiptsByHash(ctx context.Context, hash common.Hash) (types.Receipts, error)
- func (n *Node) GetTile(ctx context.Context, hash common.Hash) ([][]byte, error)
- func (n *Node) HasBlock(hash common.Hash) bool
- func (n *Node) HasState(root common.Hash) bool
- func (n *Node) ID() string
- func (n *Node) Logger() log.Logger
- func (n *Node) SubscribeNewHead(sink chan *types.Header) event.Subscription
- type NodeConfig
- type NodeSet
- func (set *NodeSet) AddNode(id string, n *Node) error
- func (set *NodeSet) ForEach(callback func(id string, node *Node) bool)
- func (set *NodeSet) HasBlock(hash common.Hash) []*Node
- func (set *NodeSet) HasState(root common.Hash) []*Node
- func (set *NodeSet) Len() int
- func (set *NodeSet) Node(id string) *Node
- func (set *NodeSet) Random() *Node
- func (set *NodeSet) RemoveNode(id string) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster represents the whole infrastructure for ethflare. It's responsible for following things.
- Create tile indexes The whole ethereum state will be cut into several chunks referenced together with each other. Each chunk is called "tile". Since each Geth node can have totally different state(out of sync, synced, fresh new), so cluster will maintain a global tile indexes based on all underlying Geth nodes. The indexes(metadata) can be used for validating the tile request and for request distribution.
- Serve actual requests All requests received in the httpserver will be processed here including chain requests and state requests.
func NewCluster ¶
NewCluster returns a cluster instance
func (*Cluster) ServeRequest ¶
func (c *Cluster) ServeRequest(ctx context.Context, method string, args ...interface{}) (interface{}, error)
ServeRequest performs the request serving with given arguments.
type Config ¶
type Config struct { // Datadir the file path points to the database. If the value is empty, // an in-memory temporary database is applied. Datadir string // HTTPHost is the host interface on which to start the HTTP RPC server. If this // field is empty, no HTTP API endpoint will be started. HTTPHost string `toml:",omitempty"` // HTTPPort is the TCP port number on which to start the HTTP RPC server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). HTTPPort int `toml:",omitempty"` // Nodes is a list of node config(web socket endpoint). Nodes []NodeConfig // Log the logger for system, nil means default logger. Log log.Logger `toml:"-"` }
func (Config) MarshalTOML ¶
MarshalTOML marshals as TOML.
func (*Config) UnmarshalTOML ¶
UnmarshalTOML unmarshals from TOML.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents an Ethereum node with the ethflare RPC API implemented and exposed via WebSockets (we need notification support for new heads).
The necessary ethflare APIs includes:
- cdn_tile
- cdn_nodes
- cdn_receipts
func NewNode ¶
NewNode takes a live websocket connection to a Node and starts to monitor its chain progression and optionally request chain and state data.
func (*Node) GetBlockByHash ¶
GetBlockByHash sends a RPC request for retrieving specified block with given hash.
func (*Node) GetNodes ¶
func (n *Node) GetNodes(ctx context.Context, hash common.Hash, number uint16, cutoff []common.Hash) ([][]byte, error)
GetNodes sends a RPC request for retrieving specified nodes with with given node hash list.
func (*Node) GetReceiptsByHash ¶
GetReceiptsByHash sends a RPC request for retrieving specified receipts with given block hash.
func (*Node) GetTile ¶
GetTile sends a RPC request for retrieving specified tile with given root hash.
func (*Node) HasBlock ¶
HasBlock checks whether a block is available from this Node. If the block is too old, return false also.
func (*Node) HasState ¶
HasState checks whether a state is available from this Node. If the state is too old, then regard it as unavailable.
func (*Node) SubscribeNewHead ¶
func (n *Node) SubscribeNewHead(sink chan *types.Header) event.Subscription
SubscribeNewHead subscribes to new chain head events to act as triggers for the task tiler.
type NodeConfig ¶
type NodeConfig struct { ID string // The unique identity of node Endpoint string // The RPC endpoint which enables the websocket RateLimit uint64 // The rate limit for sending requests to the node }
NodeConfig includes all settings of node.
type NodeSet ¶
type NodeSet struct {
// contains filtered or unexported fields
}
NodeSet is a set of connected nodes
func NewNodeSet ¶
func NewNodeSet() *NodeSet
func (*NodeSet) ForEach ¶
ForEach iterates the whole Node set and applies callback on each of them. Stop iteration when the callback returns false.
func (*NodeSet) RemoveNode ¶
RemoveNode removes the node from set, return error if it's non-existent.