mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 10:11:11 +02:00
contractcourt: use graphdb outpoint helpers
Start using the single set of exported write/read functions for wire.Outpoint.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
)
|
||||
|
||||
@@ -221,7 +222,7 @@ func prefixOutputKey(statePrefix []byte,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := writeOutpoint(&pfxOutputBuffer, &outpoint)
|
||||
err := graphdb.WriteOutpoint(&pfxOutputBuffer, &outpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -738,7 +739,9 @@ func (ns *NurseryStore) ListChannels() ([]wire.OutPoint, error) {
|
||||
|
||||
return chanIndex.ForEach(func(chanBytes, _ []byte) error {
|
||||
var chanPoint wire.OutPoint
|
||||
err := readOutpoint(bytes.NewReader(chanBytes), &chanPoint)
|
||||
err := graphdb.ReadOutpoint(
|
||||
bytes.NewReader(chanBytes), &chanPoint,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -804,12 +807,13 @@ func (ns *NurseryStore) RemoveChannel(chanPoint *wire.OutPoint) error {
|
||||
// Serialize the provided channel point, such that we can delete
|
||||
// the mature channel bucket.
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
err := graphdb.WriteOutpoint(&chanBuffer, chanPoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chanBytes := chanBuffer.Bytes()
|
||||
|
||||
err := ns.forChanOutputs(tx, chanPoint, func(k, v []byte) error {
|
||||
err = ns.forChanOutputs(tx, chanPoint, func(k, v []byte) error {
|
||||
if !bytes.HasPrefix(k, gradPrefix) {
|
||||
return ErrImmatureChannel
|
||||
}
|
||||
@@ -959,7 +963,7 @@ func (ns *NurseryStore) createChannelBucket(tx kvdb.RwTx,
|
||||
// Serialize the provided channel point, as this provides the name of
|
||||
// the channel bucket of interest.
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
if err := graphdb.WriteOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -989,7 +993,7 @@ func (ns *NurseryStore) getChannelBucket(tx kvdb.RTx,
|
||||
// Serialize the provided channel point and return the bucket matching
|
||||
// the serialized key.
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
if err := graphdb.WriteOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1017,7 +1021,7 @@ func (ns *NurseryStore) getChannelBucketWrite(tx kvdb.RwTx,
|
||||
// Serialize the provided channel point and return the bucket matching
|
||||
// the serialized key.
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
if err := graphdb.WriteOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1142,7 +1146,7 @@ func (ns *NurseryStore) createHeightChanBucket(tx kvdb.RwTx,
|
||||
// Serialize the provided channel point, as this generates the name of
|
||||
// the subdirectory corresponding to the channel of interest.
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
if err := graphdb.WriteOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chanBytes := chanBuffer.Bytes()
|
||||
@@ -1168,7 +1172,7 @@ func (ns *NurseryStore) getHeightChanBucketWrite(tx kvdb.RwTx,
|
||||
// Serialize the provided channel point, which generates the key for
|
||||
// looking up the proper height-channel bucket inside the height bucket.
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
if err := graphdb.WriteOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
return nil
|
||||
}
|
||||
chanBytes := chanBuffer.Bytes()
|
||||
@@ -1312,7 +1316,7 @@ func (ns *NurseryStore) removeOutputFromHeight(tx kvdb.RwTx, height uint32,
|
||||
}
|
||||
|
||||
var chanBuffer bytes.Buffer
|
||||
if err := writeOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
if err := graphdb.WriteOutpoint(&chanBuffer, chanPoint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user