From ca9b4e5529729e70305af66a076fc6559dc27e28 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 14 Jun 2022 13:38:43 -0400 Subject: [PATCH] Rename nameProgressLogger -> claimProgressLogger and tweak log message. --- claimtrie/claimtrie.go | 12 ++++++------ claimtrie/logger.go | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/claimtrie/claimtrie.go b/claimtrie/claimtrie.go index 4a6d6307..667916dd 100644 --- a/claimtrie/claimtrie.go +++ b/claimtrie/claimtrie.go @@ -50,8 +50,8 @@ type ClaimTrie struct { // Registrered cleanup functions which are invoked in the Close() in reverse order. cleanups []func() error - // nameLogger communicates progress of claimtrie rebuild. - nameLogger *nameProgressLogger + // claimLogger communicates progress of claimtrie rebuild. + claimLogger *claimProgressLogger } func New(cfg config.Config) (*ClaimTrie, error) { @@ -349,17 +349,17 @@ func (ct *ClaimTrie) runFullTrieRebuild(names [][]byte, interrupt <-chan struct{ var nhns chan NameHashNext if names == nil { node.Log("Building the entire claim trie in RAM...") - ct.nameLogger = newNameProgressLogger("Processed", node.GetLogger()) + ct.claimLogger = newClaimProgressLogger("Processed", node.GetLogger()) nhns = ct.makeNameHashNext(nil, true, interrupt) } else { - ct.nameLogger = nil + ct.claimLogger = nil nhns = ct.makeNameHashNext(names, false, interrupt) } for nhn := range nhns { ct.merkleTrie.Update(nhn.Name, nhn.Hash, false) - if ct.nameLogger != nil { - ct.nameLogger.LogName(nhn.Name) + if ct.claimLogger != nil { + ct.claimLogger.LogName(nhn.Name) } } } diff --git a/claimtrie/logger.go b/claimtrie/logger.go index 1d7eb529..ab5a38b4 100644 --- a/claimtrie/logger.go +++ b/claimtrie/logger.go @@ -11,10 +11,10 @@ import ( "github.com/btcsuite/btclog" ) -// nameProgressLogger provides periodic logging for other services in order +// claimProgressLogger provides periodic logging for other services in order // to show users progress of certain "actions" involving some or all current // claim names. Ex: rebuilding claimtrie. -type nameProgressLogger struct { +type claimProgressLogger struct { totalLogName int64 recentLogName int64 lastLogNameTime time.Time @@ -24,21 +24,21 @@ type nameProgressLogger struct { sync.Mutex } -// newNameProgressLogger returns a new name progress logger. +// newClaimProgressLogger returns a new name progress logger. // The progress message is templated as follows: // {progressAction} {numProcessed} {names|name} in the last {timePeriod} (total {totalProcessed}) -func newNameProgressLogger(progressMessage string, logger btclog.Logger) *nameProgressLogger { - return &nameProgressLogger{ +func newClaimProgressLogger(progressMessage string, logger btclog.Logger) *claimProgressLogger { + return &claimProgressLogger{ lastLogNameTime: time.Now(), progressAction: progressMessage, subsystemLogger: logger, } } -// LogName logs a new name as an information message to show progress -// to the user. In order to prevent spam, it limits logging to one -// message every 10 seconds with duration and totals included. -func (n *nameProgressLogger) LogName(name []byte) { +// LogName logs a new claim name as an information message to show progress +// to the user. In order to prevent spam, it limits logging to one message +// every 10 seconds with duration and totals included. +func (n *claimProgressLogger) LogName(name []byte) { n.Lock() defer n.Unlock() @@ -60,13 +60,13 @@ func (n *nameProgressLogger) LogName(name []byte) { if n.recentLogName == 1 { nameStr = "name" } - n.subsystemLogger.Infof("%s %d %s in the last %s (total %d)", + n.subsystemLogger.Infof("%s %d claim %s in the last %s (total %d)", n.progressAction, n.recentLogName, nameStr, tDuration, n.totalLogName) n.recentLogName = 0 n.lastLogNameTime = now } -func (n *nameProgressLogger) SetLastLogTime(time time.Time) { +func (n *claimProgressLogger) SetLastLogTime(time time.Time) { n.lastLogNameTime = time }