feat: offer json rpc change

This commit is contained in:
fearlessfe 2024-10-09 23:45:14 +08:00 committed by Chen Kai
parent 28d395dccc
commit e1bfcb45d9
4 changed files with 23 additions and 20 deletions

View file

@ -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{

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {