diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a460645 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "go.inferGopath": false +} \ No newline at end of file diff --git a/bdledger/api/contract.proto b/bdledger/api/contract.proto new file mode 100644 index 0000000..2e8435c --- /dev/null +++ b/bdledger/api/contract.proto @@ -0,0 +1,69 @@ +syntax = "proto3"; + +//protoc --plugin=protoc-gen-grpc-java=/Users/oliveds/docs/grpc/grpc-java/compiler/build/exe/java_plugin/protoc-gen-grpc-java --grpc-java_out=./out --proto_path=./out Go2JavaService.proto +//protoc --java_out=./out --proto_path=./out Go2JavaService.proto + +///:. 生成的文件到当前目录 +//protoc -I /Users/oliveds/docs/grpc/out --go_out=plugins=grpc:. /Users/oliveds/docs/grpc/out/Go2JavaService.proto + +option go_package = "bdware.org/bdledger/pkg/api/grpc/proto"; +option java_package = "com.bdware.units.grpc"; +option java_outer_classname = "GRPCGo2JavaService"; +option objc_class_prefix = "RTG"; + +package com.bdware.units.grpc; + +// Interface exported by the server. +service Go2JavaService { + + rpc Go2JavaStream(stream Go2JavaMessage) returns (stream Go2JavaMessage){} + +} + + +message Go2JavaMessage { + Go2JavaMessageType msgType=1; + string myPeerID = 2; + repeated string peerID = 3; + ContractUnitRequestType cuType = 4; + StatusType statusType = 5; + bytes content = 6; + string requestID = 7; + repeated string contractID = 8; + int32 num = 9; + string signature = 10; + + enum Go2JavaMessageType{ + ContractUnitRequest = 0; + ContractUnitResponse = 1; + GetMyPeerID = 2; + MyPeerIDResponse = 3; + ContractStatusRequest = 4; + ContractStatusResponse = 5; + GetRandomPeers = 6; + GetAllPeers = 7; + RandomPeersResponse = 8; + AllPeersResponse = 9; + + } + + enum StatusType{ + SUCCESS = 0; + FAIL = 1; + } + + enum ContractUnitRequestType{ + START = 0; + STOP = 1; + EXECUTE = 2; + REPLY = 3; + REQUEST = 4; + PREPREPARE = 5; + PREPARE = 6; + COMMIT = 7; + ADDPEER = 8; + DROPPEER = 9; + STATESYNC = 10; + } +} + diff --git a/docs.md b/docs.md index 581ab7f..605245a 100644 --- a/docs.md +++ b/docs.md @@ -217,7 +217,7 @@ message SendTransactionResponse { to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567", data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675" } -] +} // 结果 { diff --git a/scripts/gen-go.bat b/scripts/gen-go.bat index e1d08c5..620d1bf 100644 --- a/scripts/gen-go.bat +++ b/scripts/gen-go.bat @@ -15,5 +15,6 @@ if not exist %dir% mkdir %dir% %exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/node.proto %exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/ledger.proto %exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/query.proto +%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/contract.proto echo all done diff --git a/scripts/gen-go.sh b/scripts/gen-go.sh index b17a915..ed8717a 100644 --- a/scripts/gen-go.sh +++ b/scripts/gen-go.sh @@ -7,3 +7,5 @@ protoc -I . --go_out=plugins=grpc:$dir bdledger/api/error_details.proto protoc -I . --go_out=plugins=grpc:$dir bdledger/api/node.proto protoc -I . --go_out=plugins=grpc:$dir bdledger/api/ledger.proto protoc -I . --go_out=plugins=grpc:$dir bdledger/api/query.proto +protoc -I . --go_out=plugins=grpc:$dir bdledger/api/contract.proto + diff --git a/scripts/gen-node.js.sh b/scripts/gen-node.js.sh index 2dd1ec1..1f72893 100644 --- a/scripts/gen-node.js.sh +++ b/scripts/gen-node.js.sh @@ -8,3 +8,4 @@ protoc -I . --js_out=import_style=commonjs,binary:$dir --grpc_out=$dir --plugin= protoc -I . --js_out=import_style=commonjs,binary:$dir --grpc_out=$dir --plugin=protoc-gen-grpc="$pluginPath" bdledger/api/node.proto protoc -I . --js_out=import_style=commonjs,binary:$dir --grpc_out=$dir --plugin=protoc-gen-grpc="$pluginPath" bdledger/api/ledger.proto protoc -I . --js_out=import_style=commonjs,binary:$dir --grpc_out=$dir --plugin=protoc-gen-grpc="$pluginPath" bdledger/api/query.proto +protoc -I . --js_out=import_style=commonjs,binary:$dir --grpc_out=$dir --plugin=protoc-gen-grpc="$pluginPath" bdledger/api/contract.proto \ No newline at end of file diff --git a/scripts/gen-nodejs.bat b/scripts/gen-nodejs.bat index 849462b..c029ab1 100644 --- a/scripts/gen-nodejs.bat +++ b/scripts/gen-nodejs.bat @@ -15,5 +15,6 @@ call %exe% -I . --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --p call %exe% -I . --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%pluginPath% bdledger/api/node.proto call %exe% -I . --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%pluginPath% bdledger/api/ledger.proto call %exe% -I . --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%pluginPath% bdledger/api/query.proto +call %exe% -I . --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%pluginPath% bdledger/api/contract.proto echo all done diff --git a/scripts/gen-web.bat b/scripts/gen-web.bat index 593d664..ee4c048 100644 --- a/scripts/gen-web.bat +++ b/scripts/gen-web.bat @@ -13,5 +13,6 @@ if not exist %dir% mkdir %dir% %exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/node.proto %exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/ledger.proto %exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/query.proto +%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/contract.proto echo all done diff --git a/scripts/gen-web.sh b/scripts/gen-web.sh index 257ca78..299429b 100644 --- a/scripts/gen-web.sh +++ b/scripts/gen-web.sh @@ -7,3 +7,4 @@ protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=comm protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/node.proto protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/ledger.proto protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/query.proto +protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/contract.proto