Esempio n. 1
0
 public override void ReadWriteCore(BitcoinStream stream)
 {
     stream.ReadWrite(ref version);
     using (stream.ProtocolVersionScope((ProtocolVersion)version))
     {
         stream.ReadWrite(ref services);
         stream.ReadWrite(ref timestamp);
         using (stream.ProtocolVersionScope(ProtocolVersion.CADDR_TIME_VERSION - 1))                //No time field in version message
         {
             stream.ReadWrite(ref addr_recv);
         }
         if (version >= 106)
         {
             using (stream.ProtocolVersionScope(ProtocolVersion.CADDR_TIME_VERSION - 1))                    //No time field in version message
             {
                 stream.ReadWrite(ref addr_from);
             }
             stream.ReadWrite(ref nonce);
             stream.ReadWrite(ref user_agent);
             if (version < 60002)
             {
                 if (user_agent.Length != 0)
                 {
                     throw new FormatException("Should not find user agent for current version " + version);
                 }
             }
             stream.ReadWrite(ref start_height);
             if (version >= 70001)
             {
                 stream.ReadWrite(ref relay);
             }
         }
     }
 }
Esempio n. 2
0
 public override void ReadWriteCore(BitcoinStream stream)
 {
     stream.ReadWrite(ref version);
     using (stream.ProtocolVersionScope(version))
     {
         stream.ReadWrite(ref services);
         stream.ReadWrite(ref timestamp);
         using (stream.SerializationTypeScope(SerializationType.Hash))                 //No time field in version message
         {
             stream.ReadWrite(ref addr_recv);
         }
         if (version >= 106)
         {
             using (stream.SerializationTypeScope(SerializationType.Hash))                     //No time field in version message
             {
                 stream.ReadWrite(ref addr_from);
             }
             stream.ReadWrite(ref nonce);
             stream.ReadWrite(ref user_agent);
             if (!stream.ProtocolCapabilities.SupportUserAgent)
             {
                 if (user_agent.Length != 0)
                 {
                     throw new FormatException("Should not find user agent for current version " + version);
                 }
             }
             stream.ReadWrite(ref start_height);
             if (version >= 70001)
             {
                 stream.ReadWrite(ref relay);
             }
         }
     }
 }
Esempio n. 3
0
 public override void ReadWriteCore(BitcoinStream stream)
 {
     using (stream.ProtocolVersionScope(NetworkAddress.AddrV2Format))
     {
         base.ReadWriteCore(stream);
     }
 }
Esempio n. 4
0
        public override void ReadWriteCore(BitcoinStream stream)
        {
            stream.ReadWrite(ref this.version);
            using (stream.ProtocolVersionScope((ProtocolVersion)this.version))
            {
                stream.ReadWrite(ref this.services);
                stream.ReadWrite(ref this.timestamp);

                // No time field in version message.
                using (stream.ProtocolVersionScope(ProtocolVersion.CADDR_TIME_VERSION - 1))
                {
                    stream.ReadWrite(ref this.addressReceiver);
                }

                if (this.version >= 106)
                {
                    // No time field in version message.
                    using (stream.ProtocolVersionScope(ProtocolVersion.CADDR_TIME_VERSION - 1))
                    {
                        stream.ReadWrite(ref this.addressFrom);
                    }

                    stream.ReadWrite(ref this.nonce);
                    stream.ReadWrite(ref this.userAgent);
                    if (this.version < 60002)
                    {
                        if (this.userAgent.Length != 0)
                        {
                            throw new FormatException("Should not find user agent for current version " + this.version);
                        }
                    }

                    stream.ReadWrite(ref this.startHeight);
                    if (this.version >= 70001)
                    {
                        stream.ReadWrite(ref this.relay);
                    }
                }
            }
        }
Esempio n. 5
0
		public override void ReadWriteCore(BitcoinStream stream)
		{
			stream.ReadWrite(ref version);
			using(stream.ProtocolVersionScope((ProtocolVersion)version))
			{
				stream.ReadWrite(ref services);
				stream.ReadWrite(ref timestamp);
				using(stream.ProtocolVersionScope(ProtocolVersion.CADDR_TIME_VERSION - 1)) //No time field in version message
				{
					stream.ReadWrite(ref addr_recv);
				}
				if(version >= 106)
				{
					using(stream.ProtocolVersionScope(ProtocolVersion.CADDR_TIME_VERSION - 1)) //No time field in version message
					{
						stream.ReadWrite(ref addr_from);
					}
					stream.ReadWrite(ref nonce);
					stream.ReadWrite(ref user_agent);
					if(version < 60002)
						if(user_agent.Length != 0)
							throw new FormatException("Should not find user agent for current version " + version);
					stream.ReadWrite(ref start_height);
					if(version >= 70001)
						stream.ReadWrite(ref relay);
				}
			}
		}