forked from TrueCloudLab/neoneo-go
core: restrict the maximum number of requests per URL
This commit is contained in:
parent
7c232e2ddc
commit
6685f8eba9
1 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,7 @@ package native
|
|||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
||||
|
@ -42,6 +43,8 @@ const (
|
|||
maxFilterLength = 128
|
||||
maxCallbackLength = 32
|
||||
maxUserDataLength = 512
|
||||
// maxRequestsCount is the maximum number of requests per URL
|
||||
maxRequestsCount = 256
|
||||
|
||||
oracleRequestPrice = 5000_0000
|
||||
)
|
||||
|
@ -329,6 +332,9 @@ func (o *Oracle) PutRequestInternal(id uint64, req *state.OracleRequest, d dao.D
|
|||
if err := o.getSerializableFromDAO(d, key, lst); err != nil && !errors.Is(err, storage.ErrKeyNotFound) {
|
||||
return err
|
||||
}
|
||||
if len(*lst) >= maxRequestsCount {
|
||||
return fmt.Errorf("there are too many pending requests for %s url", req.URL)
|
||||
}
|
||||
*lst = append(*lst, id)
|
||||
si := &state.StorageItem{Value: lst.Bytes()}
|
||||
return d.PutStorageItem(o.ContractID, key, si)
|
||||
|
|
Loading…
Reference in a new issue