fix: add 5 seconds timeout context when installing stickers

This commit is contained in:
Michal Iskierko 2022-12-30 21:09:42 +01:00 committed by Michał Iskierko
parent 77a56e2b93
commit d95b259777
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package stickers
import (
"context"
"math/big"
"time"
"github.com/zenthangplus/goccm"
"olympos.io/encoding/edn"
@ -24,6 +25,7 @@ import (
)
const maxConcurrentRequests = 3
const requestTimeout = time.Duration(5) * time.Second
// ConnectionType constants
type stickerStatus int
@ -297,8 +299,11 @@ func (api *API) fetchStickerPacks(chainID uint64, resultChan chan<- *StickerPack
}
func (api *API) fetchPackData(stickerType *stickers.StickerType, packID *big.Int, translateHashes bool) (*StickerPack, error) {
callOpts := &bind.CallOpts{Context: api.ctx, Pending: false}
timeoutContext, timeoutCancel := context.WithTimeout(api.ctx, requestTimeout)
defer timeoutCancel()
callOpts := &bind.CallOpts{Context: timeoutContext, Pending: false}
packData, err := stickerType.GetPackData(callOpts, packID)
if err != nil {
return nil, err