Exemplo n.º 1
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);
                 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)
         {
         }
     }
 }
Exemplo n.º 2
0
        public void ReadWrite(uint256 value)
        {
            value = value ?? uint256.Zero;
            var v = new uint256.MutableUint256(value);

            this.ReadWrite(ref v);
            value = v.Value;
        }