Minor cleanup
authorCryptoManiac <balthazar.ad@gmail.com>
Mon, 17 Aug 2015 13:29:04 +0000 (16:29 +0300)
committerCryptoManiac <balthazar.ad@gmail.com>
Mon, 17 Aug 2015 13:29:04 +0000 (16:29 +0300)
Novacoin/CBlock.cs
Novacoin/CTransaction.cs
Novacoin/CTxIn.cs
Novacoin/CTxOut.cs

index f8b9e7e..4402480 100644 (file)
@@ -17,7 +17,7 @@ namespace Novacoin
                /// <summary>
                /// Transactions array.
                /// </summary>
-               public CTransaction[] tx;
+               public CTransaction[] vtx;
 
                /// <summary>
                /// Block header signature.
@@ -43,7 +43,7 @@ namespace Novacoin
             header.nNonce = Interop.LEBytesToUInt32(wBytes.GetItems(4));
 
             // Parse transactions list
-            tx = CTransaction.ReadTransactionsList(ref wBytes);
+            vtx = CTransaction.ReadTransactionsList(ref wBytes);
 
             // Read block signature
             signature = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
@@ -58,11 +58,11 @@ namespace Novacoin
             List<byte> r = new List<byte>();
 
             r.AddRange(header.ToBytes());
-            r.AddRange(VarInt.EncodeVarInt(tx.LongLength)); // transactions count
+            r.AddRange(VarInt.EncodeVarInt(vtx.LongLength)); // transactions count
 
-            foreach (CTransaction t in tx)
+            foreach (CTransaction tx in vtx)
             {
-                r.AddRange(t.ToBytes());
+                r.AddRange(tx.ToBytes());
             }
 
             r.AddRange(VarInt.EncodeVarInt(signature.LongLength));
@@ -77,14 +77,13 @@ namespace Novacoin
 
             sb.AppendFormat("CBlock(\n header={0},\n", header.ToString());
 
-            foreach(CTransaction t in tx)
+            foreach(CTransaction tx in vtx)
             {
-                sb.AppendFormat("{0}, \n", t.ToString());
+                sb.AppendFormat("{0},\n", tx.ToString());
             }
 
             sb.AppendFormat("signature={0})\n", Interop.ToHex(signature));
             
-
             // TODO
             return sb.ToString();
         }
index 6e40a0b..9ed33ca 100644 (file)
@@ -22,12 +22,12 @@ namespace Novacoin
                /// <summary>
                /// Array of transaction inputs
                /// </summary>
-               public CTxIn[] inputs;
+               public CTxIn[] vin;
 
                /// <summary>
                /// Array of transaction outputs
                /// </summary>
-               public CTxOut[] outputs;
+               public CTxOut[] vout;
 
                /// <summary>
                /// Block height or timestamp when transaction is final
@@ -53,28 +53,28 @@ namespace Novacoin
             nTime = Interop.LEBytesToUInt32(wBytes.GetItems(4));
 
             int nInputs = (int)VarInt.ReadVarInt(ref wBytes);
-            inputs = new CTxIn[nInputs];
+            vin = new CTxIn[nInputs];
 
             for (int nCurrentInput = 0; nCurrentInput < nInputs; nCurrentInput++)
             {
                 // Fill inputs array
-                inputs[nCurrentInput] = new CTxIn();
+                vin[nCurrentInput] = new CTxIn();
 
-                inputs[nCurrentInput].txID = new Hash256(wBytes.GetItems(32));
-                inputs[nCurrentInput].n = Interop.LEBytesToUInt32(wBytes.GetItems(4));
-                inputs[nCurrentInput].scriptSig = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
-                inputs[nCurrentInput].nSequence = Interop.LEBytesToUInt32(wBytes.GetItems(4));
+                vin[nCurrentInput].txID = new Hash256(wBytes.GetItems(32));
+                vin[nCurrentInput].n = Interop.LEBytesToUInt32(wBytes.GetItems(4));
+                vin[nCurrentInput].scriptSig = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
+                vin[nCurrentInput].nSequence = Interop.LEBytesToUInt32(wBytes.GetItems(4));
             }
 
             int nOutputs = (int)VarInt.ReadVarInt(ref wBytes);
-            outputs = new CTxOut[nOutputs];
+            vout = new CTxOut[nOutputs];
 
             for (int nCurrentOutput = 0; nCurrentOutput < nOutputs; nCurrentOutput++)
             {
                 // Fill outputs array
-                outputs[nCurrentOutput] = new CTxOut();
-                outputs[nCurrentOutput].nValue = Interop.LEBytesToUInt64(wBytes.GetItems(8));
-                outputs[nCurrentOutput].scriptPubKey = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
+                vout[nCurrentOutput] = new CTxOut();
+                vout[nCurrentOutput].nValue = Interop.LEBytesToUInt64(wBytes.GetItems(8));
+                vout[nCurrentOutput].scriptPubKey = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
             }
 
             nLockTime = Interop.LEBytesToUInt32(wBytes.GetItems(4));
@@ -102,10 +102,10 @@ namespace Novacoin
                 tx[nTx].nTime = Interop.LEBytesToUInt32(wTxBytes.GetItems(4));
 
                 // Inputs array
-                tx[nTx].inputs = CTxIn.ReadTxInList(ref wTxBytes);
+                tx[nTx].vin = CTxIn.ReadTxInList(ref wTxBytes);
 
                 // outputs array
-                tx[nTx].outputs = CTxOut.ReadTxOutList(ref wTxBytes);
+                tx[nTx].vout = CTxOut.ReadTxOutList(ref wTxBytes);
 
                 tx[nTx].nLockTime = Interop.LEBytesToUInt32(wTxBytes.GetItems(4));
             }
@@ -163,16 +163,16 @@ namespace Novacoin
 
             resultBytes.AddRange(Interop.LEBytes(nVersion));
             resultBytes.AddRange(Interop.LEBytes(nTime));
-            resultBytes.AddRange(VarInt.EncodeVarInt(inputs.LongLength));
+            resultBytes.AddRange(VarInt.EncodeVarInt(vin.LongLength));
 
-            foreach(CTxIn input in inputs)
+            foreach(CTxIn input in vin)
             {
                 resultBytes.AddRange(input.ToBytes());
             }
 
-            resultBytes.AddRange(VarInt.EncodeVarInt(outputs.LongLength));
+            resultBytes.AddRange(VarInt.EncodeVarInt(vout.LongLength));
             
-            foreach(CTxOut output in outputs)
+            foreach(CTxOut output in vout)
             {
                 resultBytes.AddRange(output.ToBytes());
             }
@@ -188,20 +188,19 @@ namespace Novacoin
 
             sb.AppendFormat("CTransaction(\n nVersion={0},\n nTime={1},\n", nVersion, nTime);
 
-            foreach (CTxIn txin in inputs)
+            foreach (CTxIn txin in vin)
             {
                 sb.AppendFormat(" {0},\n", txin.ToString());
             }
 
-            foreach (CTxOut txout in outputs)
+            foreach (CTxOut txout in vout)
             {
                 sb.AppendFormat(" {0},\n", txout.ToString());
             }
 
-            sb.AppendFormat("nLockTime={0})\n", nLockTime);
+            sb.AppendFormat("\nnLockTime={0}\n)", nLockTime);
 
             return sb.ToString();
         }
        }
 }
-
index 1f3017c..bc6850a 100644 (file)
@@ -104,11 +104,11 @@ namespace Novacoin
 
             if (IsCoinBase())
             {
-                sb.AppendFormat("CTxIn(txId={0},coinbase={2},nSequence={3})", txID.ToString(), n, Interop.ToHex(scriptSig), nSequence);
+                sb.AppendFormat("CTxIn(txId={0}, coinbase={2}, nSequence={3})", txID.ToString(), n, Interop.ToHex(scriptSig), nSequence);
             }
             else
             {
-                sb.AppendFormat("CTxIn(txId={0},n={1},scriptSig={2},nSequence={3})", txID.ToString(), n, (new CScript(scriptSig)).ToString(), nSequence);
+                sb.AppendFormat("CTxIn(txId={0}, n={1}, scriptSig={2}, nSequence={3})", txID.ToString(), n, (new CScript(scriptSig)).ToString(), nSequence);
             }
 
                        return sb.ToString ();
index eac9409..4f88955 100644 (file)
@@ -75,7 +75,7 @@ namespace Novacoin
                public override string ToString ()
                {
                        StringBuilder sb = new StringBuilder ();
-                       sb.AppendFormat ("CTxOut(nValue={0},scriptPubKey={1})", nValue, (new CScript(scriptPubKey)).ToString());
+                       sb.AppendFormat ("CTxOut(nValue={0}, scriptPubKey={1})", nValue, (new CScript(scriptPubKey)).ToString());
 
                        return sb.ToString ();
                }