handle correctly the case with no active channels
This commit is contained in:
parent
10fb35b47f
commit
7306df3445
1 changed files with 16 additions and 7 deletions
|
|
@ -68,13 +68,22 @@ class ChannelStats(BaseModel):
|
||||||
if channel.state == ChannelState.ACTIVE
|
if channel.state == ChannelState.ACTIVE
|
||||||
]
|
]
|
||||||
|
|
||||||
return cls(
|
if len(active_channel_sizes) > 0:
|
||||||
counts=counts,
|
return cls(
|
||||||
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
counts=counts,
|
||||||
biggest_size=max(active_channel_sizes),
|
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
||||||
smallest_size=min(active_channel_sizes),
|
biggest_size=max(active_channel_sizes),
|
||||||
total_capacity=sum(active_channel_sizes),
|
smallest_size=min(active_channel_sizes),
|
||||||
)
|
total_capacity=sum(active_channel_sizes),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return cls(
|
||||||
|
counts=counts,
|
||||||
|
avg_size=0,
|
||||||
|
biggest_size=0,
|
||||||
|
smallest_size=0,
|
||||||
|
total_capacity=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NodeFees(BaseModel):
|
class NodeFees(BaseModel):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue