From 4ec3fb4928d6063a45f72b9e1f4cf2c0cfdae031 Mon Sep 17 00:00:00 2001 From: carla Date: Mon, 25 May 2020 10:56:25 +0200 Subject: [PATCH] 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. --- wtxmgr/tx.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wtxmgr/tx.go b/wtxmgr/tx.go index 512fe1a..8c9e574 100644 --- a/wtxmgr/tx.go +++ b/wtxmgr/tx.go @@ -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))