X-Git-Url: https://git.novaco.in/?p=NovacoinLibrary.git;a=blobdiff_plain;f=Novacoin%2FCBlock.cs;h=101d20ee6a613c3217e0922a131bff2e1de46ba9;hp=79d07d4569a483d416af640244230b2fe984912f;hb=161220f258cf9eb640d354951a48b45598301b1a;hpb=1f0b7fb3d5fc3969952610cebe1b173dbece722b diff --git a/Novacoin/CBlock.cs b/Novacoin/CBlock.cs index 79d07d4..101d20e 100644 --- a/Novacoin/CBlock.cs +++ b/Novacoin/CBlock.cs @@ -88,16 +88,25 @@ namespace Novacoin { try { - ByteQueue wBytes = new ByteQueue(ref blockBytes); + var stream = new MemoryStream(blockBytes); + var reader = new BinaryReader(stream); // Fill the block header fields - header = new CBlockHeader(wBytes.Get(80)); + header = new CBlockHeader(); + header.nVersion = reader.ReadUInt32(); + header.prevHash = new ScryptHash256(reader.ReadBytes(32)); + header.merkleRoot = new Hash256(reader.ReadBytes(32)); + header.nTime = reader.ReadUInt32(); + header.nBits = reader.ReadUInt32(); + header.nNonce = reader.ReadUInt32(); // Parse transactions list - vtx = CTransaction.ReadTransactionsList(ref wBytes); + vtx = CTransaction.ReadTransactionsList(ref reader); // Read block signature - signature = wBytes.Get((int)wBytes.GetVarInt()); + signature = reader.ReadBytes((int)VarInt.ReadVarInt(ref reader)); + + reader.Close(); } catch (Exception e) {