public void ReadWrite(uint256 value)
        {
            value = value ?? uint256.Zero;
            var v = new uint256.MutableUint256(value);

            this.ReadWrite(ref v);
            value = v.Value;
        }
Beispiel #2
0
        public void Load(BitcoinStream stream)
        {
            using (@lock.LockWrite())
            {
                try
                {
                    int height = 0;
                    while (true)
                    {
                        uint256.MutableUint256 id = null;
                        stream.ReadWrite <uint256.MutableUint256>(ref id);
                        BlockHeader header = null;
                        stream.ReadWrite(ref header);
                        PosParameters posParameters = null;
                        stream.ReadWrite(ref posParameters);
                        header.PosParameters = posParameters;

                        if (height == 0)
                        {
                            _BlocksByHeight.Clear();
                            _BlocksById.Clear();
                            _Tip = null;
                            SetTipNoLock(new ChainedBlock(header, 0));
                        }
                        else
                        {
                            SetTipNoLock(new ChainedBlock(header, id.Value, Tip));
                        }
                        height++;
                    }
                }
                catch (EndOfStreamException)
                {
                }
            }
        }