Skip to content

Commit

Permalink
Compression manager sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed Feb 7, 2024
1 parent a7d257e commit 6bad716
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions compressor/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,27 @@ func NewCompressorManager(
updateInterval uint,
trailBlocks uint,
batchSize uint,
) *CompressorManager {
) (*CompressorManager, error) {
if userStorage {
if updateInterval == 0 {
return nil, fmt.Errorf("update interval must be greater than 0")
}

if batchSize == 0 {
return nil, fmt.Errorf("batch size must be greater than 0")
}
}

// Check if the contract exists
code, err := provider.CodeAt(context, contract, nil)
if err != nil {
return nil, err
}

if len(code) == 0 {
return nil, fmt.Errorf("contract %s does not exist", contract.Hex())
}

c := CompressorManager{
instance: &CompressorInstance{
Context: context,
Expand All @@ -68,7 +88,7 @@ func NewCompressorManager(

c.StartIndexUpdater()

return &c
return &c, nil
}

func (cm *CompressorManager) SetOnLoadedIndexes(f func(uint, uint)) {
Expand Down

0 comments on commit 6bad716

Please sign in to comment.