// GetByCid returns history logs for a Cid.
GetByCid returns history logs for a Cid.
// GetByCid returns history logs for a Cid .
func (cl *Logger) GetByCid(ctx context.Context, iid ffs.APIID, c cid.Cid) ([]ffs.LogEntry, error) {
	q := query.Query{Prefix: makeStorageCidKey(iid, c).String()}
	res, err := cl.ds.Query(q)
	if err != nil {
		return nil, fmt.Errorf("running query: %s", err)
	}
	defer func() {
		if err := res.Close(); err != nil {
			log.Errorf("closing query result: %s", err)
		}
	}()
	var lgs []ffs.LogEntry
	for r := range res.Next() {
		if r.Error != nil {
			return nil, fmt.Errorf("iter next: %s", r.Error)
		}
		var le logEntry
		if err := json.Unmarshal(r.Value, &le); err != nil {
			return nil, fmt.Errorf("unmarshaling log entry: %s", err)
		}
		lgs = append(lgs, ffs.LogEntry{
			Cid:       le.Cid,
			Jid:       le.Jid,
			Msg:       le.Msg,
			Timestamp: time.Unix(0, le.Timestamp),
		})
	}
	sort.Slice(lgs, func(a, b int) bool {
		return lgs[a].Timestamp.Before(lgs[b].Timestamp)
	})
	return lgs, nil
}
func ( cl * Logger ) GetByCid ( ctx context . Context , iid ffs . APIID , c cid . Cid ) ( [ ] ffs . LogEntry , error ) { q := query . Query { Prefix : makeStorageCidKey ( iid , c ) . String ( ) } res , err := cl . ds . Query ( q ) if err != nil { return nil , fmt . Errorf ( " " , err ) } defer func ( ) { if err := res . Close ( ) ; err != nil { log . Errorf ( " " , err ) } } ( ) var lgs [ ] ffs . LogEntry for r := range res . Next ( ) { if r . Error != nil { return nil , fmt . Errorf ( " " , r . Error ) } var le logEntry if err := json . Unmarshal ( r . Value , & le ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } lgs = append ( lgs , ffs . LogEntry { Cid : le . Cid , Jid : le . Jid , Msg : le . Msg , Timestamp : time . Unix ( 0 , le . Timestamp ) , } ) } sort . Slice ( lgs , func ( a , b int ) bool { return lgs [ a ] . Timestamp . Before ( lgs [ b ] . Timestamp ) } ) return lgs , nil }
GetByCid returns history logs for a Cid.
GetByCid returns history logs for a Cid .