public override Task <HandShakeReply> CrossChainHandShake(HandShake request, ServerCallContext context) { Logger.LogDebug($"Received shake from chain {ChainHelper.ConvertChainIdToBase58(request.ChainId)}."); if (!GrpcUriHelper.TryParsePrefixedEndpoint(context.Peer, out IPEndPoint peerEndpoint)) { return(Task.FromResult(new HandShakeReply { Status = HandShakeReply.Types.HandShakeStatus.InvalidHandshakeRequest })); } _ = PublishCrossChainRequestReceivedEvent(peerEndpoint.Address.ToString(), request.ListeningPort, request.ChainId); return(Task.FromResult(new HandShakeReply { Status = HandShakeReply.Types.HandShakeStatus.Success })); }
public void GrpcUrl_ParseTest() { //wrong format { string address = "127.0.0.1:8000"; var parsed = GrpcUriHelper.TryParsePrefixedEndpoint(address, out var endpoint); parsed.ShouldBeFalse(); endpoint.ShouldBeNull(); } //correct format { string address = "ipv4:127.0.0.1:8000"; var parsed = GrpcUriHelper.TryParsePrefixedEndpoint(address, out var endpoint); parsed.ShouldBeTrue(); endpoint.ToString().ShouldBe("127.0.0.1:8000"); endpoint.Port.ShouldBe(8000); } }