diff --git a/p2p/discover/api.go b/p2p/discover/api.go index ed306f312f..07a5b61dc4 100644 --- a/p2p/discover/api.go +++ b/p2p/discover/api.go @@ -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{ diff --git a/portalnetwork/beacon/api.go b/portalnetwork/beacon/api.go index f9358c56c7..a74455759d 100644 --- a/portalnetwork/beacon/api.go +++ b/portalnetwork/beacon/api.go @@ -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) { diff --git a/portalnetwork/history/api.go b/portalnetwork/history/api.go index 926bca7cf9..62245eed15 100644 --- a/portalnetwork/history/api.go +++ b/portalnetwork/history/api.go @@ -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) { diff --git a/portalnetwork/state/api.go b/portalnetwork/state/api.go index a09f88d595..875e1ab248 100644 --- a/portalnetwork/state/api.go +++ b/portalnetwork/state/api.go @@ -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) {