|
|
@ -86,14 +86,22 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { |
|
|
|
|
|
|
|
|
|
|
|
traceFile := os.Getenv("P2P_TRACEFILE") |
|
|
|
traceFile := os.Getenv("P2P_TRACEFILE") |
|
|
|
if len(traceFile) > 0 { |
|
|
|
if len(traceFile) > 0 { |
|
|
|
|
|
|
|
var tracer libp2p_pubsub.EventTracer |
|
|
|
|
|
|
|
var tracerErr error |
|
|
|
|
|
|
|
if strings.HasPrefix(traceFile, "file:") { |
|
|
|
|
|
|
|
tracer, tracerErr = libp2p_pubsub.NewJSONTracer(strings.TrimPrefix(traceFile, "file:")) |
|
|
|
|
|
|
|
} else { |
|
|
|
pi, err := libp2p_peer.AddrInfoFromP2pAddr(ma.StringCast(traceFile)) |
|
|
|
pi, err := libp2p_peer.AddrInfoFromP2pAddr(ma.StringCast(traceFile)) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
tracer, _ := libp2p_pubsub.NewRemoteTracer(ctx, p2pHost, *pi) |
|
|
|
tracer, tracerErr = libp2p_pubsub.NewRemoteTracer(ctx, p2pHost, *pi) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if tracerErr == nil && tracer != nil { |
|
|
|
options = append(options, libp2p_pubsub.WithEventTracer(tracer)) |
|
|
|
options = append(options, libp2p_pubsub.WithEventTracer(tracer)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
utils.Logger().Info(). |
|
|
|
utils.Logger().Warn(). |
|
|
|
Str("RemoteTracer", traceFile). |
|
|
|
Str("Tracer", traceFile). |
|
|
|
Msg("can't get address from P2P_TRACEFILE") |
|
|
|
Msg("can't add event tracer from P2P_TRACEFILE") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|