/// <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.MultiHash peerId)
        {
            if (HasPeerId)
            {
                var id = PeerId;
                if (id != peerId)
                {
                    throw new Exception($"Expected a multiaddress with peer ID of '{peerId}', not '{id}'.");
                }

                return(this);
            }

            return(new MultiAddress(ToString() + $"/p2p/{peerId}"));
        }
示例#2
0
 public override void ReadValue(CodedInputStream stream)
 {
     stream.ReadLength();
     MultiHash = new MultiHash.MultiHash(stream);
     Value     = MultiHash.ToBase58();
 }
示例#3
0
 public override void ReadValue(TextReader stream)
 {
     base.ReadValue(stream);
     MultiHash = new MultiHash.MultiHash(Value);
 }