diff --git a/configs/sys.go b/configs/sys.go index 5b32649..b8aea2e 100644 --- a/configs/sys.go +++ b/configs/sys.go @@ -1,7 +1,7 @@ package configs // type and version -const Version = "CESS-Bucket v0.4.0" +const Version = "CESS-Bucket v0.4.1" // rpc service and method const ( diff --git a/internal/chain/parameter.go b/internal/chain/parameter.go index 083a0da..9992c7e 100644 --- a/internal/chain/parameter.go +++ b/internal/chain/parameter.go @@ -114,3 +114,11 @@ type UserSpaceInfo struct { UsedSpace types.U128 RemainingSpace types.U128 } + +type ProveInfo struct { + FileId types.Bytes + MinerId types.U64 + Cinfo ChallengesInfo + Mu []types.Bytes + Sigma types.Bytes +} diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index 63b3c16..d4e9865 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -520,7 +520,7 @@ func GetAddressFromPrk(prk string, prefix []byte) (string, error) { } // -func PutProofToChain(signaturePrk string, id uint64, fid, sigma []byte, mu [][]byte) (int, error) { +func PutProofToChain(signaturePrk string, id uint64, data []ProveInfo) (int, error) { var ( err error accountInfo types.AccountInfo @@ -549,13 +549,13 @@ func PutProofToChain(signaturePrk string, id uint64, fid, sigma []byte, mu [][]b // return configs.Code_400, errors.Wrap(err, "[EncodeToBytes]") // } - var mus []types.Bytes = make([]types.Bytes, len(mu)) - for i := 0; i < len(mu); i++ { - mus[i] = make(types.Bytes, 0) - mus[i] = append(mus[i], mu[i]...) - } + // var mus []types.Bytes = make([]types.Bytes, len(mu)) + // for i := 0; i < len(mu); i++ { + // mus[i] = make(types.Bytes, 0) + // mus[i] = append(mus[i], mu[i]...) + // } - c, err := types.NewCall(meta, SegmentBook_SubmitProve, types.U64(id), types.Bytes(fid), mus, types.Bytes(sigma)) + c, err := types.NewCall(meta, SegmentBook_SubmitProve, types.U64(id), data) if err != nil { return configs.Code_500, errors.Wrap(err, "[NewCall]") } diff --git a/internal/proof/main.go b/internal/proof/main.go index 8e4c18a..02e6549 100644 --- a/internal/proof/main.go +++ b/internal/proof/main.go @@ -383,12 +383,15 @@ func task_HandlingChallenges(ch chan bool) { continue } - fmt.Printf("---> Prepare to generate challenges [%v]\n", len(chlng)) + Out.Sugar().Infof("---> Prepare to generate challenges [%v]\n", len(chlng)) for x := 0; x < len(chlng); x++ { - fmt.Printf(" %v: %s\n", x, string(chlng[x].File_id)) + Out.Sugar().Infof(" %v: %s\n", x, string(chlng[x].File_id)) } - + var proveInfos = make([]chain.ProveInfo, 0) for i := 0; i < len(chlng); i++ { + if len(proveInfos) > 50 { + break + } if chlng[i].File_type == 1 { //space file filedir = filepath.Join(configs.SpaceDir, string(chlng[i].File_id)) @@ -450,22 +453,37 @@ func task_HandlingChallenges(ch chan bool) { continue } - // proof up chain - ts := time.Now().Unix() - code = 0 - for code != int(configs.Code_200) && code != int(configs.Code_600) { - code, err = chain.PutProofToChain(configs.C.SignaturePrk, configs.MinerId_I, []byte(chlng[i].File_id), proveResponse.Sigma, proveResponse.MU) - if err == nil { - Out.Sugar().Infof("[%v] Proof submitted successfully", fileid) - break - } - if time.Since(time.Unix(ts, 0)).Minutes() > 10.0 { - Err.Sugar().Errorf("[%v] %v", filename, err) - break - } - time.Sleep(time.Second * time.Duration(tools.RandomInRange(5, 20))) + proveInfoTemp := chain.ProveInfo{} + proveInfoTemp.Cinfo = chlng[i] + proveInfoTemp.FileId = chlng[i].File_id + + var mus []types.Bytes = make([]types.Bytes, len(proveResponse.MU)) + for i := 0; i < len(proveResponse.MU); i++ { + mus[i] = make(types.Bytes, 0) + mus[i] = append(mus[i], proveResponse.MU[i]...) + } + proveInfoTemp.Mu = mus + proveInfoTemp.Sigma = types.Bytes(proveResponse.Sigma) + proveInfoTemp.MinerId = types.U64(configs.MinerId_I) + proveInfos = append(proveInfos, proveInfoTemp) + } + // proof up chain + ts := time.Now().Unix() + code = 0 + for code != int(configs.Code_200) && code != int(configs.Code_600) { + code, err = chain.PutProofToChain(configs.C.SignaturePrk, configs.MinerId_I, proveInfos) + if err == nil { + Out.Sugar().Infof("Proofs submitted successfully") + break + } + if time.Since(time.Unix(ts, 0)).Minutes() > 2.0 { + Err.Sugar().Errorf("[%v] %v", filename, err) + break } + time.Sleep(time.Second * time.Duration(tools.RandomInRange(5, 20))) } + proveInfos = proveInfos[:0] + time.Sleep(time.Second * time.Duration(tools.RandomInRange(30, 60))) } }