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:
Johan T. Halseth
2020-10-02 14:49:02 +02:00
parent d40cf6b592
commit dbeafe8832
7 changed files with 70 additions and 48 deletions

View File

@ -292,8 +292,8 @@ func TestAgentChannelOpenSignal(t *testing.T) {
// Next we'll signal a new channel being opened by the backing LN node,
// with a capacity of 1 BTC.
newChan := LocalChannel{
ChanID: randChanID(),
Capacity: btcutil.SatoshiPerBitcoin,
ChanID: randChanID(),
Balance: btcutil.SatoshiPerBitcoin,
}
testCtx.agent.OnChannelOpen(newChan)
@ -434,12 +434,12 @@ func TestAgentChannelCloseSignal(t *testing.T) {
// We'll start the agent with two channels already being active.
initialChans := []LocalChannel{
{
ChanID: randChanID(),
Capacity: btcutil.SatoshiPerBitcoin,
ChanID: randChanID(),
Balance: btcutil.SatoshiPerBitcoin,
},
{
ChanID: randChanID(),
Capacity: btcutil.SatoshiPerBitcoin * 2,
ChanID: randChanID(),
Balance: btcutil.SatoshiPerBitcoin * 2,
},
}
@ -730,9 +730,9 @@ func TestAgentPendingChannelState(t *testing.T) {
t.Fatalf("should include pending chan in current "+
"state, instead have %v chans", len(req.chans))
}
if req.chans[0].Capacity != chanAmt {
t.Fatalf("wrong chan capacity: expected %v, got %v",
req.chans[0].Capacity, chanAmt)
if req.chans[0].Balance != chanAmt {
t.Fatalf("wrong chan balance: expected %v, got %v",
req.chans[0].Balance, chanAmt)
}
if req.chans[0].Node != nodeID {
t.Fatalf("wrong node ID: expected %x, got %x",