fix: add 5 seconds timeout context when installing stickers
This commit is contained in:
parent
77a56e2b93
commit
d95b259777
|
@ -3,6 +3,7 @@ package stickers
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/zenthangplus/goccm"
|
"github.com/zenthangplus/goccm"
|
||||||
"olympos.io/encoding/edn"
|
"olympos.io/encoding/edn"
|
||||||
|
@ -24,6 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxConcurrentRequests = 3
|
const maxConcurrentRequests = 3
|
||||||
|
const requestTimeout = time.Duration(5) * time.Second
|
||||||
|
|
||||||
// ConnectionType constants
|
// ConnectionType constants
|
||||||
type stickerStatus int
|
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) {
|
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)
|
packData, err := stickerType.GetPackData(callOpts, packID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue