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
@@ -0,0 +1,54 @@
|
||||
package channeldb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
"github.com/btcsuite/btcwallet/walletdb"
|
||||
)
|
||||
|
||||
var (
|
||||
endian = binary.BigEndian
|
||||
)
|
||||
|
||||
var bufPool = &sync.Pool{
|
||||
New: func() interface{} { return new(bytes.Buffer) },
|
||||
}
|
||||
|
||||
// Store...
|
||||
// TODO(roasbeef): CHECKSUMS, REDUNDANCY, etc etc.
|
||||
type DB struct {
|
||||
// TODO(roasbeef): caching, etc?
|
||||
addrmgr *waddrmgr.Manager
|
||||
|
||||
namespace walletdb.Namespace
|
||||
}
|
||||
|
||||
// Wipe...
|
||||
func (d *DB) Wipe() error {
|
||||
return d.namespace.Update(func(tx walletdb.Tx) error {
|
||||
rootBucket := tx.RootBucket()
|
||||
// TODO(roasbeef): other buckets
|
||||
return rootBucket.DeleteBucket(openChannelBucket)
|
||||
})
|
||||
}
|
||||
|
||||
// New...
|
||||
// TODO(roasbeef): re-visit this dependancy...
|
||||
func New(addrmgr *waddrmgr.Manager, namespace walletdb.Namespace) *DB {
|
||||
// TODO(roasbeef): create buckets if not created?
|
||||
return &DB{addrmgr, namespace}
|
||||
}
|
||||
|
||||
// Open...
|
||||
// TODO(roasbeef): create+open, ditch New, fixes above
|
||||
func Open() *DB {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create...
|
||||
func Create() *DB {
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user