multi: rename: ReadBucket to RBucket

This commit is contained in:
Conner Fromknecht 2020-05-06 15:48:00 -07:00
parent d0d2ca403d
commit 455ddfebdb
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
18 changed files with 63 additions and 63 deletions

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)

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.

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

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

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{}

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

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.

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{}

View File

@ -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{}

View File

@ -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
}

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{}

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)

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 {

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.

View File

@ -337,7 +337,7 @@ func newBoltArbitratorLog(db kvdb.Backend, cfg ChannelArbitratorConfig,
// interface.
var _ ArbitratorLog = (*boltArbitratorLog)(nil)
func fetchContractReadBucket(tx kvdb.RTx, scopeKey []byte) (kvdb.ReadBucket, error) {
func fetchContractReadBucket(tx kvdb.RTx, scopeKey []byte) (kvdb.RBucket, error) {
scopeBucket := tx.ReadBucket(scopeKey)
if scopeBucket == nil {
return nil, errScopeBucketNoExist

View File

@ -966,7 +966,7 @@ func (ns *nurseryStore) createChannelBucket(tx kvdb.RwTx,
// using the given channel point. If the bucket does not exist, or any bucket
// along its path does not exist, a nil value is returned.
func (ns *nurseryStore) getChannelBucket(tx kvdb.RTx,
chanPoint *wire.OutPoint) kvdb.ReadBucket {
chanPoint *wire.OutPoint) kvdb.RBucket {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.ReadBucket(ns.pfxChainKey)
@ -1049,7 +1049,7 @@ func (ns *nurseryStore) createHeightBucket(tx kvdb.RwTx,
// store, using the provided block height. If the bucket does not exist, or any
// bucket along its path does not exist, a nil value is returned.
func (ns *nurseryStore) getHeightBucketPath(tx kvdb.RTx,
height uint32) (kvdb.ReadBucket, kvdb.ReadBucket, kvdb.ReadBucket) {
height uint32) (kvdb.RBucket, kvdb.RBucket, kvdb.RBucket) {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.ReadBucket(ns.pfxChainKey)
@ -1103,7 +1103,7 @@ func (ns *nurseryStore) getHeightBucketPathWrite(tx kvdb.RwTx,
// using the provided block height. If the bucket does not exist, or any bucket
// along its path does not exist, a nil value is returned.
func (ns *nurseryStore) getHeightBucket(tx kvdb.RTx,
height uint32) kvdb.ReadBucket {
height uint32) kvdb.RBucket {
_, _, hghtBucket := ns.getHeightBucketPath(tx, height)
return hghtBucket
@ -1412,7 +1412,7 @@ func removeBucketIfExists(parent kvdb.RwBucket, bktName []byte) error {
// isBucketEmpty returns errBucketNotEmpty if the bucket has a non-zero number
// of children.
func isBucketEmpty(parent kvdb.ReadBucket) error {
func isBucketEmpty(parent kvdb.RBucket) error {
return parent.ForEach(func(_, _ []byte) error {
return errBucketNotEmpty
})

View File

@ -577,7 +577,7 @@ func (c *ClientDB) ListClientSessions(id *TowerID) (map[SessionID]*ClientSession
// listClientSessions returns the set of all client sessions known to the db. An
// optional tower ID can be used to filter out any client sessions in the
// response that do not correspond to this tower.
func listClientSessions(sessions kvdb.ReadBucket,
func listClientSessions(sessions kvdb.RBucket,
id *TowerID) (map[SessionID]*ClientSession, error) {
clientSessions := make(map[SessionID]*ClientSession)
@ -894,7 +894,7 @@ func (c *ClientDB) AckUpdate(id *SessionID, seqNum uint16,
// bucket corresponding to the serialized session id. This does not deserialize
// the CommittedUpdates or AckUpdates associated with the session. If the caller
// requires this info, use getClientSession.
func getClientSessionBody(sessions kvdb.ReadBucket,
func getClientSessionBody(sessions kvdb.RBucket,
idBytes []byte) (*ClientSession, error) {
sessionBkt := sessions.NestedReadBucket(idBytes)
@ -922,7 +922,7 @@ func getClientSessionBody(sessions kvdb.ReadBucket,
// getClientSession loads the full ClientSession associated with the serialized
// session id. This method populates the CommittedUpdates and AckUpdates in
// addition to the ClientSession's body.
func getClientSession(sessions kvdb.ReadBucket,
func getClientSession(sessions kvdb.RBucket,
idBytes []byte) (*ClientSession, error) {
session, err := getClientSessionBody(sessions, idBytes)
@ -950,7 +950,7 @@ func getClientSession(sessions kvdb.ReadBucket,
// getClientSessionCommits retrieves all committed updates for the session
// identified by the serialized session id.
func getClientSessionCommits(sessions kvdb.ReadBucket,
func getClientSessionCommits(sessions kvdb.RBucket,
idBytes []byte) ([]CommittedUpdate, error) {
// Can't fail because client session body has already been read.
@ -986,7 +986,7 @@ func getClientSessionCommits(sessions kvdb.ReadBucket,
// getClientSessionAcks retrieves all acked updates for the session identified
// by the serialized session id.
func getClientSessionAcks(sessions kvdb.ReadBucket,
func getClientSessionAcks(sessions kvdb.RBucket,
idBytes []byte) (map[uint16]BackupID, error) {
// Can't fail because client session body has already been read.
@ -1050,7 +1050,7 @@ func markSessionStatus(sessions kvdb.RwBucket, session *ClientSession,
}
// getChanSummary loads a ClientChanSummary for the passed chanID.
func getChanSummary(chanSummaries kvdb.ReadBucket,
func getChanSummary(chanSummaries kvdb.RBucket,
chanID lnwire.ChannelID) (*ClientChanSummary, error) {
chanSummaryBytes := chanSummaries.Get(chanID[:])
@ -1081,7 +1081,7 @@ func putChanSummary(chanSummaries kvdb.RwBucket, chanID lnwire.ChannelID,
}
// getTower loads a Tower identified by its serialized tower id.
func getTower(towers kvdb.ReadBucket, id []byte) (*Tower, error) {
func getTower(towers kvdb.RBucket, id []byte) (*Tower, error) {
towerBytes := towers.Get(id)
if towerBytes == nil {
return nil, ErrTowerNotFound

View File

@ -505,7 +505,7 @@ func (t *TowerDB) GetLookoutTip() (*chainntnfs.BlockEpoch, error) {
// getSession retrieves the session info from the sessions bucket identified by
// its session id. An error is returned if the session is not found or a
// deserialization error occurs.
func getSession(sessions kvdb.ReadBucket, id []byte) (*SessionInfo, error) {
func getSession(sessions kvdb.RBucket, id []byte) (*SessionInfo, error) {
sessionBytes := sessions.Get(id)
if sessionBytes == nil {
return nil, ErrSessionNotFound
@ -551,7 +551,7 @@ func removeSessionHintBkt(updateIndex kvdb.RwBucket, id *SessionID) error {
// getHintsForSession returns all known hints belonging to the given session id.
// If the index for the session has not been initialized, this method returns
// ErrNoSessionHintIndex.
func getHintsForSession(updateIndex kvdb.ReadBucket,
func getHintsForSession(updateIndex kvdb.RBucket,
id *SessionID) ([]blob.BreachHint, error) {
sessionHints := updateIndex.NestedReadBucket(id[:])
@ -604,7 +604,7 @@ func putLookoutEpoch(bkt kvdb.RwBucket, epoch *chainntnfs.BlockEpoch) error {
// getLookoutEpoch retrieves the lookout tip block epoch from the given bucket.
// A nil epoch is returned if no update exists.
func getLookoutEpoch(bkt kvdb.ReadBucket) *chainntnfs.BlockEpoch {
func getLookoutEpoch(bkt kvdb.RBucket) *chainntnfs.BlockEpoch {
epochBytes := bkt.Get(lookoutTipKey)
if len(epochBytes) != 36 {
return nil
@ -625,7 +625,7 @@ func getLookoutEpoch(bkt kvdb.ReadBucket) *chainntnfs.BlockEpoch {
var errBucketNotEmpty = errors.New("bucket not empty")
// isBucketEmpty returns errBucketNotEmpty if the bucket is not empty.
func isBucketEmpty(bkt kvdb.ReadBucket) error {
func isBucketEmpty(bkt kvdb.RBucket) error {
return bkt.ForEach(func(_, _ []byte) error {
return errBucketNotEmpty
})