autopilot: rename to Capacity to Balance, define ChannelInfo()
We rename the field Capacity on local channels to Balance, define a new method ChannelInfo on the manager config that let us query the database for our latest channels state. Using this we will use the current local balance instead of the channel capacity when doing allocation calculations.
This commit is contained in:
7 files changed
+70
-48
No files matched your search
@@ -260,16 +260,35 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
|
||||
chanState := make([]autopilot.LocalChannel,
|
||||
len(activeChannels))
|
||||
for i, channel := range activeChannels {
|
||||
localCommit := channel.LocalCommitment
|
||||
balance := localCommit.LocalBalance.ToSatoshis()
|
||||
|
||||
chanState[i] = autopilot.LocalChannel{
|
||||
ChanID: channel.ShortChanID(),
|
||||
Capacity: channel.Capacity,
|
||||
ChanID: channel.ShortChanID(),
|
||||
Balance: balance,
|
||||
Node: autopilot.NewNodeID(
|
||||
channel.IdentityPub),
|
||||
channel.IdentityPub,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
return chanState, nil
|
||||
},
|
||||
ChannelInfo: func(chanPoint wire.OutPoint) (
|
||||
*autopilot.LocalChannel, error) {
|
||||
|
||||
channel, err := svr.remoteChanDB.FetchChannel(chanPoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localCommit := channel.LocalCommitment
|
||||
return &autopilot.LocalChannel{
|
||||
ChanID: channel.ShortChanID(),
|
||||
Balance: localCommit.LocalBalance.ToSatoshis(),
|
||||
Node: autopilot.NewNodeID(channel.IdentityPub),
|
||||
}, nil
|
||||
},
|
||||
SubscribeTransactions: svr.cc.wallet.SubscribeTransactions,
|
||||
SubscribeTopology: svr.chanRouter.SubscribeTopology,
|
||||
}, nil
|
||||
|
||||
Reference in new issue
Block a user