rpcserver: return total num of fwdPkgs in PendingChannels
This commit adds a new field, NumForwardingPackages, in the PendingChannels RPC response to specify how many forwarding packages the channel has.
This commit is contained in:
4 files changed
+1681
-1641
No files matched your search
+1644
-1632
File diff suppressed because it is too large.
Load diff
@@ -2236,6 +2236,9 @@ message PendingChannelsResponse {
|
|||||||
|
|
||||||
// The commitment type used by this channel.
|
// The commitment type used by this channel.
|
||||||
CommitmentType commitment_type = 9;
|
CommitmentType commitment_type = 9;
|
||||||
|
|
||||||
|
// Total number of forwarding packages created in this channel.
|
||||||
|
int64 num_forwarding_packages = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PendingOpenChannel {
|
message PendingOpenChannel {
|
||||||
|
|||||||
@@ -2698,6 +2698,11 @@
|
|||||||
"commitment_type": {
|
"commitment_type": {
|
||||||
"$ref": "#/definitions/lnrpcCommitmentType",
|
"$ref": "#/definitions/lnrpcCommitmentType",
|
||||||
"description": "The commitment type used by this channel."
|
"description": "The commitment type used by this channel."
|
||||||
|
},
|
||||||
|
"num_forwarding_packages": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Total number of forwarding packages created in this channel."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+29
-9
@@ -3239,6 +3239,17 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the number of forwarding packages from the historical
|
||||||
|
// channel.
|
||||||
|
fwdPkgs, err := historical.LoadFwdPkgs()
|
||||||
|
if err != nil {
|
||||||
|
rpcsLog.Errorf("unable to load forwarding packages "+
|
||||||
|
"for channel:%s, %v",
|
||||||
|
historical.ShortChannelID, err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
channel.NumForwardingPackages = int64(len(fwdPkgs))
|
||||||
|
|
||||||
closeTXID := pendingClose.ClosingTXID.String()
|
closeTXID := pendingClose.ClosingTXID.String()
|
||||||
|
|
||||||
switch pendingClose.CloseType {
|
switch pendingClose.CloseType {
|
||||||
@@ -3350,16 +3361,25 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fwdPkgs, err := waitingClose.LoadFwdPkgs()
|
||||||
|
if err != nil {
|
||||||
|
rpcsLog.Errorf("unable to load forwarding packages "+
|
||||||
|
"for channel:%s, %v",
|
||||||
|
waitingClose.ShortChannelID, err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
channel := &lnrpc.PendingChannelsResponse_PendingChannel{
|
channel := &lnrpc.PendingChannelsResponse_PendingChannel{
|
||||||
RemoteNodePub: hex.EncodeToString(pub),
|
RemoteNodePub: hex.EncodeToString(pub),
|
||||||
ChannelPoint: chanPoint.String(),
|
ChannelPoint: chanPoint.String(),
|
||||||
Capacity: int64(waitingClose.Capacity),
|
Capacity: int64(waitingClose.Capacity),
|
||||||
LocalBalance: int64(waitingClose.LocalCommitment.LocalBalance.ToSatoshis()),
|
LocalBalance: int64(waitingClose.LocalCommitment.LocalBalance.ToSatoshis()),
|
||||||
RemoteBalance: int64(waitingClose.LocalCommitment.RemoteBalance.ToSatoshis()),
|
RemoteBalance: int64(waitingClose.LocalCommitment.RemoteBalance.ToSatoshis()),
|
||||||
LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve),
|
LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve),
|
||||||
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve),
|
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve),
|
||||||
Initiator: rpcInitiator(waitingClose.IsInitiator),
|
Initiator: rpcInitiator(waitingClose.IsInitiator),
|
||||||
CommitmentType: rpcCommitmentType(waitingClose.ChanType),
|
CommitmentType: rpcCommitmentType(waitingClose.ChanType),
|
||||||
|
NumForwardingPackages: int64(len(fwdPkgs)),
|
||||||
}
|
}
|
||||||
|
|
||||||
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{
|
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{
|
||||||
|
|||||||
Reference in new issue
Block a user