multi: rename: ReadBucket to RBucket

This commit is contained in:
Conner Fromknecht committed 2020-05-26 18:21:08 -07:00
1 parent d0d2ca403d
commit 455ddfebdb
18 files changed
+63 -63

No files matched your search

+10 -10
View File
@@ -756,7 +756,7 @@ func (c *OpenChannel) RefreshShortChanID() error {
// channel's data resides in given: the public key for the node, the outpoint,
// and the chainhash that the channel resides on.
func fetchChanBucket(tx kvdb.RTx, nodeKey *btcec.PublicKey,
outPoint *wire.OutPoint, chainHash chainhash.Hash) (kvdb.ReadBucket, error) {
outPoint *wire.OutPoint, chainHash chainhash.Hash) (kvdb.RBucket, error) {
// First fetch the top level bucket which stores all data related to
// current, active channels.
@@ -1045,7 +1045,7 @@ func (c *OpenChannel) ChanSyncMsg() (*lnwire.ChannelReestablish, error) {
// active.
//
// NOTE: The primary mutex should already be held before this method is called.
func (c *OpenChannel) isBorked(chanBucket kvdb.ReadBucket) (bool, error) {
func (c *OpenChannel) isBorked(chanBucket kvdb.RBucket) (bool, error) {
channel, err := fetchOpenChannel(chanBucket, &c.FundingOutpoint)
if err != nil {
return false, err
@@ -1279,7 +1279,7 @@ func putOpenChannel(chanBucket kvdb.RwBucket, channel *OpenChannel) error {
// fetchOpenChannel retrieves, and deserializes (including decrypting
// sensitive) the complete channel currently active with the passed nodeID.
func fetchOpenChannel(chanBucket kvdb.ReadBucket,
func fetchOpenChannel(chanBucket kvdb.RBucket,
chanPoint *wire.OutPoint) (*OpenChannel, error) {
channel := &OpenChannel{
@@ -3010,7 +3010,7 @@ func putOptionalUpfrontShutdownScript(chanBucket kvdb.RwBucket, key []byte,
// getOptionalUpfrontShutdownScript reads the shutdown script stored under the
// key provided if it is present. Upfront shutdown scripts are optional, so the
// function returns with no error if the key is not present.
func getOptionalUpfrontShutdownScript(chanBucket kvdb.ReadBucket, key []byte,
func getOptionalUpfrontShutdownScript(chanBucket kvdb.RBucket, key []byte,
script *lnwire.DeliveryAddress) error {
// Return early if the bucket does not exit, a shutdown script was not set.
@@ -3114,7 +3114,7 @@ func readChanConfig(b io.Reader, c *ChannelConfig) error {
)
}
func fetchChanInfo(chanBucket kvdb.ReadBucket, channel *OpenChannel) error {
func fetchChanInfo(chanBucket kvdb.RBucket, channel *OpenChannel) error {
infoBytes := chanBucket.Get(chanInfoKey)
if infoBytes == nil {
return ErrNoChanInfoFound
@@ -3181,7 +3181,7 @@ func deserializeChanCommit(r io.Reader) (ChannelCommitment, error) {
return c, nil
}
func fetchChanCommitment(chanBucket kvdb.ReadBucket, local bool) (ChannelCommitment, error) {
func fetchChanCommitment(chanBucket kvdb.RBucket, local bool) (ChannelCommitment, error) {
var commitKey []byte
if local {
commitKey = append(chanCommitmentKey, byte(0x00))
@@ -3198,7 +3198,7 @@ func fetchChanCommitment(chanBucket kvdb.ReadBucket, local bool) (ChannelCommitm
return deserializeChanCommit(r)
}
func fetchChanCommitments(chanBucket kvdb.ReadBucket, channel *OpenChannel) error {
func fetchChanCommitments(chanBucket kvdb.RBucket, channel *OpenChannel) error {
var err error
// If this is a restored channel, then we don't have any commitments to
@@ -3219,7 +3219,7 @@ func fetchChanCommitments(chanBucket kvdb.ReadBucket, channel *OpenChannel) erro
return nil
}
func fetchChanRevocationState(chanBucket kvdb.ReadBucket, channel *OpenChannel) error {
func fetchChanRevocationState(chanBucket kvdb.RBucket, channel *OpenChannel) error {
revBytes := chanBucket.Get(revocationStateKey)
if revBytes == nil {
return ErrNoRevocationsFound
@@ -3291,7 +3291,7 @@ func appendChannelLogEntry(log kvdb.RwBucket,
return log.Put(logEntrykey[:], b.Bytes())
}
func fetchChannelLogEntry(log kvdb.ReadBucket,
func fetchChannelLogEntry(log kvdb.RBucket,
updateNum uint64) (ChannelCommitment, error) {
logEntrykey := makeLogKey(updateNum)
@@ -3304,7 +3304,7 @@ func fetchChannelLogEntry(log kvdb.ReadBucket,
return deserializeChanCommit(commitReader)
}
func fetchThawHeight(chanBucket kvdb.ReadBucket) (uint32, error) {
func fetchThawHeight(chanBucket kvdb.RBucket) (uint32, error) {
var height uint32
heightBytes := chanBucket.Get(frozenChanKey)
+2 -2
View File
@@ -460,7 +460,7 @@ func (db *DB) fetchOpenChannels(tx kvdb.RTx,
// fetchNodeChannels retrieves all active channels from the target chainBucket
// which is under a node's dedicated channel bucket. This function is typically
// used to fetch all the active channels related to a particular node.
func (db *DB) fetchNodeChannels(chainBucket kvdb.ReadBucket) ([]*OpenChannel, error) {
func (db *DB) fetchNodeChannels(chainBucket kvdb.RBucket) ([]*OpenChannel, error) {
var channels []*OpenChannel
@@ -1313,7 +1313,7 @@ func getMigrationsToApply(versions []version, version uint32) ([]migration, []ui
// from the historical channel bucket. If the bucket does not exist,
// ErrNoHistoricalBucket is returned.
func fetchHistoricalChanBucket(tx kvdb.RTx,
outPoint *wire.OutPoint) (kvdb.ReadBucket, error) {
outPoint *wire.OutPoint) (kvdb.RBucket, error) {
// First fetch the top level bucket which stores all data related to
// historically stored channels.
+3 -3
View File
@@ -61,7 +61,7 @@ type duplicateHTLCAttemptInfo struct {
// fetchDuplicatePaymentStatus fetches the payment status of the payment. If the
// payment isn't found, it will default to "StatusUnknown".
func fetchDuplicatePaymentStatus(bucket kvdb.ReadBucket) PaymentStatus {
func fetchDuplicatePaymentStatus(bucket kvdb.RBucket) PaymentStatus {
if bucket.Get(duplicatePaymentSettleInfoKey) != nil {
return StatusSucceeded
}
@@ -129,7 +129,7 @@ func deserializeDuplicatePaymentCreationInfo(r io.Reader) (
return c, nil
}
func fetchDuplicatePayment(bucket kvdb.ReadBucket) (*MPPayment, error) {
func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
seqBytes := bucket.Get(duplicatePaymentSequenceKey)
if seqBytes == nil {
return nil, fmt.Errorf("sequence number not found")
@@ -209,7 +209,7 @@ func fetchDuplicatePayment(bucket kvdb.ReadBucket) (*MPPayment, error) {
return payment, nil
}
func fetchDuplicatePayments(paymentHashBucket kvdb.ReadBucket) ([]*MPPayment,
func fetchDuplicatePayments(paymentHashBucket kvdb.RBucket) ([]*MPPayment,
error) {
var payments []*MPPayment
+2 -2
View File
@@ -543,7 +543,7 @@ func loadChannelFwdPkgs(tx kvdb.RTx, source lnwire.ShortChannelID) ([]*FwdPkg, e
// loadFwPkg reads the packager's fwd pkg at a given height, and determines the
// appropriate FwdState.
func loadFwdPkg(fwdPkgBkt kvdb.ReadBucket, source lnwire.ShortChannelID,
func loadFwdPkg(fwdPkgBkt kvdb.RBucket, source lnwire.ShortChannelID,
height uint64) (*FwdPkg, error) {
sourceKey := makeLogKey(source.ToUint64())
@@ -649,7 +649,7 @@ func loadFwdPkg(fwdPkgBkt kvdb.ReadBucket, source lnwire.ShortChannelID,
// loadHtlcs retrieves all serialized htlcs in a bucket, returning
// them in order of the indexes they were written under.
func loadHtlcs(bkt kvdb.ReadBucket) ([]LogUpdate, error) {
func loadHtlcs(bkt kvdb.RBucket) ([]LogUpdate, error) {
var htlcs []LogUpdate
if err := bkt.ForEach(func(_, v []byte) error {
var htlc LogUpdate
+9 -9
View File
@@ -389,7 +389,7 @@ func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
// of the graph. The source node is treated as the center node within a
// star-graph. This method may be used to kick off a path finding algorithm in
// order to explore the reachability of another node based off the source node.
func (c *ChannelGraph) sourceNode(nodes kvdb.ReadBucket) (*LightningNode, error) {
func (c *ChannelGraph) sourceNode(nodes kvdb.RBucket) (*LightningNode, error) {
selfPub := nodes.Get(sourceKey)
if selfPub == nil {
return nil, ErrSourceNodeNotSet
@@ -3272,7 +3272,7 @@ func (c *ChannelGraph) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte) {
// isZombieEdge returns whether an entry exists for the given channel in the
// zombie index. If an entry exists, then the two node public keys corresponding
// to this edge are also returned.
func isZombieEdge(zombieIndex kvdb.ReadBucket,
func isZombieEdge(zombieIndex kvdb.RBucket,
chanID uint64) (bool, [33]byte, [33]byte) {
var k [8]byte
@@ -3444,7 +3444,7 @@ func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket, // no
return nodeBucket.Put(nodePub, b.Bytes())
}
func fetchLightningNode(nodeBucket kvdb.ReadBucket,
func fetchLightningNode(nodeBucket kvdb.RBucket,
nodePub []byte) (LightningNode, error) {
nodeBytes := nodeBucket.Get(nodePub)
@@ -3618,7 +3618,7 @@ func putChanEdgeInfo(edgeIndex kvdb.RwBucket, edgeInfo *ChannelEdgeInfo, chanID
return edgeIndex.Put(chanID[:], b.Bytes())
}
func fetchChanEdgeInfo(edgeIndex kvdb.ReadBucket,
func fetchChanEdgeInfo(edgeIndex kvdb.RBucket,
chanID []byte) (ChannelEdgeInfo, error) {
edgeInfoBytes := edgeIndex.Get(chanID)
@@ -3827,8 +3827,8 @@ func putChanEdgePolicyUnknown(edges kvdb.RwBucket, channelID uint64,
return edges.Put(edgeKey[:], unknownPolicy)
}
func fetchChanEdgePolicy(edges kvdb.ReadBucket, chanID []byte,
nodePub []byte, nodes kvdb.ReadBucket) (*ChannelEdgePolicy, error) {
func fetchChanEdgePolicy(edges kvdb.RBucket, chanID []byte,
nodePub []byte, nodes kvdb.RBucket) (*ChannelEdgePolicy, error) {
var edgeKey [33 + 8]byte
copy(edgeKey[:], nodePub)
@@ -3860,8 +3860,8 @@ func fetchChanEdgePolicy(edges kvdb.ReadBucket, chanID []byte,
return ep, nil
}
func fetchChanEdgePolicies(edgeIndex kvdb.ReadBucket, edges kvdb.ReadBucket,
nodes kvdb.ReadBucket, chanID []byte,
func fetchChanEdgePolicies(edgeIndex kvdb.RBucket, edges kvdb.RBucket,
nodes kvdb.RBucket, chanID []byte,
db *DB) (*ChannelEdgePolicy, *ChannelEdgePolicy, error) {
edgeInfo := edgeIndex.Get(chanID)
@@ -3969,7 +3969,7 @@ func serializeChanEdgePolicy(w io.Writer, edge *ChannelEdgePolicy,
}
func deserializeChanEdgePolicy(r io.Reader,
nodes kvdb.ReadBucket) (*ChannelEdgePolicy, error) {
nodes kvdb.RBucket) (*ChannelEdgePolicy, error) {
edge := &ChannelEdgePolicy{}
+1 -1
View File
@@ -1118,7 +1118,7 @@ func serializeHtlcs(w io.Writer, htlcs map[CircuitKey]*InvoiceHTLC) error {
return nil
}
func fetchInvoice(invoiceNum []byte, invoices kvdb.ReadBucket) (Invoice, error) {
func fetchInvoice(invoiceNum []byte, invoices kvdb.RBucket) (Invoice, error) {
invoiceBytes := invoices.Get(invoiceNum)
if invoiceBytes == nil {
return Invoice{}, ErrInvoiceNotFound
+2 -2
View File
@@ -81,9 +81,9 @@ var Open = walletdb.Open
// themselves as a backend which implements the Backend interface.
type Driver = walletdb.Driver
// ReadBucket represents a bucket (a hierarchical structure within the
// RBucket represents a bucket (a hierarchical structure within the
// database) that is only allowed to perform read operations.
type ReadBucket = walletdb.ReadBucket
type RBucket = walletdb.ReadBucket
// ReadCursor represents a bucket cursor that can be positioned at the start or
// end of the bucket's key/value pairs and iterate over pairs in the bucket.
+5 -5
View File
@@ -202,7 +202,7 @@ func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
// of the graph. The source node is treated as the center node within a
// star-graph. This method may be used to kick off a path finding algorithm in
// order to explore the reachability of another node based off the source node.
func (c *ChannelGraph) sourceNode(nodes kvdb.ReadBucket) (*LightningNode, error) {
func (c *ChannelGraph) sourceNode(nodes kvdb.RBucket) (*LightningNode, error) {
selfPub := nodes.Get(sourceKey)
if selfPub == nil {
return nil, ErrSourceNodeNotSet
@@ -680,7 +680,7 @@ func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket,
return nodeBucket.Put(nodePub, b.Bytes())
}
func fetchLightningNode(nodeBucket kvdb.ReadBucket,
func fetchLightningNode(nodeBucket kvdb.RBucket,
nodePub []byte) (LightningNode, error) {
nodeBytes := nodeBucket.Get(nodePub)
@@ -983,8 +983,8 @@ func putChanEdgePolicyUnknown(edges kvdb.RwBucket, channelID uint64,
return edges.Put(edgeKey[:], unknownPolicy)
}
func fetchChanEdgePolicy(edges kvdb.ReadBucket, chanID []byte,
nodePub []byte, nodes kvdb.ReadBucket) (*ChannelEdgePolicy, error) {
func fetchChanEdgePolicy(edges kvdb.RBucket, chanID []byte,
nodePub []byte, nodes kvdb.RBucket) (*ChannelEdgePolicy, error) {
var edgeKey [33 + 8]byte
copy(edgeKey[:], nodePub)
@@ -1084,7 +1084,7 @@ func serializeChanEdgePolicy(w io.Writer, edge *ChannelEdgePolicy,
}
func deserializeChanEdgePolicy(r io.Reader,
nodes kvdb.ReadBucket) (*ChannelEdgePolicy, error) {
nodes kvdb.RBucket) (*ChannelEdgePolicy, error) {
edge := &ChannelEdgePolicy{}
@@ -437,7 +437,7 @@ func (db *DB) fetchPaymentsMigration9() ([]*Payment, error) {
return payments, nil
}
func fetchPaymentMigration9(bucket kvdb.ReadBucket) (*Payment, error) {
func fetchPaymentMigration9(bucket kvdb.RBucket) (*Payment, error) {
var (
err error
p = &Payment{}
@@ -4,7 +4,7 @@ import "github.com/lightningnetwork/lnd/channeldb/kvdb"
// fetchPaymentStatus fetches the payment status of the payment. If the payment
// isn't found, it will default to "StatusUnknown".
func fetchPaymentStatus(bucket kvdb.ReadBucket) PaymentStatus {
func fetchPaymentStatus(bucket kvdb.RBucket) PaymentStatus {
if bucket.Get(paymentSettleInfoKey) != nil {
return StatusSucceeded
}
+1 -1
View File
@@ -316,7 +316,7 @@ func (db *DB) FetchPayments() ([]*Payment, error) {
return payments, nil
}
func fetchPayment(bucket kvdb.ReadBucket) (*Payment, error) {
func fetchPayment(bucket kvdb.RBucket) (*Payment, error) {
var (
err error
p = &Payment{}
+2 -2
View File
@@ -30,7 +30,7 @@ func DumpDB(tx kvdb.RTx, rootKey []byte) error {
return dumpBucket(bucket)
}
func dumpBucket(bucket kvdb.ReadBucket) error {
func dumpBucket(bucket kvdb.RBucket) error {
fmt.Printf("map[string]interface{} {\n")
err := bucket.ForEach(func(k, v []byte) error {
key := toString(k)
@@ -109,7 +109,7 @@ func VerifyDB(tx kvdb.RTx, rootKey []byte, data map[string]interface{}) error {
return verifyDB(bucket, data)
}
func verifyDB(bucket kvdb.ReadBucket, data map[string]interface{}) error {
func verifyDB(bucket kvdb.RBucket, data map[string]interface{}) error {
for k, v := range data {
key := []byte(k)
+2 -2
View File
@@ -495,7 +495,7 @@ func createPaymentBucket(tx kvdb.RwTx, paymentHash lntypes.Hash) (
// fetchPaymentBucket fetches the sub-bucket assigned to this payment hash. If
// the bucket does not exist, it returns ErrPaymentNotInitiated.
func fetchPaymentBucket(tx kvdb.RTx, paymentHash lntypes.Hash) (
kvdb.ReadBucket, error) {
kvdb.RBucket, error) {
payments := tx.ReadBucket(paymentsRootBucket)
if payments == nil {
@@ -549,7 +549,7 @@ func nextPaymentSequence(tx kvdb.RwTx) ([]byte, error) {
// fetchPaymentStatus fetches the payment status of the payment. If the payment
// isn't found, it will default to "StatusUnknown".
func fetchPaymentStatus(bucket kvdb.ReadBucket) (PaymentStatus, error) {
func fetchPaymentStatus(bucket kvdb.RBucket) (PaymentStatus, error) {
// Creation info should be set for all payments, regardless of state.
// If not, it is unknown.
if bucket.Get(paymentCreationInfoKey) == nil {
+6 -6
View File
@@ -253,7 +253,7 @@ func (db *DB) FetchPayments() ([]*MPPayment, error) {
return payments, nil
}
func fetchCreationInfo(bucket kvdb.ReadBucket) (*PaymentCreationInfo, error) {
func fetchCreationInfo(bucket kvdb.RBucket) (*PaymentCreationInfo, error) {
b := bucket.Get(paymentCreationInfoKey)
if b == nil {
return nil, fmt.Errorf("creation info not found")
@@ -263,7 +263,7 @@ func fetchCreationInfo(bucket kvdb.ReadBucket) (*PaymentCreationInfo, error) {
return deserializePaymentCreationInfo(r)
}
func fetchPayment(bucket kvdb.ReadBucket) (*MPPayment, error) {
func fetchPayment(bucket kvdb.RBucket) (*MPPayment, error) {
seqBytes := bucket.Get(paymentSequenceKey)
if seqBytes == nil {
return nil, fmt.Errorf("sequence number not found")
@@ -345,7 +345,7 @@ func fetchPayment(bucket kvdb.ReadBucket) (*MPPayment, error) {
// fetchHtlcAttempts retrives all htlc attempts made for the payment found in
// the given bucket.
func fetchHtlcAttempts(bucket kvdb.ReadBucket) ([]HTLCAttempt, error) {
func fetchHtlcAttempts(bucket kvdb.RBucket) ([]HTLCAttempt, error) {
htlcs := make([]HTLCAttempt, 0)
err := bucket.ForEach(func(k, _ []byte) error {
@@ -388,7 +388,7 @@ func fetchHtlcAttempts(bucket kvdb.ReadBucket) ([]HTLCAttempt, error) {
// fetchHtlcAttemptInfo fetches the payment attempt info for this htlc from the
// bucket.
func fetchHtlcAttemptInfo(bucket kvdb.ReadBucket) (*HTLCAttemptInfo, error) {
func fetchHtlcAttemptInfo(bucket kvdb.RBucket) (*HTLCAttemptInfo, error) {
b := bucket.Get(htlcAttemptInfoKey)
if b == nil {
return nil, errNoAttemptInfo
@@ -400,7 +400,7 @@ func fetchHtlcAttemptInfo(bucket kvdb.ReadBucket) (*HTLCAttemptInfo, error) {
// fetchHtlcSettleInfo retrieves the settle info for the htlc. If the htlc isn't
// settled, nil is returned.
func fetchHtlcSettleInfo(bucket kvdb.ReadBucket) (*HTLCSettleInfo, error) {
func fetchHtlcSettleInfo(bucket kvdb.RBucket) (*HTLCSettleInfo, error) {
b := bucket.Get(htlcSettleInfoKey)
if b == nil {
// Settle info is optional.
@@ -413,7 +413,7 @@ func fetchHtlcSettleInfo(bucket kvdb.ReadBucket) (*HTLCSettleInfo, error) {
// fetchHtlcFailInfo retrieves the failure info for the htlc. If the htlc hasn't
// failed, nil is returned.
func fetchHtlcFailInfo(bucket kvdb.ReadBucket) (*HTLCFailInfo, error) {
func fetchHtlcFailInfo(bucket kvdb.RBucket) (*HTLCFailInfo, error) {
b := bucket.Get(htlcFailInfoKey)
if b == nil {
// Fail info is optional.