فهرست منبع

Merge remote-tracking branch 'origin/master'

drumstick-code 6 سال پیش
والد
کامیت
4a9362c20d
1فایلهای تغییر یافته به همراه15 افزوده شده و 40 حذف شده
  1. 15 40
      SEECBC-Test/datatype.py

+ 15 - 40
SEECBC-Test/datatype.py

@@ -3,7 +3,7 @@
 import os 
 from ecc import sha256d
 
-#A pointer to a transaction unspent output
+#指向为使用交易输出的指针
 class Pointer(tuple):
 
     def __new__(cls,tx_id,n):
@@ -16,13 +16,13 @@ class Pointer(tuple):
     @property
     def n(self):
         return self[1]
-    # XGY:重新打印时的方法,相当于String
+    #重新打印时的方法,相当于String
     def __repr__(self):
         return "Pointer(tx_id:{0},n:{1})".format(self[0],self[1])
     
     
     
-#value input for a transaction
+#交易输入
 class Vin(tuple):
 
     def __new__(cls,to_spend,signature,pubkey):
@@ -37,7 +37,7 @@ class Vin(tuple):
     def signature(self):
         return self[1]
 
-    #XGY: 公共密钥
+    #公共密钥
     @property
     def pubkey(self):
         return self[2]
@@ -50,7 +50,7 @@ class Vin(tuple):
         return "Vin(to_spend:{0},signature:{1},pubkey:{2})".format(self[0],self[1],self[2])
     
 
-#value output for a transaction
+#交易输出
 class Vout(tuple):
     
     def __new__(cls,to_addr,value):
@@ -73,7 +73,7 @@ class Vout(tuple):
     def __repr__(self):
         return "Vout(to_addr:{0},value:{1})".format(self[0],self[1])
 
-#unspent transation output
+#交易未使用输出
 class UTXO(tuple):
     
     def __new__(cls,
@@ -122,15 +122,11 @@ class UTXO(tuple):
         return "UTXO(vout:{0},pointer:{1})".format(self[0],self[1])
 
 
-#transaction
+#交易
 class Tx(tuple):
     
     def __new__(cls,tx_in,tx_out,fee=0,timestamp=0,nlocktime=0):
-        return super(Tx,cls).__new__(cls,(tx_in,
-                                          tx_out,
-                                          fee,
-                                          timestamp,
-                                          nlocktime))
+        return super(Tx,cls).__new__(cls,(tx_in,tx_out,fee,timestamp,nlocktime))
         
     @property
     def tx_in(self):
@@ -175,20 +171,10 @@ class Tx(tuple):
         return "Tx(id:{0})".format(self.id)
 
 
-#block
+#区块
 class Block(tuple): 
-    def __new__(cls,version,
-                prev_block_hash,
-                timestamp,
-                bits,
-                nonce,
-                txs):
-        return super(Block,cls).__new__(cls,(version,
-                                             prev_block_hash,
-                                             timestamp,
-                                             bits,
-                                             nonce,
-                                             txs))
+    def __new__(cls,version,prev_block_hash,timestamp, bits,nonce,txs):
+        return super(Block,cls).__new__(cls,(version,prev_block_hash,timestamp,bits,nonce,txs))
         
     
     @property
@@ -220,14 +206,9 @@ class Block(tuple):
         return self.get_merkle_root()
 
     def _replace(self,nonce = 0):
-        return Block(self[0],
-                     self[1],
-                     self[2],
-                     self[3],
-                     nonce,
-                     self[5])
-
-    #XGY: 可信签名树,用于签名认证
+        return Block(self[0],self[1],self[2],self[3],nonce,self[5])
+
+    #可信签名树,用于签名认证
     def get_merkle_root(self):
         return get_merkle_root_of_txs(self.txs) if self.txs else None
     
@@ -235,12 +216,7 @@ class Block(tuple):
         if merkle_root_hash is None:
             merkle_root_hash = self.get_merkle_root()
             
-        return "{0}{1}{2}{3}{4}{5}".format(self[0],
-                                           self[1],
-                                           self[2],
-                                           self[3],
-                                           merkle_root_hash,
-                                           nonce or self[4])
+        return "{0}{1}{2}{3}{4}{5}".format(self[0],self[1],self[2],self[3],merkle_root_hash,nonce or self[4])
 
     @property
     def hash(self):
@@ -256,7 +232,6 @@ def get_merkle_root_of_txs(txs):
 
 
 def get_merkle_root(level):
-    
     while len(level) != 1:
         odd = None
         if len(level) % 2 == 1: