/// <summary> /// Gets a multiaddress that ends with the peer ID. /// </summary> /// <param name="peerId"> /// The peer ID to end the multiaddress with. /// </param> /// <returns> /// Either the <c>this</c> multiadddress when it contains the /// <paramref name="peerId"/> or a new <see cref="MultiAddress"/> /// ending the <paramref name="peerId"/>. /// </returns> /// <exception cref="Exception"> /// When the mulltiaddress has the wrong peer ID. /// </exception> public MultiAddress WithPeerId(MultiHash peerId) { if (!HasPeerId) { return(new MultiAddress(ToString() + $"/p2p/{peerId}")); } var id = PeerId; if (id != peerId) { throw new Exception($"Expected a multiaddress with peer ID of '{peerId}', not '{id}'."); } return(this); }
public override void ReadValue(CodedInputStream stream) { stream.ReadLength(); MultiHash = new MultiHash(stream); Value = MultiHash.ToBase58(); }
public override void ReadValue(TextReader stream) { base.ReadValue(stream); MultiHash = new MultiHash(Value); }