Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions p2p/discover/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,28 +415,31 @@ func (p *PortalProtocolAPI) FindContent(enr string, contentKey string) (interfac
}
}

func (p *PortalProtocolAPI) Offer(enr string, contentKey string, contentValue string) (string, error) {
func (p *PortalProtocolAPI) Offer(enr string, contentItems [][2]string) (string, error) {
n, err := enode.Parse(enode.ValidSchemes, enr)
if err != nil {
return "", err
}

contentKeyBytes, err := hexutil.Decode(contentKey)
if err != nil {
return "", err
}
contentValueBytes, err := hexutil.Decode(contentValue)
if err != nil {
return "", err
}

contentEntry := &ContentEntry{
ContentKey: contentKeyBytes,
Content: contentValueBytes,
entries := make([]*ContentEntry, 0, len(contentItems))
for _, contentItem := range contentItems {
contentKey, err := hexutil.Decode(contentItem[0])
if err != nil {
return "", err
}
contentValue, err := hexutil.Decode(contentItem[1])
if err != nil {
return "", err
}
contentEntry := &ContentEntry{
ContentKey: contentKey,
Content: contentValue,
}
entries = append(entries, contentEntry)
}

transientOfferRequest := &TransientOfferRequest{
Contents: []*ContentEntry{contentEntry},
Contents: entries,
}

offerReq := &OfferRequest{
Expand Down
4 changes: 2 additions & 2 deletions portalnetwork/beacon/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (p *API) BeaconFindContent(enr string, contentKey string) (interface{}, err
return p.FindContent(enr, contentKey)
}

func (p *API) BeaconOffer(enr string, contentKey string, contentValue string) (string, error) {
return p.Offer(enr, contentKey, contentValue)
func (p *API) BeaconOffer(enr string, contentItems [][2]string) (string, error) {
return p.Offer(enr, contentItems)
}

func (p *API) BeaconRecursiveFindNodes(nodeId string) ([]string, error) {
Expand Down
4 changes: 2 additions & 2 deletions portalnetwork/history/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (p *API) HistoryFindContent(enr string, contentKey string) (interface{}, er
return p.FindContent(enr, contentKey)
}

func (p *API) HistoryOffer(enr string, contentKey string, contentValue string) (string, error) {
return p.Offer(enr, contentKey, contentValue)
func (p *API) HistoryOffer(enr string, contentItems [][2]string) (string, error) {
return p.Offer(enr, contentItems)
}

func (p *API) HistoryRecursiveFindNodes(nodeId string) ([]string, error) {
Expand Down
4 changes: 2 additions & 2 deletions portalnetwork/state/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (p *API) StateFindContent(enr string, contentKey string) (interface{}, erro
return p.FindContent(enr, contentKey)
}

func (p *API) StateOffer(enr string, contentKey string, contentValue string) (string, error) {
return p.Offer(enr, contentKey, contentValue)
func (p *API) StateOffer(enr string, contentItems [][2]string) (string, error) {
return p.Offer(enr, contentItems)
}

func (p *API) StateRecursiveFindNodes(nodeId string) ([]string, error) {
Expand Down