You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

rs.go 541 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package ec
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/baohan10/reedsolomon"
  6. )
  7. type rs struct {
  8. r *(reedsolomon.ReedSolomon)
  9. ecN int
  10. ecK int
  11. ecP int
  12. }
  13. func NewRsEnc(ecK int, ecN int) *rs {
  14. enc := rs{
  15. ecN: ecN,
  16. ecK: ecK,
  17. ecP: ecN - ecK,
  18. }
  19. enc.r = reedsolomon.GetReedSolomonIns(ecK, ecN)
  20. return &enc
  21. }
  22. func (r *rs) Encode(all [][]byte) {
  23. r.r.Encode(all)
  24. }
  25. func (r *rs) Repair(all [][]byte) error {
  26. return r.r.Reconstruct(all)
  27. }
  28. func checkErr(err error) {
  29. if err != nil {
  30. fmt.Fprintf(os.Stderr, "Error: %s", err.Error())
  31. }
  32. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。