Skip to content

Commit c9c7759

Browse files
authored
Merge pull request #222 from klim0v/dev-v19-SetCustomQueryIDFetcherWithContext
SetCustomQueryIDFetcherWithContext
2 parents 2ec0b5d + e3e497c commit c9c7759

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ton/wallet/highloadv2r2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type SpecHighloadV2R2 struct {
2222
SpecQuery
2323
}
2424

25-
func (s *SpecHighloadV2R2) BuildMessage(_ context.Context, messages []*Message) (*cell.Cell, error) {
25+
func (s *SpecHighloadV2R2) BuildMessage(ctx context.Context, messages []*Message) (*cell.Cell, error) {
2626
if len(messages) > 254 {
2727
return nil, errors.New("for this type of wallet max 254 messages can be sent in the same time")
2828
}
@@ -47,7 +47,7 @@ func (s *SpecHighloadV2R2) BuildMessage(_ context.Context, messages []*Message)
4747

4848
var ttl, queryID uint32
4949
if s.customQueryIDFetcher != nil {
50-
ttl, queryID = s.customQueryIDFetcher()
50+
ttl, queryID = s.customQueryIDFetcher(ctx)
5151
} else {
5252
queryID = randUint32()
5353
ttl = uint32(timeNow().Add(time.Duration(s.messagesTTL) * time.Second).UTC().Unix())

ton/wallet/regular.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ type SpecQuery struct {
5454
// Do not set ttl to high if you are sending many messages,
5555
// unexpired executed messages will be cached in contract,
5656
// and it may become too expensive to make transactions.
57-
customQueryIDFetcher func() (ttl uint32, randPart uint32)
57+
customQueryIDFetcher func(context.Context) (ttl uint32, randPart uint32)
5858
}
5959

6060
func (s *SpecQuery) SetCustomQueryIDFetcher(fetcher func() (ttl uint32, randPart uint32)) {
61+
s.SetCustomQueryIDFetcherWithContext(func(ctx context.Context) (ttl uint32, randPart uint32) {
62+
return fetcher()
63+
})
64+
}
65+
66+
func (s *SpecQuery) SetCustomQueryIDFetcherWithContext(fetcher func(ctx context.Context) (ttl uint32, randPart uint32)) {
6167
s.customQueryIDFetcher = fetcher
6268
}

0 commit comments

Comments
 (0)