-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
erase front dependency to bcos-boostssl
- Loading branch information
1 parent
7c69e64
commit 49f2b02
Showing
33 changed files
with
583 additions
and
1,275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,11 +51,11 @@ jobs: | |
!c:/vcpkg/buildtrees | ||
!c:/vcpkg/packages | ||
!c:/vcpkg/downloads | ||
key: build-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
key: build-all-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
restore-keys: | | ||
build-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
build-${{ matrix.os }}-${{ github.base_ref }}- | ||
build-${{ matrix.os }}- | ||
build-all-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
build-all-${{ matrix.os }}-${{ github.base_ref }}- | ||
build-all-${{ matrix.os }}- | ||
- name: Build for linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
|
@@ -105,11 +105,11 @@ jobs: | |
${{ env.VCPKG_ROOT }}/buildtrees | ||
${{ env.VCPKG_ROOT }}/packages | ||
${{ env.VCPKG_ROOT }}/downloads | ||
key: build-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
key: build-sdk-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
restore-keys: | | ||
build-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
build-${{ matrix.os }}-${{ github.base_ref }}- | ||
build-${{ matrix.os }}- | ||
build-sdk-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
build-sdk-${{ matrix.os }}-${{ github.base_ref }}- | ||
build-sdk-${{ matrix.os }}- | ||
- name: Add MSbuild to PATH | ||
if: runner.os == 'Windows' | ||
uses: microsoft/[email protected] | ||
|
@@ -118,7 +118,7 @@ jobs: | |
run: | | ||
mkdir -p cpp/build && cd cpp/build && cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DTESTS=OFF -DBUILD_SDK=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake .. | ||
MSBuild /version | ||
MSBuild wedpr-component.sln /p:Configuration=Release /p:Platform=x64 | ||
MSBuild WeDPR-Component.sln /p:Configuration=Release /p:Platform=x64 | ||
- name: Build for linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
|
@@ -184,18 +184,18 @@ jobs: | |
${{ env.VCPKG_ROOT }}/buildtrees | ||
${{ env.VCPKG_ROOT }}/packages | ||
${{ env.VCPKG_ROOT }}/downloads | ||
key: build-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
key: build-toolkit-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
restore-keys: | | ||
build-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
build-${{ matrix.os }}-${{ github.base_ref }}- | ||
build-${{ matrix.os }}- | ||
build-toolkit-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
build-toolkit-${{ matrix.os }}-${{ github.base_ref }}- | ||
build-toolkit-${{ matrix.os }}- | ||
- name: Add MSbuild to PATH | ||
if: runner.os == 'Windows' | ||
uses: microsoft/[email protected] | ||
- name: Build for windows | ||
if: runner.os == 'Windows' | ||
run: | | ||
mkdir -p cpp/build && cd cpp/build && cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DTESTS=OFF -DBUILD_WEDPR_TOOLKIT=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake .. && MSBuild /version && MSBuild wedpr-component.sln /p:Configuration=Release /p:Platform=x64 | ||
mkdir -p cpp/build && cd cpp/build && cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DTESTS=OFF -DBUILD_WEDPR_TOOLKIT=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake .. && MSBuild /version && MSBuild WeDPR-Component.sln /p:Configuration=Release /p:Platform=x64 | ||
- name: Build for linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
|
@@ -249,11 +249,11 @@ jobs: | |
/usr/local/share/vcpkg/packages | ||
/home/runner/.ccache | ||
/Users/runner/.ccache/ | ||
key: centos-notest-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
key: centos-notest-all-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
restore-keys: | | ||
centos-notest-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
centos-notest-${{ matrix.os }}-${{ github.base_ref }}- | ||
centos-notest-${{ matrix.os }}- | ||
centos-notest-all-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} | ||
centos-notest-all-${{ matrix.os }}-${{ github.base_ref }}- | ||
centos-notest-all-${{ matrix.os }}- | ||
- name: Prepare centos tools | ||
run: | | ||
rpm -ivh https://cbs.centos.org/kojifiles/packages/centos-release-scl-rh/2/3.el7.centos/noarch/centos-release-scl-rh-2-3.el7.centos.noarch.rpm | ||
|
@@ -277,11 +277,10 @@ jobs: | |
- name: Build | ||
run: | | ||
alias cmake='cmake3' | ||
. /opt/rh/devtoolset-10/enable | ||
. /opt/rh/devtoolset-11/enable | ||
. /opt/rh/rh-perl530/enable | ||
export LIBCLANG_PATH=/opt/rh/llvm-toolset-7/root/lib64/ | ||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
. /opt/rh/llvm-toolset-7/enable | ||
mkdir -p cpp/build | ||
cd cpp/build | ||
cmake3 -DCMAKE_BUILD_TYPE=Release -DTESTS=ON -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake ../ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* Copyright (C) 2023 WeDPR. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @file Message.h | ||
* @author: yujiechen | ||
* @date 2024-08-22 | ||
*/ | ||
#pragma once | ||
#include "Message.h" | ||
#include <bcos-boostssl/interfaces/MessageFace.h> | ||
namespace ppc::protocol | ||
{ | ||
// the wrapper for override bcos::boostssl::MessageFace while use implementation for Message | ||
class P2PMessage : virtual public bcos::boostssl::MessageFace | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<P2PMessage>; | ||
P2PMessage(Message::Ptr msg) : m_msg(std::move(msg)) {} | ||
~P2PMessage() override {} | ||
|
||
/// the overloaed implementation === | ||
uint16_t version() const override { return m_msg->version(); } | ||
void setVersion(uint16_t version) override { m_msg->setVersion(version); } | ||
uint16_t packetType() const override { return m_msg->packetType(); } | ||
void setPacketType(uint16_t packetType) override { m_msg->setPacketType(packetType); } | ||
std::string const& seq() const override { return m_msg->seq(); } | ||
void setSeq(std::string seq) override { m_msg->setSeq(seq); } | ||
uint16_t ext() const override { return m_msg->ext(); } | ||
void setExt(uint16_t ext) override { m_msg->setExt(ext); } | ||
std::shared_ptr<bcos::bytes> payload() const override { return m_msg->payload(); } | ||
void setPayload(std::shared_ptr<bcos::bytes> payload) override | ||
{ | ||
m_msg->setPayload(std::move(payload)); | ||
} | ||
|
||
bool encode(bcos::bytes& _buffer) override { return m_msg->encode(_buffer); } | ||
|
||
int64_t decode(bcos::bytesConstRef _buffer) override { return m_msg->decode(_buffer); } | ||
|
||
bool isRespPacket() const override { return m_msg->isRespPacket(); } | ||
void setRespPacket() override { m_msg->setRespPacket(); } | ||
uint32_t length() const override { return m_msg->length(); } | ||
|
||
// encode and return the {header, payload} | ||
virtual bool encode(bcos::boostssl::EncodedMsg& _encodedMsg) = 0; | ||
|
||
Message::Ptr const& msg() { return m_msg; } | ||
MessageHeader::Ptr header() const { return m_msg->header(); } | ||
|
||
protected: | ||
Message::Ptr m_msg; | ||
}; | ||
|
||
|
||
class P2PMessageBuilder : virtual public bcos::boostssl::MessageFaceFactory | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<P2PMessageBuilder>; | ||
P2PMessageBuilder() = default; | ||
~P2PMessageBuilder() override = default; | ||
|
||
virtual P2PMessage::Ptr build() = 0; | ||
virtual P2PMessage::Ptr build(ppc::protocol::RouteType routeType, | ||
ppc::protocol::MessageOptionalHeader::Ptr const& routeInfo, bcos::bytes&& payload) = 0; | ||
}; | ||
inline std::string printWsMessage(bcos::boostssl::MessageFace::Ptr const& _msg) | ||
{ | ||
if (!_msg) | ||
{ | ||
return "nullptr"; | ||
} | ||
std::ostringstream stringstream; | ||
stringstream << LOG_KV("rsp", _msg->isRespPacket()) << LOG_KV("traceID", _msg->seq()) | ||
<< LOG_KV("packetType", _msg->packetType()) << LOG_KV("length", _msg->length()) | ||
<< LOG_KV("ext", _msg->ext()); | ||
return stringstream.str(); | ||
} | ||
inline std::string printP2PMessage(P2PMessage::Ptr const& _msg) | ||
{ | ||
if (_msg->msg() == nullptr) | ||
{ | ||
return ""; | ||
} | ||
return printMessage(_msg->msg()); | ||
} | ||
} // namespace ppc::protocol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
file(GLOB_RECURSE SRCS *.cpp) | ||
add_library(${PROTOCOL_TARGET} ${SRCS}) | ||
|
||
target_link_libraries(${PROTOCOL_TARGET} PUBLIC ${BCOS_BOOSTSSL_TARGET} ${CPU_FEATURES_LIB} jsoncpp_static) | ||
target_link_libraries(${PROTOCOL_TARGET} PUBLIC ${CPU_FEATURES_LIB} jsoncpp_static) |
Oops, something went wrong.