public ITransportDialer Dialer(Multiaddress laddr, TimeSpan?timeout = null, bool reusePort = true) { ITransportDialer d; if (_dialers.TryGetValue(laddr.ToString(), out d)) { return(d); } d = CreateDialer(laddr, timeout, reusePort); _dialers.TryAdd(laddr.ToString(), d); return(d); }
public ITransportListener Listen(Multiaddress laddr) { if (!Matches(laddr)) { throw new NotSupportedException($"Tcp transport cannot listen on {laddr}"); } ITransportListener l; if (_listeners.TryGetValue(laddr.ToString(), out l)) { return(l); } l = CreateListener(laddr); _listeners.TryAdd(laddr.ToString(), l); return(l); }
public void Add(Multiaddress address, Multiaddress observer) { Write(() => { if (_addresses == null) { _addresses = new Dictionary <string, ObservedAddress>(); _ttl = AddressManager.OwnObservedAddrTTL; } var s = address.ToString(); ObservedAddress oa; if (!_addresses.TryGetValue(s, out oa)) { oa = new ObservedAddress(address, new HashSet <string>()); _addresses.Add(s, oa); } oa.SeenBy.Add(ToObserverGroup(observer)); oa.LastSeen = DateTime.Now; }); }