Skip to content

Commit

Permalink
hotstore now memrepo and somehow it works for compaction!
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Dec 27, 2024
1 parent 7349047 commit 0640edd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
9 changes: 9 additions & 0 deletions blockstore/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,12 @@ func (m MemBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
func (m MemBlockstore) HashOnRead(enabled bool) {
// no-op
}

func (m MemBlockstore) ForEachKey(f func(c cid.Cid) error) error {
for _, b := range m {
if err := f(b.Cid()); err != nil {
return err
}
}
return nil
}
6 changes: 6 additions & 0 deletions blockstore/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ func (m *SyncBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error
func (m *SyncBlockstore) HashOnRead(enabled bool) {
// noop
}

func (m *SyncBlockstore) ForEachKey(f func(c cid.Cid) error) error {
m.mu.RLock()
defer m.mu.RUnlock()
return m.bs.ForEachKey(f)
}
17 changes: 11 additions & 6 deletions node/repo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,9 @@ func (fsr *fsLockedRepo) Blockstore(ctx context.Context, domain BlockstoreDomain
log.Error("invalid blockstore domain", domain)
return nil, nil, ErrInvalidBlockstoreDomain
}
var bs *badgerbs.Blockstore
var bs blockstore.Blockstore
var err error
var close func() error

Check failure on line 441 in node/repo/fsrepo.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

redefines-builtin-id: redefinition of the built-in function close (revive)
if domain == UniversalBlockstore {
fsr.bsOnce.Do(func() {
path := fsr.join(filepath.Join(fsDatastore, "chain"))
Expand All @@ -458,12 +459,14 @@ func (fsr *fsLockedRepo) Blockstore(ctx context.Context, domain BlockstoreDomain
opts.SyncWrites = false
}

bs, err = badgerbs.Open(opts)
bbs, err := badgerbs.Open(opts)
if err != nil {
fsr.bsErr = err
return
}
fsr.bs = blockstore.WrapIDStore(bs)
close = bbs.Close

Check failure on line 467 in node/repo/fsrepo.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

redefines-builtin-id: redefinition of the built-in function close (revive)
fsr.bs = blockstore.WrapIDStore(bbs)
bs = fsr.bs
})
err = fsr.bsErr
} else {
Expand All @@ -485,17 +488,19 @@ func (fsr *fsLockedRepo) Blockstore(ctx context.Context, domain BlockstoreDomain
fsr.bsHotErr = err
return
}
bs, err = badgerbs.Open(opts)
bbs, err := badgerbs.Open(opts)
if err != nil {
fsr.bsHotErr = err
return
}
fsr.bsHot = bs
fsr.bsHot = bbs
close = bbs.Close

Check failure on line 497 in node/repo/fsrepo.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

redefines-builtin-id: redefinition of the built-in function close (revive)
bs = fsr.bsHot
})
err = fsr.bsHotErr
}

return bs, bs.Close, err
return bs, close, err
}

func (fsr *fsLockedRepo) SplitstorePath() (string, error) {
Expand Down

0 comments on commit 0640edd

Please sign in to comment.