From eafffc16340d228c92348a6b63d6e88df1b6dedc Mon Sep 17 00:00:00 2001 From: vyzo Date: Sun, 4 Jul 2021 10:14:58 +0300 Subject: [PATCH] more efficient trackTxnRefMany --- blockstore/splitstore/splitstore.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index ced493ed9..679d2d8e8 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -650,15 +650,25 @@ func (s *SplitStore) trackTxnRefMany(cids []cid.Cid) error { return nil } - var err error + if s.txnRefs != nil { + // we haven't finished marking yet, so track the reference + s.txnRefsMx.Lock() + for _, c := range cids { + s.txnRefs[c] = struct{}{} + } + s.txnRefsMx.Unlock() + return nil + } + + // we have finished marking, protect the refs for _, c := range cids { - err2 := s.trackTxnRef(c, false) - if err2 != nil { - err = multierr.Combine(err, err2) + err := s.txnProtect.Mark(c) + if err != nil { + return err } } - return err + return nil } func (s *SplitStore) warmup(curTs *types.TipSet) error {