channeldb: create new channeldb package, update lnwallet to use new API
* Initial draft of brain dump of chandler. Nothing yet set in stone. * Will most likely move the storage of all structs to a more “column” oriented approach. Such that, small updates like incrementing the total satoshi sent don’t result in the entire struct being serialized and written. * Some skeleton structs for other possible data we might want to store are also included. * Seem valuable to record as much data as possible for record keeping, visualization, debugging, etc. Will need to set up a time+space+dirty cache to ensure performance isn’t impacted too much.
This commit is contained in:
1 parent
d7a1c5d337
commit
4fdb2763e6
13 files changed
+194
-131
No files matched your search
+11
-2
@@ -1,6 +1,7 @@
|
||||
package lnwallet
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"li.lan/labs/plasma/channeldb"
|
||||
"li.lan/labs/plasma/shachain"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
@@ -34,7 +36,14 @@ var (
|
||||
"create funding transaction")
|
||||
|
||||
// Which bitcoin network are we using?
|
||||
// TODO(roasbeef): config
|
||||
ActiveNetParams = &chaincfg.TestNet3Params
|
||||
// Namespace bucket keys.
|
||||
lightningNamespaceKey = []byte("ln-wallet")
|
||||
waddrmgrNamespaceKey = []byte("waddrmgr")
|
||||
wtxmgrNamespaceKey = []byte("wtxmgr")
|
||||
|
||||
endian = binary.BigEndian
|
||||
)
|
||||
|
||||
type FundingType uint16
|
||||
@@ -137,7 +146,7 @@ type LightningWallet struct {
|
||||
|
||||
// A wrapper around a namespace within boltdb reserved for ln-based
|
||||
// wallet meta-data.
|
||||
channelDB *ChannelDB
|
||||
channelDB *channeldb.DB
|
||||
|
||||
wallet *btcwallet.Wallet
|
||||
rpc *chain.Client
|
||||
@@ -210,7 +219,7 @@ func NewLightningWallet(privWalletPass, pubWalletPass, hdSeed []byte, dataDir st
|
||||
return &LightningWallet{
|
||||
DB: db,
|
||||
wallet: wallet,
|
||||
channelDB: NewChannelDB(wallet.Manager, lnNamespace),
|
||||
channelDB: channeldb.New(wallet.Manager, lnNamespace),
|
||||
msgChan: make(chan interface{}, msgBufferSize),
|
||||
// TODO(roasbeef): make this atomic.Uint32 instead? Which is
|
||||
// faster, locks or CAS? I'm guessing CAS because assembly:
|
||||
|
||||
Reference in new issue
Block a user