From 8d15e823f9522ac99dcd4a0b6c55e0d0f27bc2e8 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Fri, 25 Jan 2019 17:38:29 +0100 Subject: [PATCH] swarm/storage/localstore: add more context to pull sub log messages --- swarm/storage/localstore/subscription_pull.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/swarm/storage/localstore/subscription_pull.go b/swarm/storage/localstore/subscription_pull.go index dc2aa004ba..a18f0915d9 100644 --- a/swarm/storage/localstore/subscription_pull.go +++ b/swarm/storage/localstore/subscription_pull.go @@ -20,6 +20,7 @@ import ( "bytes" "context" "errors" + "fmt" "sync" "github.com/ethereum/go-ethereum/log" @@ -117,7 +118,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until *ChunkD // if until is reached return } - log.Error("localstore pull subscription iteration", "err", err) + log.Error("localstore pull subscription iteration", "bin", bin, "since", since, "until", until, "err", err) return } case <-stopChan: @@ -131,7 +132,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until *ChunkD case <-ctx.Done(): err := ctx.Err() if err != nil { - log.Error("localstore pull subscription", "err", err) + log.Error("localstore pull subscription", "bin", bin, "since", since, "until", until, "err", err) } return } @@ -164,6 +165,13 @@ type ChunkDescriptor struct { StoreTimestamp int64 } +func (c *ChunkDescriptor) String() string { + if c == nil { + return "none" + } + return fmt.Sprintf("%s stored at %v", c.Address.Hex(), c.StoreTimestamp) +} + // triggerPullSubscriptions is used internally for starting iterations // on Pull subscriptions for a particular bin. When new item with address // that is in particular bin for DB's baseKey is added to pull index