Documentation ¶
Index ¶
- func SetLogger(w io.Writer)
- type ClientRequest
- type ClientResponse
- type HostRequest
- type HostResponse
- type NoHostNodesError
- type Pool
- type RemoteHostErrors
- type RemotePool
- func (p *RemotePool) Client(ctx context.Context, req ClientRequest) (*ClientResponse, error)
- func (p *RemotePool) Disconnect(ctx context.Context) error
- func (p *RemotePool) Host(ctx context.Context, req HostRequest) (*HostResponse, error)
- func (p *RemotePool) Update(ctx context.Context, req UpdateRequest) (*UpdateResponse, error)
- func (p *RemotePool) Withdraw(ctx context.Context) error
- type StaticPool
- func (s *StaticPool) AddNode(nodeURI string) error
- func (s *StaticPool) Client(ctx context.Context, req ClientRequest) (*ClientResponse, error)
- func (s *StaticPool) Disconnect(ctx context.Context) error
- func (s *StaticPool) Host(ctx context.Context, req HostRequest) (*HostResponse, error)
- func (s *StaticPool) Update(ctx context.Context, req UpdateRequest) (*UpdateResponse, error)
- func (s *StaticPool) Withdraw(ctx context.Context) error
- type UpdateRequest
- type UpdateResponse
- type VerifyFailedError
- type VipnodePool
- func (p *VipnodePool) Client(ctx context.Context, sig string, nodeID string, nonce int64, req ClientRequest) (*ClientResponse, error)
- func (p *VipnodePool) Host(ctx context.Context, sig string, nodeID string, nonce int64, req HostRequest) (*HostResponse, error)
- func (p *VipnodePool) Ping(ctx context.Context) string
- func (p *VipnodePool) Update(ctx context.Context, sig string, nodeID string, nonce int64, req UpdateRequest) (*UpdateResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientRequest ¶ added in v0.2.2
type ClientRequest struct {
Kind string `json:"kind"`
}
ClientRequest is the request type for Client RPC calls.
type ClientResponse ¶ added in v0.2.2
type ClientResponse struct { // Hosts that have whitelisted the client NodeID and are ready for the // client to connect. Hosts []store.Node `json:"hosts"` // PoolVersion is the version of vipnode-pool that is running. PoolVersion string `json:"pool_version"` // Message contains a prompt for the client from the pool, possibly // instructions for interfacing with this pool. For example, a link to the // DApp for adding a balance deposit. Message string `json:"message,omitempty"` }
ClientResponse is the response type for Client RPC calls.
type HostRequest ¶ added in v0.2.2
type HostRequest struct { // Kind is the type of node the host supports: geth, parity Kind string `json:"kind"` // Payout sets the wallet account to register the host credit towards. Payout string `json:"payout"` // Optional public node URI override, useful if the vipnode agent runs on a // separate IP from the actual node host. Otherwise, the pool will // automatically use the same IP and default port as the host connecting. NodeURI string `json:"node_uri,omitempty"` }
HostRequest is the request type for Host RPC calls.
type HostResponse ¶ added in v0.2.2
type HostResponse struct {
PoolVersion string `json:"pool_version"`
}
HostResponse is the response type for Host RPC calls.
type NoHostNodesError ¶ added in v0.2.5
type NoHostNodesError struct {
NumTried int
}
NoHostNodesError is returned when the pool does not have any hosts available.
func (NoHostNodesError) Error ¶ added in v0.2.5
func (err NoHostNodesError) Error() string
type Pool ¶
type Pool interface { // Host subscribes a host to receive vipnode_whitelist instructions. Host(ctx context.Context, req HostRequest) (*HostResponse, error) // Client requests for available hosts to connect to as a client. Client(ctx context.Context, req ClientRequest) (*ClientResponse, error) // Disconnect stops tracking the connection and billing, will prompt a // disconnect from both ends. Disconnect(ctx context.Context) error // Update is a keep-alive for sharing the node's peering info. It returns // a list of peers that are no longer corroborated by the pool, and current // balance for the node (if relevant). Update(ctx context.Context, req UpdateRequest) (*UpdateResponse, error) // Withdraw prompts a request to settle the node's balance. Withdraw(ctx context.Context) error }
Pool represents a vipnode pool for coordinating between clients and hosts.
type RemoteHostErrors ¶ added in v0.2.5
RemoteHostErrors is used when a subset of RPC calls to hosts fail.
func (RemoteHostErrors) Error ¶ added in v0.2.5
func (err RemoteHostErrors) Error() string
type RemotePool ¶
type RemotePool struct {
// contains filtered or unexported fields
}
RemotePool wraps a Pool with an RPC service and handles all the signging.
func Remote ¶
func Remote(client jsonrpc2.Service, privkey *ecdsa.PrivateKey) *RemotePool
Remote returns a RemotePool abstraction which proxies an RPC pool client but takes care of all the request signing.
func (*RemotePool) Client ¶ added in v0.2.2
func (p *RemotePool) Client(ctx context.Context, req ClientRequest) (*ClientResponse, error)
func (*RemotePool) Disconnect ¶
func (p *RemotePool) Disconnect(ctx context.Context) error
func (*RemotePool) Host ¶
func (p *RemotePool) Host(ctx context.Context, req HostRequest) (*HostResponse, error)
func (*RemotePool) Update ¶
func (p *RemotePool) Update(ctx context.Context, req UpdateRequest) (*UpdateResponse, error)
type StaticPool ¶
StaticPool is a dummy implementation of a pool service that always returns from the same set of host nodes. It does not do any signature checking.
func (*StaticPool) AddNode ¶
func (s *StaticPool) AddNode(nodeURI string) error
func (*StaticPool) Client ¶ added in v0.2.2
func (s *StaticPool) Client(ctx context.Context, req ClientRequest) (*ClientResponse, error)
func (*StaticPool) Disconnect ¶
func (s *StaticPool) Disconnect(ctx context.Context) error
func (*StaticPool) Host ¶
func (s *StaticPool) Host(ctx context.Context, req HostRequest) (*HostResponse, error)
func (*StaticPool) Update ¶
func (s *StaticPool) Update(ctx context.Context, req UpdateRequest) (*UpdateResponse, error)
type UpdateRequest ¶ added in v0.2.2
type UpdateRequest struct { Peers []string `json:"peers"` BlockNumber uint64 `json:"block_number"` }
UpdateRequest is the request type for Update RPC calls.
type UpdateResponse ¶
type UpdateResponse struct { Balance *store.Balance `json:"balance,omitempty"` InvalidPeers []string `json:"invalid_peers"` }
UpdateResponse is the response type for Update RPC calls.
type VerifyFailedError ¶ added in v0.2.5
VerifyFailedError is returned when a signature fails to verify. It embeds the underlying Cause.
func (VerifyFailedError) Error ¶ added in v0.2.5
func (err VerifyFailedError) Error() string
type VipnodePool ¶
type VipnodePool struct { // Version is returned as the PoolVersion in the ClientResponse when a new client connects. Version string Store store.Store BalanceManager balance.Manager ClientMessager func(nodeID string) string // contains filtered or unexported fields }
VipnodePool implements a Pool service with balance tracking.
func New ¶
func New(storeDriver store.Store, manager balance.Manager) *VipnodePool
New returns a new VipnodePool RPC service with the given storage driver and balance manager. If manager is nil, then balance.NoBalance{} is used.
func (*VipnodePool) Client ¶ added in v0.2.2
func (p *VipnodePool) Client(ctx context.Context, sig string, nodeID string, nonce int64, req ClientRequest) (*ClientResponse, error)
Client returns a list of enodes who are ready for the client node to connect.
func (*VipnodePool) Host ¶
func (p *VipnodePool) Host(ctx context.Context, sig string, nodeID string, nonce int64, req HostRequest) (*HostResponse, error)
Host registers a full node to participate as a vipnode host in this pool.
func (*VipnodePool) Ping ¶
func (p *VipnodePool) Ping(ctx context.Context) string
Ping returns "pong", used for testing.
func (*VipnodePool) Update ¶
func (p *VipnodePool) Update(ctx context.Context, sig string, nodeID string, nonce int64, req UpdateRequest) (*UpdateResponse, error)
Update submits a list of peers that the node is connected to, returning the current account balance.