-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bb040e
commit 17db013
Showing
6 changed files
with
110 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "hypersync" | ||
version = "0.7.7" | ||
version = "0.7.8" | ||
edition = "2021" | ||
|
||
[lib] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import hypersync | ||
import asyncio | ||
from hypersync import BlockField, JoinMode, TransactionField, LogField, ClientConfig | ||
|
||
async def main(): | ||
client = hypersync.HypersyncClient(ClientConfig(url="http://167.235.0.227:2104")) | ||
|
||
# The query to run | ||
query = hypersync.Query( | ||
# only get block 20224332 | ||
from_block=20224332, | ||
to_block=20224333, | ||
include_all_blocks=True, | ||
join_mode=JoinMode.JOIN_ALL, | ||
field_selection=hypersync.FieldSelection( | ||
block=[BlockField.NUMBER, BlockField.TIMESTAMP, BlockField.HASH], | ||
log=[ | ||
LogField.LOG_INDEX, | ||
LogField.TRANSACTION_INDEX, | ||
LogField.TRANSACTION_HASH, | ||
LogField.DATA, | ||
LogField.ADDRESS, | ||
LogField.TOPIC0, | ||
LogField.TOPIC1, | ||
LogField.TOPIC2, | ||
LogField.TOPIC3, | ||
], | ||
transaction=[ | ||
TransactionField.BLOCK_NUMBER, | ||
TransactionField.TRANSACTION_INDEX, | ||
TransactionField.HASH, | ||
TransactionField.FROM, | ||
TransactionField.TO, | ||
TransactionField.VALUE, | ||
TransactionField.INPUT, | ||
] | ||
), | ||
|
||
) | ||
|
||
print("Running the query...") | ||
|
||
# Run the query once, the query is automatically paginated so it will return when it reaches some limit (time, response size etc.) | ||
# there is a next_block field on the response object so we can set the from_block of our query to this value and continue our query until | ||
# res.next_block is equal to res.archive_height or query.to_block in case we specified an end block. | ||
res = await client.get(query) | ||
|
||
print(f"Ran the query once. Next block to query is {res.next_block}") | ||
|
||
print(len(res.data.blocks)) | ||
print(len(res.data.transactions)) | ||
print(len(res.data.logs)) | ||
|
||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters