mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 22:46:38 +02:00
channeldb: re-design OpenChannel schema, update tests
The state of OpenChannel on disk has now been partitioned into several buckets+keys within the db. At the top level, a set of prefixed keys stored common data updated frequently (with every channel update). These fields are stored at the top level in order to facilities prefix scans, and to avoid read/write amplification due to serialization/deserialization with each read/write. Within the active channel bucket, a nested bucket keyed on the node’s ID stores the remainder of the channel. Additionally OpenChannel now uses elkrem rather than shachain, delivery scripts instead of addresses, stores the total net fees, and splits the csv delay into the remote vs local node’s. Several TODO’s have been left lingering, to be visited in the near future.
This commit is contained in:
@@ -132,3 +132,24 @@ func fileExists(path string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// FetchOpenChannel...
|
||||
func (d *DB) FetchOpenChannel(nodeID [32]byte) (*OpenChannel, error) {
|
||||
var channel *OpenChannel
|
||||
err := d.store.View(func(tx *bolt.Tx) error {
|
||||
// Get the bucket dedicated to storing the meta-data for open
|
||||
// channels.
|
||||
openChanBucket := tx.Bucket(openChannelBucket)
|
||||
if openChannelBucket == nil {
|
||||
return fmt.Errorf("open channel bucket does not exist")
|
||||
}
|
||||
|
||||
oChannel, err := fetchOpenChannel(openChanBucket, nodeID, d.cryptoSystem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
channel = oChannel
|
||||
return nil
|
||||
})
|
||||
|
||||
return channel, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user