コード例 #1
0
        internal static RequestMessage FromReader(Address address, string host, BinaryReader reader)
        {
            var kind      = (RequestKind)reader.ReadByte();
            var nexusName = reader.ReadVarString();
            var msg       = new RequestMessage(address, host, kind, nexusName);

            if (kind.HasFlag(RequestKind.Blocks))
            {
                var count   = reader.ReadVarInt();
                var fetches = new Dictionary <string, RequestRange>();
                while (count > 0)
                {
                    var key   = reader.ReadVarString();
                    var start = reader.ReadBigInteger();
                    var end   = reader.ReadBigInteger();
                    fetches[key] = new RequestRange(start, end);
                    count--;
                }

                msg.SetBlocks(fetches);
            }

            return(msg);
        }
コード例 #2
0
        public void AddBlockRange(Chain chain, RequestRange range)
        {
            var count = (uint)(1 + range.End - range.Start);

            AddBlockRange(chain, range.Start, count);
        }