diff --git a/blockstore/splitstore/markset_bloom.go b/blockstore/splitstore/markset_bloom.go index 9261de7c753..a8960be311b 100644 --- a/blockstore/splitstore/markset_bloom.go +++ b/blockstore/splitstore/markset_bloom.go @@ -62,6 +62,11 @@ func (s *BloomMarkSet) saltedKey(cid cid.Cid) []byte { key := make([]byte, len(s.salt)+len(hash)) n := copy(key, s.salt) copy(key[n:], hash) + // FYI, you probably don't need a cryptographic hash function here given that we're salting + // anyways. + // You could use https://golang.org/pkg/hash/maphash/ + // (probably) + // (if it's a perf issue) rehash := sha256.Sum256(key) return rehash[:] } diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index 82494795d63..9854c35cbbf 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -228,6 +228,8 @@ func (s *SplitStore) Has(cid cid.Cid) (bool, error) { return true, nil } + // Didn't we need to somehow ressurect everything under this in case we decide to GC? Or are + // we handling that in a followup patch. return s.cold.Has(cid) } @@ -618,6 +620,12 @@ func (s *SplitStore) trackTxnRefMany(cids []cid.Cid) error { return nil } +// This could get _real_ slow (many minutes to hours) and will block tipset verification. Can we do this lazily and/or force +// the GC thread to handle this? +// +// I.e., take a lock to make sure GC is paused, then stick this in a "to traverse" queue. Then, when +// GC "resumes", it first checks that queue. + // transactionally protect a reference by walking the object and marking. // concurrent markings are short circuited by checking the markset. func (s *SplitStore) doTxnProtect(root cid.Cid, batch map[cid.Cid]struct{}) error { @@ -625,6 +633,14 @@ func (s *SplitStore) doTxnProtect(root cid.Cid, batch map[cid.Cid]struct{}) erro // cannot be deleted before the object itself. err := s.walkObjectIncomplete(root, cid.NewSet(), func(c cid.Cid) error { + // Let's make sure we _completely_ match vm.Copy. We don't need this _now_, + // but should try to not to introduce inconsistencies. + + if root.Prefix().MhType == 0 { + // identity cid, skip + return errStopWalk + } + if isFilCommitment(c) { return errStopWalk } @@ -1282,6 +1298,7 @@ func (s *SplitStore) checkClosing() error { return nil } +// This is very dangerious and could go horribly wrong if we have anything else with a structure that matches a block header. func (s *SplitStore) isOldBlockHeader(c cid.Cid, epoch abi.ChainEpoch) (isOldBlock bool, err error) { if c.Prefix().Codec != cid.DagCBOR { return false, nil