Skip to content

Commit

Permalink
changed the way the cid file is read
Browse files Browse the repository at this point in the history
  • Loading branch information
FotiosBistas committed Oct 4, 2022
1 parent 474ebd1 commit 5c51fef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions pkg/hoarder/cid_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,22 @@ func (file_cid_source *JsonFileCIDSource) GetNewCid() (GetNewCidReturnType, erro
if err != nil {
return Undef, errors.Wrap(err, " could not parse CID")
}
newPid, err := peer.IDFromString(providerRecord.ID)
newPid, err := peer.IDFromBytes([]byte(providerRecord.ID))
if err != nil {
return Undef, errors.Wrap(err, " could not parse PID")
}
multiaddr := providerRecord.Address
log.Infof("Read a new provider ID %s. The multiaddresses are %v.The new CID is %s", newPid, multiaddr, newCid)
ProviderAndCidInstance := NewGetNewCidReturnType(newPid, newCid, multiaddr)

multiaddresses := make([]ma.Multiaddr, 0)
for i := 0; i < len(providerRecord.Addresses); i++ {
multiaddr, err := ma.NewMultiaddr(providerRecord.Addresses[i])
if err != nil {
log.Errorf("could not convert string to multiaddress %s", err)
}
multiaddresses = append(multiaddresses, multiaddr)
}

log.Infof("Read a new provider ID %s. The multiaddresses are %v.The new CID is %s", string(newPid), multiaddresses, newCid)
ProviderAndCidInstance := NewGetNewCidReturnType(newPid, newCid, multiaddresses)
return ProviderAndCidInstance, nil
}
file_cid_source.ResetIndex()
Expand Down
2 changes: 1 addition & 1 deletion pkg/hoarder/json-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ProviderRecords struct {
type EncapsulatedJSONProviderRecord struct {
ID string `json:"PeerID"`
CID string `json:"ContentID"`
Addresses []string `json:"PeerMultiaddress"`
Addresses []string `json:"PeerMultiaddresses"`
}

//Creates a new:
Expand Down

0 comments on commit 5c51fef

Please sign in to comment.