// Get retrieves witnesses for the given anchor id.
Get retrieves witnesses for the given anchor id.
// Get retrieves witnesses for the given anchor id .
func (s *Store) Get(anchorID string) ([]*proof.WitnessProof, error) {
	var err error
	anchorIDEncoded := base64.RawURLEncoding.EncodeToString([]byte(anchorID))
	query := fmt.Sprintf("%s:%s", anchorIndex, anchorIDEncoded)
	iter, err := s.store.Query(query)
	if err != nil {
		return nil, orberrors.NewTransient(fmt.Errorf("failed to get witnesses for[%s]: %w", query, err))
	}
	defer func() {
		err = iter.Close()
		if err != nil {
			logger.Errorf("failed to close iterator: %s", err.Error())
		}
	}()
	ok, err := iter.Next()
	if err != nil {
		return nil, orberrors.NewTransient(fmt.Errorf("iterator error for anchorID[%s] : %w", anchorID, err))
	}
	var witnesses []*proof.WitnessProof
	for ok {
		var value []byte
		value, err = iter.Value()
		if err != nil {
			return nil, orberrors.NewTransient(fmt.Errorf("failed to get iterator value for anchorID[%s]: %w",
				anchorID, err))
		}
		var witness proof.WitnessProof
		err = json.Unmarshal(value, &witness)
		if err != nil {
			return nil, fmt.Errorf("failed to unmarshal anchor witness from store value for anchorID[%s]: %w",
				anchorID, err)
		}
		witnesses = append(witnesses, &witness)
		ok, err = iter.Next()
		if err != nil {
			return nil, orberrors.NewTransient(fmt.Errorf("iterator error for anchorID[%s] : %w", anchorID, err))
		}
	}
	logger.Debugf("retrieved %d witnesses for anchorID[%s]", len(witnesses), anchorID)
	if len(witnesses) == 0 {
		return nil, fmt.Errorf("anchorID[%s] not found in the store", anchorID)
	}
	return witnesses, nil
}
func ( s * Store ) Get ( anchorID string ) ( [ ] * proof . WitnessProof , error ) { var err error anchorIDEncoded := base64 . RawURLEncoding . EncodeToString ( [ ] byte ( anchorID ) ) query := fmt . Sprintf ( " " , anchorIndex , anchorIDEncoded ) iter , err := s . store . Query ( query ) if err != nil { return nil , orberrors . NewTransient ( fmt . Errorf ( " " , query , err ) ) } defer func ( ) { err = iter . Close ( ) if err != nil { logger . Errorf ( " " , err . Error ( ) ) } } ( ) ok , err := iter . Next ( ) if err != nil { return nil , orberrors . NewTransient ( fmt . Errorf ( " " , anchorID , err ) ) } var witnesses [ ] * proof . WitnessProof for ok { var value [ ] byte value , err = iter . Value ( ) if err != nil { return nil , orberrors . NewTransient ( fmt . Errorf ( " " , anchorID , err ) ) } var witness proof . WitnessProof err = json . Unmarshal ( value , & witness ) if err != nil { return nil , fmt . Errorf ( " " , anchorID , err ) } witnesses = append ( witnesses , & witness ) ok , err = iter . Next ( ) if err != nil { return nil , orberrors . NewTransient ( fmt . Errorf ( " " , anchorID , err ) ) } } logger . Debugf ( " " , len ( witnesses ) , anchorID ) if len ( witnesses ) == 0 { return nil , fmt . Errorf ( " " , anchorID ) } return witnesses , nil }
Get retrieves witnesses for the given anchor id.
Get retrieves witnesses for the given anchor id .