[#170] oid, cid: Refactor and document package functionality

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-04-11 19:25:14 +03:00 committed by LeL
parent 24d6c2221f
commit f7172adf18
49 changed files with 831 additions and 439 deletions

View file

@ -16,20 +16,20 @@ type DNS struct{}
// Otherwise, returns an error.
//
// See also net.LookupTXT.
func (x *DNS) ResolveContainerName(name string) (*cid.ID, error) {
func (x *DNS) ResolveContainerName(name string) (id cid.ID, err error) {
records, err := net.LookupTXT(name)
if err != nil {
return nil, err
return
}
var id cid.ID
for i := range records {
err = id.Parse(records[i])
err = id.DecodeString(records[i])
if err == nil {
return &id, nil
return
}
}
return nil, errNotFound
err = errNotFound
return
}