From 474982ecaf8c0ffb5f23d165c18a2e2f6a9c1617 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Tue, 14 Mar 2023 15:40:30 +0700 Subject: [PATCH] torrent: don't cancel storage, because lib can't handle such error and can graceful-shutdown anyway (#937) --- downloader/mdbx_piece_completion.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/downloader/mdbx_piece_completion.go b/downloader/mdbx_piece_completion.go index 89eb56e1b..6f209cd19 100644 --- a/downloader/mdbx_piece_completion.go +++ b/downloader/mdbx_piece_completion.go @@ -32,19 +32,18 @@ const ( ) type mdbxPieceCompletion struct { - db kv.RwDB - ctx context.Context + db kv.RwDB } var _ storage.PieceCompletion = (*mdbxPieceCompletion)(nil) -func NewMdbxPieceCompletion(ctx context.Context, db kv.RwDB) (ret storage.PieceCompletion, err error) { - ret = &mdbxPieceCompletion{ctx: ctx, db: db} +func NewMdbxPieceCompletion(db kv.RwDB) (ret storage.PieceCompletion, err error) { + ret = &mdbxPieceCompletion{db: db} return } func (m mdbxPieceCompletion) Get(pk metainfo.PieceKey) (cn storage.Completion, err error) { - err = m.db.View(m.ctx, func(tx kv.Tx) error { + err = m.db.View(context.Background(), func(tx kv.Tx) error { var key [infohash.Size + 4]byte copy(key[:], pk.InfoHash[:]) binary.BigEndian.PutUint32(key[infohash.Size:], uint32(pk.Index)) @@ -84,12 +83,12 @@ func (m mdbxPieceCompletion) Set(pk metainfo.PieceKey, b bool) error { // 1K fsyncs/2minutes it's quite expensive, but even on cloud (high latency) drive it allow download 100mb/s // and Erigon doesn't do anything when downloading snapshots if b { - tx, err = m.db.BeginRwNosync(m.ctx) + tx, err = m.db.BeginRwNosync(context.Background()) if err != nil { return err } } else { - tx, err = m.db.BeginRw(m.ctx) + tx, err = m.db.BeginRw(context.Background()) if err != nil { return err }