Skip to content

Commit

Permalink
Merge pull request #2047 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
core/rawdb, triedb/pathdb: fix freezer read-only option
  • Loading branch information
ucwong committed Jun 5, 2024
2 parents f94e270 + 1890de9 commit d896b79
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
19 changes: 12 additions & 7 deletions core/rawdb/freezer_resettable.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ type freezerOpenFunc = func() (*Freezer, error)
// resettableFreezer is a wrapper of the freezer which makes the
// freezer resettable.
type resettableFreezer struct {
freezer *Freezer
opener freezerOpenFunc
datadir string
lock sync.RWMutex
readOnly bool
freezer *Freezer
opener freezerOpenFunc
datadir string
lock sync.RWMutex
}

// newResettableFreezer creates a resettable freezer, note freezer is
Expand All @@ -60,9 +61,10 @@ func newResettableFreezer(datadir string, namespace string, readonly bool, maxTa
return nil, err
}
return &resettableFreezer{
freezer: freezer,
opener: opener,
datadir: datadir,
readOnly: readonly,
freezer: freezer,
opener: opener,
datadir: datadir,
}, nil
}

Expand All @@ -74,6 +76,9 @@ func (f *resettableFreezer) Reset() error {
f.lock.Lock()
defer f.lock.Unlock()

if f.readOnly {
return errReadOnly
}
if err := f.freezer.Close(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2
github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/arsham/figurine v1.3.0
github.com/aws/aws-sdk-go-v2 v1.27.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1:
github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q=
github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk=
github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA=
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e h1:XPgiOuI/BQmEYOhDfrEl7e0vksbkBe0meT6YZAd0y3w=
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e/go.mod h1:RTrewKfZZUqUIudGRYm7SydFQOnAQlmyQ2rggGH0CmA=
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6 h1:vqyeuougAKbCCe5iajAKXyfi673149dZy0k6RXLs/i0=
github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6/go.mod h1:RTrewKfZZUqUIudGRYm7SydFQOnAQlmyQ2rggGH0CmA=
github.com/CortexFoundation/wormhole v0.0.2-0.20240503144741-71d4d22383f0 h1:pePXS+/6usgcC1G2Ma3pX7fJwoRcgLPyu5SLawrTszc=
github.com/CortexFoundation/wormhole v0.0.2-0.20240503144741-71d4d22383f0/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ github.com/CortexFoundation/robot/backend
# github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
## explicit; go 1.16
github.com/CortexFoundation/statik
# github.com/CortexFoundation/torrentfs v1.0.65-0.20240528085256-81c24aed642e
# github.com/CortexFoundation/torrentfs v1.0.65-0.20240528134905-53a5260396d6
## explicit; go 1.22
github.com/CortexFoundation/torrentfs
github.com/CortexFoundation/torrentfs/backend
Expand Down

0 comments on commit d896b79

Please sign in to comment.