channeldb: modify schema to multiple-channels-per-peer

This commit overhauls the current schema for storing active channels in
order to support tracking+updating multiple open channels for a
particular peer.

Channels are now uniquely identified by an output (txid:index) rather
than an arbitrary hash value. As a result, the funding transaction is
no longer stored, as only the txin is required to lookup the original
transaction, and to sign for new commitment states.

A new bucket, nested within the bucket for a node’s Lightning ID has
been created. This new bucket acts as an index to the active channels
for a particular peer by storing all the active channel points as keys
within the bucket. This bucket can then be scanned in a linear fashion,
or queried randomly in order to retrieve channel information.

The split between top-level, and channel-level keys remains the same.
The primary modification comes in using the channel ID (the funding
outpoint) as the key suffix for all top-level and channel-level keys.
This commit is contained in:
Olaoluwa Osuntokun
2016-06-20 21:39:50 -07:00
parent 43c84c2ce5
commit c2818a549b
3 changed files with 337 additions and 106 deletions

View File

@@ -3,5 +3,6 @@ package channeldb
import "fmt"
var (
ErrNoExists = fmt.Errorf("channel db has not yet been created")
ErrNoExists = fmt.Errorf("channel db has not yet been created")
ErrNoActiveChannels = fmt.Errorf("no active channels exist")
)