Skip to content

Commit 4e8dc12

Browse files
author
Vedran
committed
Bug fixes
1 parent 77efaab commit 4e8dc12

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

blockchain/blockchaindata.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def get_block(block_id, api_code = None):
77
resource += '?api_code=' + api_code
88
response = util.call_api(resource)
99
json_response = json.loads(response)
10-
return parse_block(json_response)
10+
return Block(json_response)
1111

1212
def get_tx(tx, api_code = None):
1313
resource = 'rawtx/' + tx
@@ -23,7 +23,7 @@ def get_block_height(height, api_code = None):
2323
resource += '&api_code=' + api_code
2424
response = util.call_api(resource)
2525
json_response = json.loads(response)
26-
return [parse_block(b) for b in json_response['blocks']]
26+
return [Block(b) for b in json_response['blocks']]
2727

2828
def get_address(address, api_code = None):
2929
resource = 'rawaddr/' + address
@@ -79,16 +79,6 @@ def get_inventory_data(hash, api_code = None):
7979
response = util.call_api(resource)
8080
json_response = json.loads(response)
8181
return InventoryData(json_response)
82-
83-
def parse_block(b):
84-
block_height = b['height']
85-
txs = [Transaction(t) for t in b['tx']]
86-
for tx in txs:
87-
tx.block_height = block_height
88-
return Block(b['hash'], b['ver'], b['prev_block'], b['mrkl_root'], b['time'], b['bits'],
89-
b['fee'], b['nonce'], b['n_tx'], b['size'], b['block_index'], b['main_chain'],
90-
b['height'], b.get('received_time'), b.get('relayed_by'), txs)
91-
9282

9383
class SimpleBlock:
9484
def __init__(self, b):
@@ -186,8 +176,8 @@ def __init__(self, b):
186176
self.received_time = b.get('received_time', b['time'])
187177
self.relayed_by = b.get('relayed_by')
188178
self.transactions = [Transaction(t) for t in b['tx']]
189-
for tx in txs:
190-
tx.block_height = block_height
179+
for tx in self.transactions:
180+
tx.block_height = self.height
191181

192182
class InventoryData:
193183
def __init__(self, i):

0 commit comments

Comments
 (0)