Пример #1
0
 public static void EncodeTransaction(Stream stream, Transaction tx)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.Write4Bytes(tx.Version);
         writer.EncodeList(tx.Inputs, input => EncodeTxInput(stream, input));
         writer.EncodeList(tx.Outputs, output => EncodeTxOutput(stream, output));
         writer.Write4Bytes(tx.LockTime);
     }
 }
Пример #2
0
 public static void EncodeInventoryPayload(Stream stream, InventoryPayload invPayload)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.EncodeList(invPayload.InventoryVectors, invVector => EncodeInventoryVector(stream, invVector));
     }
 }
Пример #3
0
 public static void EncodeBlock(Stream stream, Block block)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         EncodeBlockHeader(stream, block.Header);
         writer.EncodeList(block.Transactions, tx => EncodeTransaction(stream, tx));
     }
 }
Пример #4
0
 public static void EncodeGetBlocksPayload(Stream stream, GetBlocksPayload getBlocksPayload)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.Write4Bytes(getBlocksPayload.Version);
         writer.EncodeList(getBlocksPayload.BlockLocatorHashes, locatorHash => writer.Write32Bytes(locatorHash));
         writer.Write32Bytes(getBlocksPayload.HashStop);
     }
 }
Пример #5
0
 public static void EncodeAddressPayload(Stream stream, AddressPayload addressPayload)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.EncodeList(addressPayload.NetworkAddresses, networkAddress => EncodeNetworkAddressWithTime(stream, networkAddress));
     }
 }