Skip to content

Instantly share code, notes, and snippets.

@zsfelfoldi
Last active February 14, 2019 12:04
Show Gist options
  • Save zsfelfoldi/917ea527613cf570766fb5ae0724335c to your computer and use it in GitHub Desktop.
Save zsfelfoldi/917ea527613cf570766fb5ae0724335c to your computer and use it in GitHub Desktop.
### New LES server API calls implemented in https://github.com/ethereum/go-ethereum/pull/18230
// TotalCapacity queries total available capacity for all clients
func (api *PrivateLightServerAPI) TotalCapacity() hexutil.Uint64
// SubscribeTotalCapacity subscribes to changed total capacity events.
// If onlyUnderrun is true thenhttps://github.com/ethereum/go-ethereum/pull/18230 notification is sent only if the total capacity
// drops under the total capacity of connected priority clients.
//
// Note: actually applying decreasing total capacity values is delayed while the
// notification is sent instantly. This allows lowering the capacity of a priority client
// or choosing which one to drop before the system drops some of them automatically.
func (api *PrivateLightServerAPI) SubscribeTotalCapacity(ctx context.Context, onlyUnderrun bool) (*rpc.Subscription, error)
// MinimumCapacity queries minimum assignable capacity for a single client
func (api *PrivateLightServerAPI) MinimumCapacity() hexutil.Uint64
// FreeClientCapacity queries the capacity provided for free clients
func (api *PrivateLightServerAPI) FreeClientCapacity() hexutil.Uint64
// SetClientCapacity sets the priority capacity assigned to a given client.
// If the assigned capacity is bigger than zero then connection is always
// guaranteed. The sum of capacity assigned to priority clients can not exceed
// the total available capacity.
//
// Note: assigned capacity can be changed while the client is connected with
// immediate effect.
func (api *PrivateLightServerAPI) SetClientCapacity(id enode.ID, cap uint64) error
// GetClientCapacity returns the capacity assigned to a given client
func (api *PrivateLightServerAPI) GetClientCapacity(id enode.ID) hexutil.Uint64
// Benchmark runs a request performance benchmark with a given set of measurement setups
// in multiple passes specified by passCount. The measurement time for each setup in each
// pass is specified in milliseconds by length.
//
// Note: measurement time is adjusted for each pass depending on the previous ones.
// Therefore a controlled total measurement time is achievable in multiple passes.
func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error)
### Additional planned API calls
// GetClientUsage returns the total "real cost" of requests served for the given client since the server has been started up
//
// Note: since the server only keeps a permanent entry for priority nodes the usage statistics of non-priority nodes are reset
// to zero after the connection has been ended
func (api *PrivateLightServerAPI) GetClientUsage(id enode.ID) hexutil.Uint64
// SubscribeClientUsage subscribes to events related to client service usage. A new event is generated when a client is connected,
// disconnected and every time they accumulate a certain amount of request serving cost.
func (api *PrivateLightServerAPI) SubscribeClientUsage(ctx context.Context, reportCost uint64, priorityOnly bool) (*rpc.Subscription, error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment