mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: add new fields to client info
This commit is contained in:
parent
703e67e521
commit
313e17bffc
2 changed files with 8 additions and 1 deletions
|
|
@ -107,14 +107,19 @@ func (api *PrivateLightServerAPI) PriorityClientInfo(start, stop enode.ID, maxCo
|
||||||
func (api *PrivateLightServerAPI) clientInfo(c *clientInfo, id enode.ID) map[string]interface{} {
|
func (api *PrivateLightServerAPI) clientInfo(c *clientInfo, id enode.ID) map[string]interface{} {
|
||||||
info := make(map[string]interface{})
|
info := make(map[string]interface{})
|
||||||
if c != nil {
|
if c != nil {
|
||||||
|
now := mclock.Now()
|
||||||
info["isConnected"] = true
|
info["isConnected"] = true
|
||||||
|
info["connectionTime"] = float64(now-c.connectedAt) / float64(time.Second)
|
||||||
info["capacity"] = c.capacity
|
info["capacity"] = c.capacity
|
||||||
info["pricing/balance"], info["pricing/negBalance"] = c.balanceTracker.getBalance(mclock.Now())
|
pb, nb := c.balanceTracker.getBalance(now)
|
||||||
|
info["pricing/balance"], info["pricing/negBalance"] = pb, nb
|
||||||
info["pricing/balanceMeta"] = c.balanceMetaInfo
|
info["pricing/balanceMeta"] = c.balanceMetaInfo
|
||||||
|
info["priority"] = pb != 0
|
||||||
} else {
|
} else {
|
||||||
info["isConnected"] = false
|
info["isConnected"] = false
|
||||||
pb := api.server.clientPool.getPosBalance(id)
|
pb := api.server.clientPool.getPosBalance(id)
|
||||||
info["pricing/balance"], info["pricing/balanceMeta"] = pb.value, pb.meta
|
info["pricing/balance"], info["pricing/balanceMeta"] = pb.value, pb.meta
|
||||||
|
info["priority"] = pb.value != 0
|
||||||
}
|
}
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ type clientPeer interface {
|
||||||
type clientInfo struct {
|
type clientInfo struct {
|
||||||
address string
|
address string
|
||||||
id enode.ID
|
id enode.ID
|
||||||
|
connectedAt mclock.AbsTime
|
||||||
capacity uint64
|
capacity uint64
|
||||||
priority bool
|
priority bool
|
||||||
pool *clientPool
|
pool *clientPool
|
||||||
|
|
@ -241,6 +242,7 @@ func (f *clientPool) connect(peer clientPeer, capacity uint64) bool {
|
||||||
address: freeID,
|
address: freeID,
|
||||||
queueIndex: -1,
|
queueIndex: -1,
|
||||||
id: id,
|
id: id,
|
||||||
|
connectedAt: now,
|
||||||
priority: posBalance != 0,
|
priority: posBalance != 0,
|
||||||
posFactors: f.defaultPosFactors,
|
posFactors: f.defaultPosFactors,
|
||||||
negFactors: f.defaultNegFactors,
|
negFactors: f.defaultNegFactors,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue