Skip to content

Conversation

@k-karuna
Copy link
Member

No description provided.


func (indexer *Indexer) getNewBlocks(ctx context.Context) error {
head, err := indexer.receiver.Head(ctx)
commonReceiver, ok := indexer.receiver.(*receiver.Receiver)
Copy link
Member

Choose a reason for hiding this comment

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

Как будто эту проверку можно перенести в начало sync метода. getNewBlocks только там и вызывается

return traces, nil
}

func getTxTraces(traces []api.TraceResponse, txIndex uint) []api.TraceResponse {
Copy link
Member

Choose a reason for hiding this comment

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

Как ни странно, но здесь могут помочь итераторы =) не уверен, что будет выглядеть чище, но можешь посмотреть при желании


for invokationIndex := range flatInvocations {
invocation := flatInvocations[invokationIndex]
calldata := make([]data.Felt, len(invocation.Calldata))
Copy link
Member

Choose a reason for hiding this comment

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

можно сделать какую-нибудь вспомогательную функцию для перевода []string -> []data.Felt. Часто встречается

return current
}

func filterEventsByAddress(events []api.Event, targetAddress []int) []api.Event {
Copy link
Member

Choose a reason for hiding this comment

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

тоже очень похоже на итераторы

return response.Body().AsString()
}

func (s *Subsquid) GetBlocks(_ context.Context, from, to uint64, workerUrl string) ([]*SqdBlockResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Используй контекст workerClient.Context().Set()

import "github.com/dipdup-io/starknet-go-api/pkg/data"

func (block *SqdBlockResponse) GetDeployContractAddress(txIndex uint) data.Felt {
for _, trace := range block.Traces {
Copy link
Member

Choose a reason for hiding this comment

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

Сделай итерацию по индексу лучше

if value == nil {
return ""
}
return data.Felt(fmt.Sprintf("%d", *value))
Copy link
Member

Choose a reason for hiding this comment

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

вроде через %x надо сделать

@k-karuna k-karuna merged commit f2ff7f8 into master Mar 13, 2025
5 checks passed
@k-karuna k-karuna deleted the feat/subsquid-datasource branch March 13, 2025 14:58
@dmirgaleev dmirgaleev mentioned this pull request Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants