Skip to content

Commit

Permalink
Base 076 1 (#94)
Browse files Browse the repository at this point in the history
* update pb for v0.7.6

* update RequestVerifySpaceTotal
  • Loading branch information
AstaFrode authored Dec 19, 2023
1 parent e40b326 commit bc3bdd1
Show file tree
Hide file tree
Showing 10 changed files with 957 additions and 846 deletions.
90 changes: 38 additions & 52 deletions core/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,90 +154,76 @@ type P2P interface {
// GetServiceTagCh returns the tag channel of the service data received by the host
GetServiceTagCh() <-chan string

// PoisNewClient
PoisNewClient(addr string, opts ...grpc.DialOption) (pb.PoisApiClient, error)
NewPoisCertifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisCertifierApiClient, error)

//
PoisServiceNewClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)
NewPoisVerifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisVerifierApiClient, error)

NewPodr2ApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)

// PoisGetMinerInitParam
PoisGetMinerInitParam(
NewPodr2VerifierApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2VerifierApiClient, error)

RequestMinerGetNewKey(
addr string,
accountKey []byte,
timeout time.Duration,
opts ...grpc.DialOption,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseMinerInitParam, error)

// PoisMinerCommitGenChall
PoisMinerCommitGenChall(
RequestMinerCommitGenChall(
addr string,
commitGenChall *pb.RequestMinerCommitGenChall,
timeout time.Duration,
opts ...grpc.DialOption,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.Challenge, error)

// PoisVerifyCommitProof
PoisVerifyCommitProof(
RequestVerifyCommitProof(
addr string,
verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof,
timeout time.Duration,
opts ...grpc.DialOption,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)

// PoisSpaceProofVerifySingleBlock
PoisSpaceProofVerifySingleBlock(
RequestVerifyDeletionProof(
addr string,
accountKey []byte,
spaceChals []int64,
minerPoisInfo *pb.MinerPoisInfo,
proof *pb.SpaceProof,
spaceProofHashPolkadotSig []byte,
requestVerifyDeletionProof *pb.RequestVerifyDeletionProof,
timeout time.Duration,
opts ...grpc.DialOption,
) (*pb.ResponseSpaceProofVerify, error)
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)

//
PoisRequestVerifySpaceTotal(
RequestSpaceProofVerifySingleBlock(
addr string,
accountKey []byte,
proofList []*pb.BlocksProof,
front int64,
rear int64,
acc []byte,
spaceChals []int64,
requestSpaceProofVerify *pb.RequestSpaceProofVerify,
timeout time.Duration,
opts ...grpc.DialOption,
) (*pb.ResponseSpaceProofVerifyTotal, error)
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseSpaceProofVerify, error)

//
PoisRequestVerifyDeletionProof(
RequestVerifySpaceTotal(
addr string,
RequestVerifyDeletionProof *pb.RequestVerifyDeletionProof,
requestSpaceProofVerifyTotal *pb.RequestSpaceProofVerifyTotal,
timeout time.Duration,
opts ...grpc.DialOption,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseSpaceProofVerifyTotal, error)

//
PoisServiceRequestGenTag(
RequestGenTag(
addr string,
fileData []byte,
roothash string,
filehash string,
customData string,
requestGenTag *pb.RequestGenTag,
timeout time.Duration,
opts ...grpc.DialOption,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseGenTag, error)

//
PoisServiceRequestBatchVerify(
RequestBatchVerify(
addr string,
peerid []byte,
minerPbk []byte,
minerPeerIdSign []byte,
batchVerifyParam *pb.RequestBatchVerify_BatchVerifyParam,
qslices *pb.RequestBatchVerify_Qslice,
requestBatchVerify *pb.RequestBatchVerify,
timeout time.Duration,
opts ...grpc.DialOption,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseBatchVerify, error)
}

Expand Down
75 changes: 75 additions & 0 deletions core/podr2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Copyright (C) CESS. All rights reserved.
Copyright (C) Cumulus Encrypted Storage System. All rights reserved.
SPDX-License-Identifier: Apache-2.0
*/

package core

import (
"context"
"time"

"github.com/CESSProject/p2p-go/pb"
"google.golang.org/grpc"
)

func (n *Node) NewPodr2ApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error) {
conn, err := grpc.Dial(addr, opts...)
if err != nil {
return nil, err
}
return pb.NewPodr2ApiClient(conn), nil
}

func (n *Node) NewPodr2VerifierApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2VerifierApiClient, error) {
conn, err := grpc.Dial(addr, opts...)
if err != nil {
return nil, err
}
return pb.NewPodr2VerifierApiClient(conn), nil
}

func (n *Node) RequestGenTag(
addr string,
requestGenTag *pb.RequestGenTag,
timeout time.Duration,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseGenTag, error) {
conn, err := grpc.Dial(addr, dialOpts...)
if err != nil {
return nil, err
}
defer conn.Close()
c := pb.NewPodr2ApiClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

result, err := c.RequestGenTag(ctx, requestGenTag, callOpts...)
return result, err
}

func (n *Node) RequestBatchVerify(
addr string,
requestBatchVerify *pb.RequestBatchVerify,
timeout time.Duration,
dialOpts []grpc.DialOption,
callOpts []grpc.CallOption,
) (*pb.ResponseBatchVerify, error) {
conn, err := grpc.Dial(addr, dialOpts...)
if err != nil {
return nil, err
}

defer conn.Close()
c := pb.NewPodr2VerifierApiClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

result, err := c.RequestBatchVerify(ctx, requestBatchVerify, callOpts...)
return result, err
}
Loading

0 comments on commit bc3bdd1

Please sign in to comment.