Skip to content

Conversation

jadepark-dev
Copy link
Collaborator

No description provided.


// TODO: can this scale?
type EventContainer struct {
Event any `tlb:"[CounterResetEvent,CounterIncrementEvent]"`
Copy link
Collaborator Author

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{})

Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@jadepark-dev jadepark-dev Jun 16, 2025

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! :)

Copy link
Collaborator Author

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cursors for batch polling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants