wtxmgr: separate PutTxLabel into store-independent function

Separate out the logic we use to write labels so that it can be used
in dropwtxmgr to re-add labels if we want to keep them when we drop the
rest of the db.
This commit is contained in:
carla 2020-05-25 10:56:25 +02:00
parent e0e62245ec
commit 4ec3fb4928
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91

View file

@ -984,6 +984,15 @@ func (s *Store) PutTxLabel(ns walletdb.ReadWriteBucket, txid chainhash.Hash,
return err
}
return PutTxLabel(labelBucket, txid, label)
}
// PutTxLabel writes a label for a tx to the bucket provided. Note that it does
// not perform any validation on the label provided, or check whether there is
// an existing label for the txid.
func PutTxLabel(labelBucket walletdb.ReadWriteBucket, txid chainhash.Hash,
label string) error {
// We expect the label length to be limited on creation, so we can
// store the label's length as a uint16.
labelLen := uint16(len(label))