@@ -19,6 +19,11 @@ func NewDiscV5API(discV5 *UDPv5) *DiscV5API {
1919 return & DiscV5API {discV5 }
2020}
2121
22+ type PutContentResult struct {
23+ PeerCount int `json:"peerCount"`
24+ StoredLocally bool `json:"storedLocally"`
25+ }
26+
2227type NodeInfo struct {
2328 NodeId string `json:"nodeId"`
2429 Enr string `json:"enr"`
@@ -540,6 +545,30 @@ func (p *PortalProtocolAPI) Gossip(contentKeyHex, contentHex string) (int, error
540545 return p .portalProtocol .Gossip (& id , [][]byte {contentKey }, [][]byte {content })
541546}
542547
548+ func (p * PortalProtocolAPI ) PutContent (contentKeyHex , contentHex string ) (* PutContentResult , error ) {
549+ contentKey , err := hexutil .Decode (contentKeyHex )
550+ if err != nil {
551+ return nil , err
552+ }
553+ content , err := hexutil .Decode (contentHex )
554+ if err != nil {
555+ return nil , err
556+ }
557+ shouldStore , err := p .portalProtocol .ShouldStore (contentKey , content )
558+ if err != nil {
559+ return nil , err
560+ }
561+ id := p .portalProtocol .Self ().ID ()
562+ num , err := p .portalProtocol .Gossip (& id , [][]byte {contentKey }, [][]byte {content })
563+ if err != nil {
564+ return nil , err
565+ }
566+ return & PutContentResult {
567+ PeerCount : num ,
568+ StoredLocally : shouldStore ,
569+ }, nil
570+ }
571+
543572func (p * PortalProtocolAPI ) TraceRecursiveFindContent (contentKeyHex string ) (* TraceContentResult , error ) {
544573 contentKey , err := hexutil .Decode (contentKeyHex )
545574 if err != nil {
0 commit comments