Uint64ToByteStreamLe() публичный статический Метод

public static Uint64ToByteStreamLe ( ulong val, Stream stream ) : void
val ulong
stream Stream
Результат void
Пример #1
0
 /// <exception cref="IOException"/>
 public override void BitcoinSerializeToStream(Stream stream)
 {
     Debug.Assert(_scriptBytes != null);
     Utils.Uint64ToByteStreamLe(Value, stream);
     // TODO: Move script serialization into the Script class, where it belongs.
     stream.Write(new VarInt((ulong)_scriptBytes.Length).Encode());
     stream.Write(_scriptBytes);
 }
Пример #2
0
        /// <exception cref="IOException"/>
        public override void BitcoinSerializeToStream(Stream buf)
        {
            Utils.Uint32ToByteStreamLe(ClientVersion, buf);
            Utils.Uint64ToByteStreamLe(LocalServices, buf);
            Utils.Uint64ToByteStreamLe(Time, buf);
            // My address.
            MyAddr.BitcoinSerializeToStream(buf);
            // Their address.
            TheirAddr.BitcoinSerializeToStream(buf);
            // Next up is the "local host nonce", this is to detect the case of connecting
            // back to yourself. We don't care about this as we won't be accepting inbound
            // connections.
            Utils.Uint64ToByteStreamLe(_localHostNonce, buf);
            // Now comes subVer.
            var subVerBytes = Encoding.UTF8.GetBytes(SubVer);

            buf.Write(new VarInt((ulong)subVerBytes.Length).Encode());
            buf.Write(subVerBytes);
            // Size of known block chain.
            Utils.Uint32ToByteStreamLe(BestHeight, buf);
        }
Пример #3
0
        /// <exception cref="IOException"/>
        public override void BitcoinSerializeToStream(Stream stream)
        {
            if (ProtocolVersion >= 31402)
            {
                var secs = UnixTime.ToUnixTime(DateTime.UtcNow);
                Utils.Uint32ToByteStreamLe((uint)secs, stream);
            }
            Utils.Uint64ToByteStreamLe(_services, stream); // nServices.
            // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by hand.
            var ipBytes = Addr.GetAddressBytes();

            if (ipBytes.Length == 4)
            {
                var v6Addr = new byte[16];
                Array.Copy(ipBytes, 0, v6Addr, 12, 4);
                v6Addr[10] = 0xFF;
                v6Addr[11] = 0xFF;
                ipBytes    = v6Addr;
            }
            stream.Write(ipBytes);
            // And write out the port. Unlike the rest of the protocol, address and port is in big endian byte order.
            stream.Write((byte)(Port >> 8));
            stream.Write((byte)Port);
        }