-
Notifications
You must be signed in to change notification settings - Fork 2
[DO NOT MERGE - POC] Tolk event parsing with tonutils-go #50
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
Conversation
pkg/logpoller/poc/events.go
Outdated
|
||
// TODO: can this scale? | ||
type EventContainer struct { | ||
Event any `tlb:"[CounterResetEvent,CounterIncrementEvent]"` |
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.
Note: this enables generic event parsing, but we need to register events first
tlb.RegisterWithName("CounterResetEvent", poc.CounterResetEvent{})
tlb.RegisterWithName("CounterIncrementEvent", poc.CounterIncrementEvent{})
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.
This assumes we'll have a magic prefix on each event. I think we'll encode events without the prefix and instead use the prefix as a topic ID
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.
fun emit<T>(topic: int, body: T) {
val emitMsg = createExternalLogMessage({
dest: ExtOutLogBucket { topic },
body
});
emitMsg.send(SEND_MODE_REGULAR);
}
e.g. here: Tolk allows us to specify a bucket topic and it's specifically meant to be used by indexers
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.
I'm not sure how to get this topic without making a patch to tonutils though, it seems to parse as address https://github.com/xssnick/tonutils-go/blob/3d1c8457c2b806acb3498450b400e8738f1c03a2/tlb/message.go#L72
I think it ends up being some custom address value
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.
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.
external indexers can index your emitted logs by destination address without parsing body
@archseer This is interesting, thank you for the finding! :)
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.
Looks good, removed magic field
DEBUG: Source address: EQCvrm2qN-FHaljS7XtuvDracSB805A3WgBj0jpNKwgM0OYD
DEBUG: Dest address: EXT:110000010000000000000000000000000000000000000000000000000000000000000003e9
DEBUG: Body size: 299 bits
DEBUG: Raw body (BOC hex): b5ee9c7241010101002800004b685092508005f0bef1245290a21c3107461fd538f44184ea07cac86f5a6e4183533e8b850230a9793b1d
DEBUG: Address data (hex): 00000000000000000000000000000000000000000000000000000000000003e9, extracted topic: 1001
DEBUG: Extracted topic: 1001
} | ||
|
||
lastHash := acc.LastTxHash | ||
lastLt := acc.LastTxLT |
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.
cursors for batch polling
No description provided.