// AddStaged pins a Cid for APIID with a staged-pin.
// If c is already stage-pinned, its stage-pin timestamp will be refreshed.
// If c is already fully-pinned, this call is a noop (full-pin will be kept).
AddStaged pins a Cid for APIID with a staged-pin.
If c is already stage-pinned, its stage-pin timestamp will be refreshed.
If c is already fully-pinned, this call is a noop (full-pin will be kept).
// AddStaged pins a Cid for APIID with a staged - pin . // If c is already stage - pinned its stage - pin timestamp will be refreshed . // If c is already fully - pinned this call is a noop ( full - pin will be kept ) .
func (s *Store) AddStaged(iid ffs.APIID, c cid.Cid) error {
	s.lock.Lock()
	defer s.lock.Unlock()
	var r PinnedCid
	if cr, ok := s.cache[c]; ok {
		r = cr
	} else {
		r = PinnedCid{Cid: c}
	}
	for i, p := range r.Pins {
		if p.APIID == iid {
			if !p.Staged {
				return nil
			}
			r.Pins[i].CreatedAt = time.Now().Unix()
			return s.persist(r)
		}
	}
	p := Pin{
		APIID:     iid,
		Staged:    true,
		CreatedAt: time.Now().Unix(),
	}
	r.Pins = append(r.Pins, p)
	return s.persist(r)
}
func ( s * Store ) AddStaged ( iid ffs . APIID , c cid . Cid ) error { s . lock . Lock ( ) defer s . lock . Unlock ( ) var r PinnedCid if cr , ok := s . cache [ c ] ; ok { r = cr } else { r = PinnedCid { Cid : c } } for i , p := range r . Pins { if p . APIID == iid { if ! p . Staged { return nil } r . Pins [ i ] . CreatedAt = time . Now ( ) . Unix ( ) return s . persist ( r ) } } p := Pin { APIID : iid , Staged : true , CreatedAt : time . Now ( ) . Unix ( ) , } r . Pins = append ( r . Pins , p ) return s . persist ( r ) }
AddStaged pins a Cid for APIID with a staged-pin.
AddStaged pins a Cid for APIID with a staged - pin .
// Looks like the APIID had this Cid // pinned with Hot Storage, and later // decided to stage the Cid again. // Don't mark this Cid as stage-pin since // that would be wrong; keep the strong pin. // This Cid isn't GCable. // If the Cid is pinned because of a stage, // and is re-staged then simply update its // CreatedAt, so it will survive longer to a // GC. // If the Cid is not present, create it as a staged pin.