From 6ef3b11b6927d227ff3aee890d663b6c754128c4 Mon Sep 17 00:00:00 2001 From: fearlessfe <505380967@qq.com> Date: Wed, 6 Mar 2024 23:28:29 +0800 Subject: [PATCH] feat: define traceContentLookupRes --- p2p/discover/api.go | 16 ++++++++++++++++ p2p/discover/portal_protocol.go | 2 ++ 2 files changed, 18 insertions(+) diff --git a/p2p/discover/api.go b/p2p/discover/api.go index 363765ca8f..47f26c3977 100644 --- a/p2p/discover/api.go +++ b/p2p/discover/api.go @@ -46,6 +46,22 @@ type ContentInfo struct { UtpTransfer bool `json:"utpTransfer"` } +type TraceContentResult struct { + Content string `json:"content"` + UtpTransfer bool `json:"utpTransfer"` + Trace Trace `json:"trace"` +} + +type Trace struct { + Origin string `json:"origin"` // local node id + TargetId string `json:"targetId"` // target content id + ReceivedFrom string `json:"receivedFrom"` // the node id of which content from + Responses map[string]ContentInfo `json:"responses"` // the node id and there response + Metadata map[string]any `json:"metadata"` // node id and there metadata object + StartedAtMs int `json:"startedAtMs"` // timestamp of the beginning of this request in milliseconds + Cancelled []string `json:"cancelled"` // the node ids which are send but cancelled +} + type Enrs struct { Enrs []string `json:"enrs"` } diff --git a/p2p/discover/portal_protocol.go b/p2p/discover/portal_protocol.go index 67eb3248a0..3b84f1da68 100644 --- a/p2p/discover/portal_protocol.go +++ b/p2p/discover/portal_protocol.go @@ -1499,6 +1499,8 @@ func (p *PortalProtocol) contentLookupWorker(n *enode.Node, contentKey []byte, r return wrapedNode, nil } +// func (p *PortalProtocol) traceContentLookupWorker() + func (p *PortalProtocol) ToContentId(contentKey []byte) []byte { return p.toContentId(contentKey) }