swarm: integrate OpenTracing; propagate ctx to internal APIs (#17169)
* swarm: propagate ctx, enable opentracing * swarm/tracing: log error when tracing is misconfigured
This commit is contained in:
committed by
Balint Gabor
parent
f7d3678c28
commit
7c9314f231
@@ -74,7 +74,7 @@ func NewHasherStore(chunkStore ChunkStore, hashFunc SwarmHasher, toEncrypt bool)
|
||||
// Put stores the chunkData into the ChunkStore of the hasherStore and returns the reference.
|
||||
// If hasherStore has a chunkEncryption object, the data will be encrypted.
|
||||
// Asynchronous function, the data will not necessarily be stored when it returns.
|
||||
func (h *hasherStore) Put(chunkData ChunkData) (Reference, error) {
|
||||
func (h *hasherStore) Put(ctx context.Context, chunkData ChunkData) (Reference, error) {
|
||||
c := chunkData
|
||||
size := chunkData.Size()
|
||||
var encryptionKey encryption.Key
|
||||
@@ -87,7 +87,7 @@ func (h *hasherStore) Put(chunkData ChunkData) (Reference, error) {
|
||||
}
|
||||
chunk := h.createChunk(c, size)
|
||||
|
||||
h.storeChunk(chunk)
|
||||
h.storeChunk(ctx, chunk)
|
||||
|
||||
return Reference(append(chunk.Addr, encryptionKey...)), nil
|
||||
}
|
||||
@@ -95,14 +95,14 @@ func (h *hasherStore) Put(chunkData ChunkData) (Reference, error) {
|
||||
// Get returns data of the chunk with the given reference (retrieved from the ChunkStore of hasherStore).
|
||||
// If the data is encrypted and the reference contains an encryption key, it will be decrypted before
|
||||
// return.
|
||||
func (h *hasherStore) Get(ref Reference) (ChunkData, error) {
|
||||
func (h *hasherStore) Get(ctx context.Context, ref Reference) (ChunkData, error) {
|
||||
key, encryptionKey, err := parseReference(ref, h.hashSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
toDecrypt := (encryptionKey != nil)
|
||||
|
||||
chunk, err := h.store.Get(key)
|
||||
chunk, err := h.store.Get(ctx, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -207,13 +207,13 @@ func (h *hasherStore) RefSize() int64 {
|
||||
return h.refSize
|
||||
}
|
||||
|
||||
func (h *hasherStore) storeChunk(chunk *Chunk) {
|
||||
func (h *hasherStore) storeChunk(ctx context.Context, chunk *Chunk) {
|
||||
h.wg.Add(1)
|
||||
go func() {
|
||||
<-chunk.dbStoredC
|
||||
h.wg.Done()
|
||||
}()
|
||||
h.store.Put(chunk)
|
||||
h.store.Put(ctx, chunk)
|
||||
}
|
||||
|
||||
func parseReference(ref Reference, hashSize int) (Address, encryption.Key, error) {
|
||||
|
Reference in New Issue
Block a user