示例#1
0
 public static NetAddr Read(BitcoinStreamReader reader)
 {
     uint timestamp = reader.ReadUInt32();
     ulong services = reader.ReadUInt64();
     IPAddress address = reader.ReadAddress();
     ushort port = reader.ReadUInt16BigEndian();
     return new NetAddr(timestamp, services, address, port);
 }
        public static VersionMessage Read(BitcoinStreamReader reader)
        {
            int protocolVersion = reader.ReadInt32();
            ulong services = reader.ReadUInt64();
            long timestamp = reader.ReadInt64();

            ulong remoteServices = reader.ReadUInt64();
            IPAddress remoteAddress = reader.ReadAddress();
            ushort remotePort = reader.ReadUInt16BigEndian();
            IPEndPoint remoteEndpoint = new IPEndPoint(remoteAddress, remotePort);

            ulong localServices = reader.ReadUInt64();
            IPAddress localAddress = reader.ReadAddress();
            ushort localPort = reader.ReadUInt16BigEndian();
            IPEndPoint localEndpoint = new IPEndPoint(localAddress, localPort);

            ulong nonce = reader.ReadUInt64();

            string userAgent = reader.ReadText(MaxUserAgentLength);
            int startHeight = reader.ReadInt32();
            //todo: support clients that don't send relay bit
            bool acceptBroadcasts = reader.ReadBoolean();

            VersionMessage versionMessage = new VersionMessage(
                userAgent,
                protocolVersion,
                services,
                timestamp,
                nonce,
                localEndpoint,
                remoteEndpoint,
                startHeight,
                acceptBroadcasts);
            versionMessage.LocalServices = localServices;
            versionMessage.RemoteServices = remoteServices;
            return versionMessage;
        }