Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockchain.atomicals.get_block_hash #174

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading