import warnings
from . import base58
-from p2pool.util import bases, expiring_dict, math
+from p2pool.util import bases, math
class EarlyEnd(Exception):
pass
data = self._pack(obj)
assert self._unpack(data) == obj
-
+
return data
def unpack_base58(self, base58_data):
return self.unpack(base58.base58_decode(base58_data))
-
+
def hash160(self, obj):
return ShortHashType().unpack(hashlib.new('ripemd160', hashlib.sha256(self.pack(obj)).digest()).digest())
def truncate_to(self, x):
return self._bits_to_target(self._target_to_bits(x, _check=False))
-
+
def _bits_to_target(self, bits2):
target = math.shift_left(bits2 & 0x00ffffff, 8 * ((bits2 >> 24) - 3))
assert target == self._bits_to_target1(struct.pack("<I", bits2))
bits = bits[::-1]
length = ord(bits[0])
return bases.string_to_natural((bits[1:] + "\0"*length)[:length])
-
+
def _target_to_bits(self, target, _check=True):
n = bases.natural_to_string(target)
if n and ord(n[0]) >= 128:
from __future__ import division
-import struct
-
from . import data as bitcoin_data
from . import sha256
('id', bitcoin_data.HashType()),
('order', bitcoin_data.FixedStrType(60)), # XXX
])
-
+
message_addr = bitcoin_data.ComposedType([
('addrs', bitcoin_data.ListType(bitcoin_data.ComposedType([
('timestamp', bitcoin_data.StructType('<I')),
def handle_reply(self, hash, reply, script):
self.check_order.got_response(hash, dict(reply=reply, script=script))
self.submit_order.got_response(hash, dict(reply=reply, script=script))
-
+
message_ping = bitcoin_data.ComposedType([])
def handle_ping(self):
pass
-
+
message_alert = bitcoin_data.ComposedType([
('message', bitcoin_data.VarStrType()),
('signature', bitcoin_data.VarStrType()),
previous_share2 = tracker.shares[previous_share_hash] if previous_share_hash is not None else None
#previous_share2 = chain.shares
#previous_shares
- #shares =
+ #shares =
#shares = (previous_share2.shares if previous_share2 is not None else [net.SCRIPT]*net.SPREAD)[1:-1] + [new_script, new_script]
lookbehind = 120
Returns:
{'result': 'okay', verified_height: ...} # if share has an okay parent or if share has CHAIN_LENGTH children and CHAIN_LENTH parents that it verified with
{'result': 'needs_share', 'share_hash': ...} # if share doesn't have CHAIN_LENGTH parents
- #{'result': 'needs_share_shares', 'share_hash': ...} # if share has CHAIN_LENGTH children and needs its shares to
+ #{'result': 'needs_share_shares', 'share_hash': ...} # if share has CHAIN_LENGTH children and needs its shares to
{'result': 'not_okay'} # if the share has a not okay parent or if the share has an okay parent and failed validation
'''
self.putChild('', self)
def rpc_getwork(self, data=None):
- try:
- if data is not None:
- return self.response_callback(data)
-
- return self.compute(self.work.value)
- except ValueError:
- traceback.print_exc()
+ try:
+ if data is not None:
+ return self.response_callback(data)
+
+ return self.compute(self.work.value)
+ except ValueError:
+ traceback.print_exc()