Implemented protobuf infastructure and definitions for proposal and npl messages.

This commit is contained in:
asanka-indrajith
2019-10-04 03:56:53 -04:00
parent 040bc76c95
commit 75434d4991
5 changed files with 7108 additions and 1 deletions

View File

@@ -35,6 +35,20 @@ Following Instructions are based on Boost [getting started](https://www.boost.or
2. Navigate to the extracted directory.
3. Run `sudo cp -r include/rapidjson /usr/local/include/`
#### Install Protocol buffers
Instructions are based on [this](https://github.com/protocolbuffers/protobuf/tree/master/src).
1. Download and extract Protobuf 3.10.0 from [here](https://github.com/protocolbuffers/protobuf/releases/tag/v3.10.0).
2. Navigate to the extracted Protobuf directory in a terminal.
3. Run `./configure`
4. Run `make && make check`
5. Run `sudo make install`
#### Compile Protocol buffers
1. Run `protoc -I=./src/p2p --cpp_out=./src/p2p ./src/p2p/message.proto`
Ex - For message protobuf
`protoc -I=./src/p2p --cpp_out=./src/p2p ./src/p2p/message.proto`
#### Run ldconfig
1. Run `sudo ldconfig`

View File

@@ -1,4 +1,4 @@
all:
mkdir -p build
g++ src/*.cpp -lsodium -lboost_system -lboost_filesystem -std=c++17 -o build/hpcore
g++ src/*.cpp src/*.cc -lsodium -lboost_system -lboost_filesystem -pthread -lprotobuf -std=c++17 -o build/hpcore
echo 'build successful, binary in '`pwd`'/build/hpcore'

4139
src/p2p/message.pb.cc Normal file

File diff suppressed because it is too large Load Diff

2885
src/p2p/message.pb.h Normal file

File diff suppressed because it is too large Load Diff

69
src/p2p/message.proto Normal file
View File

@@ -0,0 +1,69 @@
syntax = "proto2";
package p2p;
message Message {
optional string version = 1;
optional bytes publicKey = 2;
optional int32 timestamp = 3;
optional bytes signature = 4;
enum Messagetype {
PROPOSAL = 0;
NPL = 1;
STATE_REQUEST = 2;
STATE_RESPONSE = 3;
HISTORY_REQUEST = 4;
HISTORY_RESPONSE = 5;
}
optional Messagetype type = 5;
optional bytes content = 6;
}
message StateDifference {
map<string, string> created = 1;
map<string, string> updated = 2;
map<string, string> deleted = 3;
}
message State {
optional bytes previous = 1;
optional bytes current = 2;
optional StateDifference difference = 3;
map<string, string> patch = 4;
}
message Proposal {
repeated string connections = 1;
repeated string inputs = 2;
repeated string outputs = 3;
optional int32 stage = 4;
optional int32 time = 5;
optional State state = 6;
optional bytes lcl = 7;
}
message NPL {
optional bytes data = 1;
optional bytes lcl = 2;
}
message StateRequest {
}
message StateResponse {
}
message HistoryRequest {
}
message HistoryResponse {
}