예제 #1
0
 internal void SaveToStream(BinaryWriter bw, bool saveHash = true, bool proto1 = false)
 {
     bw.Write(BlockNumber);
     if (!proto1)
     {
         AccountKey.SaveToStream(bw.BaseStream, false);
         bw.Write(Reward);
         bw.Write(Fee);
         bw.Write(ProtocolVersion);
         bw.Write(AvailableProtocol);
         bw.Write(Timestamp);
         bw.Write(CompactTarget);
         bw.Write(Nonce);
         Payload.SaveToStream(bw);
         CheckPointHash.SaveToStream(bw);
         TransactionHash.SaveToStream(bw);
         ProofOfWork.SaveToStream(bw);
     }
     for (int i = 0; i < 5; i++)
     {
         Accounts[i].SaveToStream(bw, saveHash, !proto1);
     }
     if (proto1)
     {
         bw.Write(Timestamp);
     }
     if (saveHash)
     {
         BlockHash.SaveToStream(bw);
     }
     if (!proto1)
     {
         bw.Write(AccumulatedWork);
     }
 }
예제 #2
0
 internal virtual void SaveToStream(Stream s)
 {
     using (var bw = new BinaryWriter(s, Encoding.ASCII, true))
     {
         bw.Write(BlockSignature);
         bw.Write(ProtocolVersion);
         bw.Write(AvailableProtocol);
         bw.Write(BlockNumber);
         if (AccountKey == null)
         {
             bw.Write((ushort)6);
             bw.Write((ushort)0);
             bw.Write((ushort)0);
             bw.Write((ushort)0);
         }
         else
         {
             AccountKey.SaveToStream(s);
         }
         bw.Write(Reward);
         bw.Write(Fee);
         bw.Write(Timestamp);
         bw.Write(CompactTarget);
         bw.Write(Nonce);
         Payload.SaveToStream(bw);
         CheckPointHash.SaveToStream(bw);
         TransactionHash.SaveToStream(bw);
         ProofOfWork.SaveToStream(bw);
     }
 }
예제 #3
0
 public Hash GetPart3()
 {
     using (BinaryWriter bw = new BinaryWriter(new MemoryStream()))
     {
         CheckPointHash.SaveToStream(bw, false);
         TransactionHash.SaveToStream(bw, false);
         bw.Write((uint)Fee);
         return((bw.BaseStream as MemoryStream)?.ToArray());
     }
 }
 internal override void SaveToStream(Stream s)
 {
     base.SaveToStream(s);
     using (BinaryWriter bw = new BinaryWriter(s, Encoding.Default, true))
     {
         DataLength = 4 + 2 + 32 + 4 + 4;
         bw.Write(DataLength);
         bw.Write(CheckPointBlockCount);
         CheckPointHash.SaveToStream(bw);
         bw.Write(StartBlock);
         bw.Write(EndBlock);
     }
 }