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{} {
|
||||
info := make(map[string]interface{})
|
||||
if c != nil {
|
||||
now := mclock.Now()
|
||||
info["isConnected"] = true
|
||||
info["connectionTime"] = float64(now-c.connectedAt) / float64(time.Second)
|
||||
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["priority"] = pb != 0
|
||||
} else {
|
||||
info["isConnected"] = false
|
||||
pb := api.server.clientPool.getPosBalance(id)
|
||||
info["pricing/balance"], info["pricing/balanceMeta"] = pb.value, pb.meta
|
||||
info["priority"] = pb.value != 0
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ type clientPeer interface {
|
|||
type clientInfo struct {
|
||||
address string
|
||||
id enode.ID
|
||||
connectedAt mclock.AbsTime
|
||||
capacity uint64
|
||||
priority bool
|
||||
pool *clientPool
|
||||
|
|
@ -241,6 +242,7 @@ func (f *clientPool) connect(peer clientPeer, capacity uint64) bool {
|
|||
address: freeID,
|
||||
queueIndex: -1,
|
||||
id: id,
|
||||
connectedAt: now,
|
||||
priority: posBalance != 0,
|
||||
posFactors: f.defaultPosFactors,
|
||||
negFactors: f.defaultNegFactors,
|
||||
|
|
|
|||
Loading…
Reference in a new issue