// Get retrieves unpublished operations by suffix.
Get retrieves unpublished operations by suffix.
// Get retrieves unpublished operations by suffix .
func (s *Store) Get(suffix string) ([]*operation.AnchoredOperation, error) {
	startTime := time.Now()
	defer func() {
		s.metrics.GetUnpublishedOperations(time.Since(startTime))
	}()
	var err error
	query := fmt.Sprintf("%s:%s", index, suffix)
	iter, err := s.store.Query(query)
	if err != nil {
		return nil, fmt.Errorf("failed to get unpublished operations for[%s]: %w", query, err)
	}
	ok, err := iter.Next()
	if err != nil {
		return nil, fmt.Errorf("iterator error for suffix[%s] : %w", suffix, err)
	}
	var ops []*operation.AnchoredOperation
	for ok {
		var value []byte
		value, err = iter.Value()
		if err != nil {
			return nil, fmt.Errorf("failed to get iterator value for suffix[%s]: %w",
				suffix, err)
		}
		var op operation.AnchoredOperation
		err = json.Unmarshal(value, &op)
		if err != nil {
			return nil, fmt.Errorf("failed to unmarshal unpublished operation from store value for suffix[%s]: %w",
				suffix, err)
		}
		ops = append(ops, &op)
		ok, err = iter.Next()
		if err != nil {
			return nil, orberrors.NewTransient(fmt.Errorf("iterator error for suffix[%s] : %w", suffix, err))
		}
	}
	logger.Debugf("retrieved %d unpublished operations for suffix[%s]", len(ops), suffix)
	if len(ops) == 0 {
		return nil, fmt.Errorf("suffix[%s] not found in the unpublished operation store", suffix)
	}
	return ops, nil
}
func ( s * Store ) Get ( suffix string ) ( [ ] * operation . AnchoredOperation , error ) { startTime := time . Now ( ) defer func ( ) { s . metrics . GetUnpublishedOperations ( time . Since ( startTime ) ) } ( ) var err error query := fmt . Sprintf ( " " , index , suffix ) iter , err := s . store . Query ( query ) if err != nil { return nil , fmt . Errorf ( " " , query , err ) } ok , err := iter . Next ( ) if err != nil { return nil , fmt . Errorf ( " " , suffix , err ) } var ops [ ] * operation . AnchoredOperation for ok { var value [ ] byte value , err = iter . Value ( ) if err != nil { return nil , fmt . Errorf ( " " , suffix , err ) } var op operation . AnchoredOperation err = json . Unmarshal ( value , & op ) if err != nil { return nil , fmt . Errorf ( " " , suffix , err ) } ops = append ( ops , & op ) ok , err = iter . Next ( ) if err != nil { return nil , orberrors . NewTransient ( fmt . Errorf ( " " , suffix , err ) ) } } logger . Debugf ( " " , len ( ops ) , suffix ) if len ( ops ) == 0 { return nil , fmt . Errorf ( " " , suffix ) } return ops , nil }
Get retrieves unpublished operations by suffix.
Get retrieves unpublished operations by suffix .