Skip to content

Commit de3747a

Browse files
committed
pkg/config: add func SizeOf; pkg/settings: defaults/types/comments
1 parent e5da126 commit de3747a

6 files changed

Lines changed: 16 additions & 9 deletions

File tree

pkg/config/bytes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ var (
3232
}
3333
)
3434

35+
func SizeOf[B ~[]byte](bs ...B) (s Size) {
36+
for _, b := range bs {
37+
s += Size(len(b))
38+
}
39+
return
40+
}
41+
3542
func (b Size) MarshalText() ([]byte, error) {
3643
if b >= TByte {
3744
d := decimal.NewFromInt(int64(b)).Div(decimal.NewFromInt(int64(TByte)))

pkg/settings/cresettings/defaults.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"TargetsLimit": "3",
5959
"ReportSizeLimit": "1kb",
6060
"EVM": {
61-
"TransactionGasLimit": "-1"
61+
"TransactionGasLimit": "500000"
6262
}
6363
},
6464
"ChainRead": {

pkg/settings/cresettings/defaults.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TargetsLimit = '3'
6060
ReportSizeLimit = '1kb'
6161

6262
[PerWorkflow.ChainWrite.EVM]
63-
TransactionGasLimit = '-1'
63+
TransactionGasLimit = '500000'
6464

6565
[PerWorkflow.ChainRead]
6666
CallLimit = '3'

pkg/settings/cresettings/settings.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ var Default = Schema{
9191
TargetsLimit: Int(3),
9292
ReportSizeLimit: Size(config.KByte),
9393
EVM: evmChainWrite{
94-
TransactionGasLimit: Int(-1), //TODO
94+
TransactionGasLimit: Uint64(500_000),
9595
},
9696
},
9797
ChainRead: chainRead{
9898
CallLimit: Int(3),
99-
LogQueryBlockLimit: Int(100),
99+
LogQueryBlockLimit: Uint64(100),
100100
PayloadSizeLimit: Size(5 * config.KByte),
101101
},
102102
},
@@ -187,11 +187,11 @@ type chainWrite struct {
187187
EVM evmChainWrite
188188
}
189189
type evmChainWrite struct {
190-
TransactionGasLimit Setting[int] `unit:"{gas}"`
190+
TransactionGasLimit Setting[uint64] `unit:"{gas}"`
191191
}
192192

193193
type chainRead struct {
194-
CallLimit Setting[int] `unit:"{call}"`
195-
LogQueryBlockLimit Setting[int] `unit:"{block}"`
194+
CallLimit Setting[int] `unit:"{call}"`
195+
LogQueryBlockLimit Setting[uint64] `unit:"{block}"`
196196
PayloadSizeLimit Setting[config.Size]
197197
}

pkg/settings/cresettings/settings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ func TestSchema_Unmarshal(t *testing.T) {
109109
assert.Equal(t, config.Rate{Limit: rate.Every(13 * time.Second), Burst: 6}, cfg.PerWorkflow.LogTrigger.EventRateLimit.DefaultValue)
110110
assert.Equal(t, config.Rate{Limit: rate.Every(3 * time.Second), Burst: 5}, cfg.PerWorkflow.HTTPAction.RateLimit.DefaultValue)
111111
assert.Equal(t, 5*time.Minute, cfg.PerWorkflow.HTTPAction.CacheAgeLimit.DefaultValue)
112-
assert.Equal(t, 500000, cfg.PerWorkflow.ChainWrite.EVM.TransactionGasLimit.DefaultValue)
112+
assert.Equal(t, uint64(500000), cfg.PerWorkflow.ChainWrite.EVM.TransactionGasLimit.DefaultValue)
113113
assert.Equal(t, 3, cfg.PerWorkflow.ChainRead.CallLimit.DefaultValue)
114114
}

pkg/settings/limits/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type ResourceLimiter[N Number] interface {
2424
Use(ctx context.Context, amount N) error
2525
// Free is the counterpart to Use and releases amount of resources from use.
2626
Free(ctx context.Context, amount N) error
27-
// Available returns
27+
// Available returns the available remaining capacity.
2828
Available(ctx context.Context) (N, error)
2929
}
3030

0 commit comments

Comments
 (0)