-
Notifications
You must be signed in to change notification settings - Fork 65
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
feat: improve chainhook-sdk interface #608
Conversation
removed - `cache_path`, `data_handler_tx`, and`ingestion_port` renamed - `display_logs` -> `display_stacks_ingestion_logs`
`*ChainhookFullSpecification` => `*ChainhookSpecificationNetworkMap` `*ChainhookNetworkSpecification` => `*ChainhookSpecification` `*ChainhookSpecification` => `*ChainhookInstance`
remove unnecessary wrapper around ChainhookStore
BlockCommit = '[' as u8, | ||
KeyRegister = '^' as u8, | ||
StackStx = 'x' as u8, | ||
PreStx = 'p' as u8, | ||
TransferStx = '$' as u8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason in the codebase to truncate 4 bytes (chars) to 1 byte (u8)? Consider using a byte literal b'['
, for instance, for those ASCII characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MicaiahReid I should have provided more information from the start, sorry.
Using a byte literal clarifies the code's intent: only ASCII characters are allowed for StacksOpcodes
. Any non-ASCII character, like ∞
, will be rejected. Casting types allows to truncate NON-ASCII chars like '∞' as u8
.
Other thing I am considering in this case is the runtime performance. StacksOpcodes
is used by the indexer, inside a loop. The overhead of casting '[' as u8
involves a runtime operation to convert the char to u8. This is not a super-heavy operation but is being performed inside a loop in a performance-critical section, thus the difference might become more noticeable.
I'm unsure of the exact impact on the indexer's performance, but any code involving it should consider performance optimization, in my opinion (maybe I'm getting a bit too performance-obsessed lately, thanks to working on Clarity-Wasm... 😛 ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csgui Thanks for the explanation! I've applied your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall refactoring implemented in this PR looks good. Just left some comments to be addressed.
@csgui, I'm not quite following you on this one - what's the difference between |
Can we merge this @MicaiahReid? |
done fixes according to this pull to chainhook-sdk(hirosystems/chainhook#608)
done fixes according to this pull to chainhook-sdk(hirosystems/chainhook#608)
Description
The goal of this PR is to make it much easier to use the Chainhook SDK. Previously, there were many fields that are rarely needed for the average user which had to be set when configuring the SDK. Many of these fields had confusing names that made it difficult to know how they were used in the SDK. Additionally, many of these fields were only needed for observing stacks events, but bitcoin-only users had to specify them anyways.
This has a few major changes to the Chainhook SDK:
cache_path
,data_handler_tx
, andingestion_port
) (694fb4d)display_logs
->display_stacks_ingestion_logs
(694fb4d)EventObserverConfigOverrides
->StacksEventObserverConfigBuilder
(9da1178)ingestion_port
->chainhook_stacks_block_ingestion_port
forStacksEventObserverConfigBuilder
(4e997fc)BitcoinEventObserverConfigBuilder
(fc67dff)*ChainhookFullSpecification
=>*ChainhookSpecificationNetworkMap
*ChainhookNetworkSpecification
=>*ChainhookSpecification
*ChainhookSpecification
=>*ChainhookInstance
ChainhookConfig
->ChainhookStore
(c54b6e7)EventObserverBuilder
to make a clean interface for starting an event observer (fe04dd9)Breaking change?
This will break some aspects of the Chainhook SDK. It should be a simple upgrade:
::new(..)
to build any of the above structs with fields that are removed, you may need to remove some fieldsExample
New code example to start a bitcoin event observer:
Previous usage of starting a bitcoin observer
Fixes #598