Add Litecoin scrypt proof of work and use scrypt instead of hash256 if we are on...
[p2pool.git] / p2pool / bitcoin / data.py
index 473ea3a..e0c1d9a 100644 (file)
@@ -106,6 +106,13 @@ class Type(object):
     def hash256(self, obj):
         return HashType().unpack(hashlib.sha256(hashlib.sha256(self.pack(obj)).digest()).digest())
 
+    ltc_scrypt = None
+    def scrypt(self, obj):
+        # dynamically import ltc_scrypt so you will only get an error on runtime
+        if (not self.ltc_scrypt):
+            self.ltc_scrypt = __import__('ltc_scrypt')
+        return HashType().unpack(self.ltc_scrypt.getPoWHash(self.pack(obj)))
+
 class VarIntType(Type):
     # redundancy doesn't matter here because bitcoin and p2pool both reencode before hashing
     def read(self, file):