mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-03 20:14:49 +02:00
channeldb: implement snapshots for active channels
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/roasbeef/btcd/btcec"
|
"github.com/roasbeef/btcd/btcec"
|
||||||
"github.com/roasbeef/btcd/wire"
|
"github.com/roasbeef/btcd/wire"
|
||||||
"github.com/roasbeef/btcutil"
|
"github.com/roasbeef/btcutil"
|
||||||
"github.com/roasbeef/btcwallet/walletdb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -251,15 +250,48 @@ func (c *OpenChannel) CloseChannel() error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelSnapshot....
|
// ChannelSnapshot is a frozen snapshot of the current channel state. A
|
||||||
|
// snapshot is detached from the original channel that generated it, providing
|
||||||
|
// read-only access to the current or prior state of an active channel.
|
||||||
// TODO(roasbeef): methods to roll forwards/backwards in state etc
|
// TODO(roasbeef): methods to roll forwards/backwards in state etc
|
||||||
// * use botldb cursor?
|
// * use botldb cursor?
|
||||||
type ChannelSnapshot struct {
|
type ChannelSnapshot struct {
|
||||||
OpenChannel
|
RemoteID [wire.HashSize]byte
|
||||||
|
|
||||||
|
ChannelPoint *wire.OutPoint
|
||||||
|
|
||||||
|
Capacity btcutil.Amount
|
||||||
|
LocalBalance btcutil.Amount
|
||||||
|
RemoteBalance btcutil.Amount
|
||||||
|
|
||||||
|
NumUpdates uint64
|
||||||
|
|
||||||
|
TotalSatoshisSent uint64
|
||||||
|
TotalSatoshisReceived uint64
|
||||||
|
|
||||||
|
// TODO(roasbeef): fee stuff
|
||||||
|
|
||||||
// TODO(roasbeef): active HTLC's + their direction
|
// TODO(roasbeef): active HTLC's + their direction
|
||||||
updateNum uint64
|
updateNum uint64
|
||||||
deltaNamespace walletdb.Namespace
|
channel *OpenChannel
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snapshot returns a read-only snapshot of the current channel state. This
|
||||||
|
// snapshot includes information concerning the current settled balance within
|
||||||
|
// the channel, meta-data detailing total flows, and any outstanding HTLCs.
|
||||||
|
func (c *OpenChannel) Snapshot() *ChannelSnapshot {
|
||||||
|
snapshot := &ChannelSnapshot{
|
||||||
|
ChannelPoint: c.ChanID,
|
||||||
|
Capacity: c.Capacity,
|
||||||
|
LocalBalance: c.OurBalance,
|
||||||
|
RemoteBalance: c.TheirBalance,
|
||||||
|
NumUpdates: c.NumUpdates,
|
||||||
|
TotalSatoshisSent: c.TotalSatoshisSent,
|
||||||
|
TotalSatoshisReceived: c.TotalSatoshisReceived,
|
||||||
|
}
|
||||||
|
copy(snapshot.RemoteID[:], c.TheirLNID[:])
|
||||||
|
|
||||||
|
return snapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindPreviousState...
|
// FindPreviousState...
|
||||||
@@ -268,12 +300,6 @@ func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelSnapshot, err
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snapshot....
|
|
||||||
// read-only snapshot
|
|
||||||
func (c *OpenChannel) Snapshot() (*ChannelSnapshot, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChannelDelta...
|
// ChannelDelta...
|
||||||
// TODO(roasbeef): binlog like entry?
|
// TODO(roasbeef): binlog like entry?
|
||||||
type ChannelDelta struct {
|
type ChannelDelta struct {
|
||||||
|
Reference in New Issue
Block a user