Skip to content

Commit

Permalink
blockchain.atomicals.get_block_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Apr 28, 2024
1 parent f37d361 commit 6d6e675
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions electrumx/server/http_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,12 @@ async def atomicals_num_to_id(self, request):
atomicals_num_to_id_map_reformatted[num] = location_id_bytes_to_compact(id)
return {'global': await self.get_summary_info(), 'result': atomicals_num_to_id_map_reformatted }

async def atomicals_block_hash(self, request):
params = await self.format_params(request)
height = params.get(0, self.session_mgr.bp.height)
block_hash = self.db.get_atomicals_block_hash(height)
return {'result': block_hash}

async def atomicals_block_txs(self, request):
params = await self.format_params(request)
height = params.get(0, "")
Expand Down
9 changes: 9 additions & 0 deletions electrumx/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ async def _start_servers(self, services):
app.router.add_get('/proxy/blockchain.atomicals.listscripthash', handler.atomicals_listscripthash)
app.router.add_get('/proxy/blockchain.atomicals.list', handler.atomicals_list)
app.router.add_get('/proxy/blockchain.atomicals.get_numbers', handler.atomicals_num_to_id)
app.router.add_get('/proxy/blockchain.atomicals.get_block_hash', handler.atomicals_block_hash)
app.router.add_get('/proxy/blockchain.atomicals.get_block_txs', handler.atomicals_block_txs)
app.router.add_get('/proxy/blockchain.atomicals.dump', handler.atomicals_dump)
app.router.add_get('/proxy/blockchain.atomicals.at_location', handler.atomicals_at_location)
Expand Down Expand Up @@ -334,6 +335,7 @@ async def _start_servers(self, services):
app.router.add_post('/proxy/blockchain.atomicals.listscripthash', handler.atomicals_listscripthash)
app.router.add_post('/proxy/blockchain.atomicals.list', handler.atomicals_list)
app.router.add_post('/proxy/blockchain.atomicals.get_numbers', handler.atomicals_num_to_id)
app.router.add_post('/proxy/blockchain.atomicals.get_block_hash', handler.atomicals_block_hash)
app.router.add_post('/proxy/blockchain.atomicals.get_block_txs', handler.atomicals_block_txs)
app.router.add_post('/proxy/blockchain.atomicals.dump', handler.atomicals_dump)
app.router.add_post('/proxy/blockchain.atomicals.at_location', handler.atomicals_at_location)
Expand Down Expand Up @@ -1544,6 +1546,12 @@ async def atomicals_num_to_id(self, limit, offset, asc):
atomicals_num_to_id_map_reformatted[num] = location_id_bytes_to_compact(id)
return {'global': await self.get_summary_info(), 'result': atomicals_num_to_id_map_reformatted }

async def atomicals_block_hash(self, height):
if not height:
height = self.session_mgr.bp.height
block_hash = self.db.get_atomicals_block_hash(height)
return {'result': block_hash}

async def atomicals_block_txs(self, height):
tx_list = self.session_mgr.bp.get_atomicals_block_txs(height)
return {'global': await self.get_summary_info(), 'result': tx_list }
Expand Down Expand Up @@ -3102,6 +3110,7 @@ def set_request_handlers(self, ptuple):
'blockchain.atomicals.listscripthash': self.atomicals_listscripthash,
'blockchain.atomicals.list': self.atomicals_list,
'blockchain.atomicals.get_numbers': self.atomicals_num_to_id,
'blockchain.atomicals.get_block_hash': self.atomicals_block_hash,
'blockchain.atomicals.get_block_txs': self.atomicals_block_txs,
'blockchain.atomicals.dump': self.atomicals_dump,
'blockchain.atomicals.at_location': self.atomicals_at_location,
Expand Down

0 comments on commit 6d6e675

Please sign in to comment.