Commit 7f25f85b authored by Ubuntu's avatar Ubuntu

add repeated nonce grpc

parent 773fb36f
......@@ -15,6 +15,8 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
type P2PServer struct {
......@@ -74,6 +76,20 @@ func main() {
fmt.Printf("failed to listen: %v", err)
return
}
ethTx := metabase.EthTransaction{}
var checkTx metabase.CheckTx
ethTxAsAny, err := pbany(ethTx)
if err != nil {
fmt.Println(err.Error())
return
}
checkTx.Tx = ethTxAsAny
s := grpc.NewServer() // 创建gRPC服务器
metacrypter.RegisterCrypterServiceServer(s, &server{}) // 在gRPC服务端注册服务
// 启动服务
......@@ -83,3 +99,11 @@ func main() {
return
}
}
func pbany(v interface{}) (*anypb.Any, error) {
pv, ok := v.(proto.Message)
if !ok {
return &anypb.Any{}, fmt.Errorf("%v is not proto.Message", pv)
}
return anypb.New(pv)
}
......@@ -130,14 +130,14 @@ message NonceResponse {
}
message NonceRepeatedRequest {
message RepeatedNonceRequest {
// request address
repeated bytes address = 1;
repeated bytes address = 1;
// request block number
repeated bytes block_id = 2;
}
message NonceRepeatedResponse {
message RepeatedNonceResponse {
// the address
repeated bytes address = 1;
// block height
......
......@@ -56,6 +56,7 @@ service NebulaService {
rpc Balance(BalanceRequest) returns (BalanceResponse) {};
rpc Storage(StorageRequest) returns (StorageResponse) {};
rpc Nonce(NonceRequest) returns (NonceResponse) {};
rpc RepeatedNonce(RepeatedNonceRequest) returns (RepeatedNonceResponse) {};
rpc TransactionCount(TransactionCountRequest) returns (TransactionCountResponse) {};
rpc GetCode(GetCodeRequest) returns (GetCodeResponse) {};
rpc Sign(SignRequest) returns (SignResponse) {};
......
......@@ -68,24 +68,3 @@ message GetConsensusedBlockResponse {
}
// GetBalance -> eth.getBalance -> eth_getBalance
message GetBalanceReq {
repeated string address = 1;
}
message GetBalanceResp {
repeated string balance = 1;
}
// GetNonce -> eth.GetNonce -> GetNonce
message GetNonceReq {
repeated string address = 1;
}
message GetNonceResp {
repeated string balance = 1;
}
message BlockNumber {
uint64 blocknum = 1;
}
......@@ -20,7 +20,4 @@ service SentryService {
// GetConsensusedBlock used for nebula get special block consensus result.
rpc GetConfirmedBlock(GetConsensusedBlockRequest) returns(GetConsensusedBlockResponse) {}
// rpc GetBalance(GetBalanceReq) returns (GetBalanceResp) {};
// rpc GetNonce(GetNonceReq) returns (GetNonceResp) {};
// rpc GetBlockNumber(google.protobuf.Empty) returns (BlockNumber) {};
}
......@@ -2,28 +2,8 @@ syntax = "proto3";
package txchecker.v1;
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "txchecker/v1/resource.proto";
import "google/protobuf/any.proto";
import "base/v1/resource.proto";
message EnumValue {
// The URL, optionally omitted scheme, for the enumeration type.
string type_url = 1;
int32 value =2;
}
enum Corpus {
CORPUS_UNIVERSAL = 0;
CORPUS_WEB =1;
}
// The standard BatchGet request definition.
message BatchCheckTxRequest {
repeated base.v1.CheckTx txs = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment