Skip to content

Commit

Permalink
add GetChunkEnableCompression & GetBatchEnableCompression
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Oct 11, 2024
1 parent ef5ea6e commit 9d9fd89
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions encoding/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,39 @@ func CheckBatchCompressedDataCompatibility(batch *Batch, codecVersion CodecVersi
}
return codec.CheckBatchCompressedDataCompatibility(batch)
}

// GetChunkEnableCompression returns whether to enable compression for the given block height and timestamp.
func GetChunkEnableCompression(codecVersion CodecVersion, chunk Chunk) (bool, error) {
switch codecVersion {
case CodecV0:
return false, nil
case CodecV1:
return false, nil
case CodecV2:
return true, nil
case CodecV3:
return true, nil
case CodecV4:
return CheckChunkCompressedDataCompatibility(&chunk, codecVersion)
default:
return false, fmt.Errorf("unsupported codec version: %v", codecVersion)
}
}

// GetBatchEnableCompression returns whether to enable compression for the given block height and timestamp.
func GetBatchEnableCompression(codecVersion CodecVersion, batch Batch) (bool, error) {
switch codecVersion {
case CodecV0:
return false, nil
case CodecV1:
return false, nil
case CodecV2:
return true, nil
case CodecV3:
return true, nil
case CodecV4:
return CheckBatchCompressedDataCompatibility(&batch, codecVersion)
default:
return false, fmt.Errorf("unsupported codec version: %v", codecVersion)
}
}

0 comments on commit 9d9fd89

Please sign in to comment.