swarm/storage/localstore: add more context to pull sub log messages

This commit is contained in:
Janos Guljas 2019-01-25 17:38:29 +01:00
parent ad5b329a39
commit 8d15e823f9

View file

@ -20,6 +20,7 @@ import (
"bytes" "bytes"
"context" "context"
"errors" "errors"
"fmt"
"sync" "sync"
"github.com/ethereum/go-ethereum/log" "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 // if until is reached
return return
} }
log.Error("localstore pull subscription iteration", "err", err) log.Error("localstore pull subscription iteration", "bin", bin, "since", since, "until", until, "err", err)
return return
} }
case <-stopChan: case <-stopChan:
@ -131,7 +132,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until *ChunkD
case <-ctx.Done(): case <-ctx.Done():
err := ctx.Err() err := ctx.Err()
if err != nil { if err != nil {
log.Error("localstore pull subscription", "err", err) log.Error("localstore pull subscription", "bin", bin, "since", since, "until", until, "err", err)
} }
return return
} }
@ -164,6 +165,13 @@ type ChunkDescriptor struct {
StoreTimestamp int64 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 // triggerPullSubscriptions is used internally for starting iterations
// on Pull subscriptions for a particular bin. When new item with address // 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 // that is in particular bin for DB's baseKey is added to pull index