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,6 +68,7 @@ class ChannelStats(BaseModel):
|
|||
if channel.state == ChannelState.ACTIVE
|
||||
]
|
||||
|
||||
if len(active_channel_sizes) > 0:
|
||||
return cls(
|
||||
counts=counts,
|
||||
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
||||
|
|
@ -75,6 +76,14 @@ class ChannelStats(BaseModel):
|
|||
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue