Skip to content

Commit

Permalink
remove wedpr-front-cpp-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Aug 26, 2024
1 parent 4cad628 commit ceb0f92
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 365 deletions.
2 changes: 1 addition & 1 deletion cpp/cmake/IncludeDirectories.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-front)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-gateway)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-component-c-sdk)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-component-sdk)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-tars-protocol)

set(VCPKG_INCLUDE_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
Expand Down
6 changes: 2 additions & 4 deletions cpp/cmake/TargetSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,12 @@ set(PPC_CRYPTO_C_SDK_STATIC_TARGET ppc-crypto-c-sdk-static)
set(PPC_CRYPTO_C_SDK_TARGET ppc-crypto-c-sdk)

set(PPC_FRONT_C_SDK_STATIC_TARGET ppc-front-c-sdk-static)
set(PPC_FRONT_C_SDK_TARGET ppc-front-c-sdk)

# add suffix for arm
if(ARCH_NATIVE)
message(STATUS "Building arm architecture, CMAKE_HOST_SYSTEM_PROCESSOR => ${CMAKE_HOST_SYSTEM_PROCESSOR}")
set(PPC_CRYPTO_C_SDK_STATIC_TARGET "ppc-crypto-c-sdk-aarch64")
set(PPC_CRYPTO_C_SDK_TARGET "ppc-crypto-c-sdk-static-aarch64")
set(PPC_FRONT_C_SDK_STATIC_TARGET ppc-front-c-sdk-static-aarch64)
set(PPC_FRONT_C_SDK_TARGET ppc-front-c-sdk-aarch64)
endif()
#====== wedpr-component-sdk ===========

Expand Down Expand Up @@ -127,4 +124,5 @@ endif()
set(BOOST_UNIT_TEST Boost::unit_test_framework)

# ==== the swig wrapper =====
set(WEDPR_PYTHON_TOOLKIT "wedpr_python_toolkit")
set(WEDPR_PYTHON_TOOLKIT "wedpr_python_toolkit")
set(WEDPR_PYTHON_TOOLKIT_DIR ${PROJECT_BINARY_DIR}/python/${WEDPR_PYTHON_TOOLKIT})
1 change: 1 addition & 0 deletions cpp/cmake/Version.cmake
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
set(VERSION "1.0.0")
set(PYTHON_TOOLKIT_VERSION "1.0.0")
12 changes: 12 additions & 0 deletions cpp/ppc-framework/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ namespace ppc
{ \
}

#define CHECK_OFFSET_WITH_THROW_EXCEPTION(offset, length) \
do \
{ \
if (offset > length) \
{ \
throw std::out_of_range("Out of range error, offset:" + std::to_string(offset) + \
" ,length: " + std::to_string(length) + \
" ,file: " + __FILE__ + " ,func: " + __func__ + \
" ,line: " + std::to_string(__LINE__)); \
} \
} while (0);

DERIVE_PPC_EXCEPTION(OpenFileFailed);
DERIVE_PPC_EXCEPTION(DataSchemaNotSetted);
DERIVE_PPC_EXCEPTION(UnsupportedDataSchema);
Expand Down
195 changes: 195 additions & 0 deletions cpp/ppc-framework/protocol/Message.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/**
* 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 <bcos-boostssl/interfaces/MessageFace.h>
#include <bcos-utilities/Common.h>
#include <memory>

namespace ppc::protocol
{
class MessageOptionalHeader
{
public:
using Ptr = std::shared_ptr<MessageOptionalHeader>;
MessageOptionalHeader() = default;
virtual ~MessageOptionalHeader() = default;

virtual bcos::bytes encode() const = 0;
// the componentType
virtual uint8_t componentType() const { return m_componentType; }
// the source nodeID that send the message
virtual bcos::bytes const& srcNode() const { return m_srcNode; }
// the target nodeID that should receive the message
virtual bcos::bytes const& dstNode() const { return m_dstNode; }
// the target agency that need receive the message
virtual bcos::bytes const& dstInst() const { return m_dstInst; }

protected:
virtual uint32_t decode(bcos::bytesConstRef data) = 0;

protected:
// the componentType
uint8_t m_componentType;
// the source nodeID that send the message
bcos::bytes m_srcNode;
// the target nodeID that should receive the message
bcos::bytes m_dstNode;
// the target agency that need receive the message
bcos::bytes m_dstInst;
};
class MessageHeader
{
public:
using Ptr = std::shared_ptr<MessageHeader>;
MessageHeader() = default;
virtual ~MessageHeader() = default;

virtual bcos::bytes encode() const = 0;

// the msg version, used to support compatibility
virtual uint8_t version() const { return m_version; }
// the traceID
virtual std::string const& traceID() const { return m_traceID; }
// the srcGwNode
virtual bcos::bytes const& srcGwNode() const { return m_srcGwNode; }
// the dstGwNode
virtual bcos::bytes const& dstGwNode() const { return m_dstGwNode; }
// the packetType
virtual uint16_t packetType() const { return m_packetType; }
// the ttl
virtual int16_t ttl() const { return m_ttl; }
// the ext(contains the router policy and response flag)
virtual uint16_t ext() const { return m_ext; }
//// the optional field(used to route between components and nodes)
virtual MessageOptionalHeader::Ptr optionalFields() const { return m_optionalFields; }

virtual uint32_t length() const { return m_length; }

virtual void setVersion(uint16_t version) { m_version = version; }
virtual void setPacketType(uint16_t packetType) { m_packetType = packetType; }
// the seq is the traceID
virtual void setTraceID(std::string traceID) { m_traceID = traceID; }
virtual void setExt(uint16_t ext) { m_ext = ext; }

uint64_t packetLen() const { return m_packetLen; }
uint16_t headerLen() const { return m_headerLen; }

virtual bool isRespPacket() const = 0;
virtual void setRespPacket() = 0;

protected:
virtual uint32_t decode(bcos::bytesConstRef data) = 0;

protected:
// the msg version, used to support compatibility
uint8_t m_version;
// the traceID
std::string m_traceID;
// the srcGwNode
bcos::bytes m_srcGwNode;
// the dstGwNode
bcos::bytes m_dstGwNode;
// the packetType
uint16_t m_packetType;
// the ttl
int16_t m_ttl;
// the ext(contains the router policy and response flag)
uint16_t m_ext;
//// the optional field(used to route between components and nodes)
MessageOptionalHeader::Ptr m_optionalFields;
uint64_t m_packetLen;
uint16_t m_headerLen;
};

class MessagePayload
{
public:
using Ptr = std::shared_ptr<MessagePayload>;
MessagePayload() = default;
virtual ~MessagePayload() = default;

virtual bcos::bytes encode() const = 0;

// the version
virtual uint8_t version() const { return m_version; }
// the topic
virtual std::string const& topic() const { return m_topic; }
virtual bcos::bytes const& data() const { return m_data; }
virtual uint32_t length() const { return m_length; }

protected:
virtual uint32_t decode(uint32_t startPos, bcos::bytesConstRef data) = 0;

protected:
// the front payload version, used to support compatibility
uint8_t m_version;
// the topic
std::string m_topic;
bcos::bytes m_data;
uint32_t m_length;
};

class Message : virtual public bcos::boostssl::MessageFace
{
public:
using Ptr = std::shared_ptr<Message>;
Message() = default;
~Message() override {}

virtual MessageHeader::Ptr header() const { return m_header; }
virtual MessagePayLoad::Ptr payload() const { return m_payload; }

uint16_t version() const override { return m_header->version(); }
void setVersion(uint16_t version) override{m_header->setVersion(version)} uint16_t
packetType() const override
{
return m_header->packetType();
}
void setPacketType(uint16_t packetType) override { m_header->setPacketType(packetType); }
std::string const& seq() const override { return m_header->traceID(); }
void setSeq(std::string traceID) override { m_header->setTraceID(traceID); }
uint16_t ext() const override { return m_header->ext(); }
void setExt(uint16_t ext) override { m_header->setExt(except); }

bool isRespPacket() const override { return m_header->isRespPacket(); }
void setRespPacket() override { m_header->setRespPacket(); }

virtual uint32_t length() const override { return m_header->packetLen(); }
std::shared_ptr<bcos::bytes> payload() const override { return m_payload; }
void setPayload(std::shared_ptr<bcos::bytes> _payload) override
{
m_payload = std::move(_payload);
}


protected:
MessageHeader::Ptr m_header;
std::shared_ptr<bcos::bytes> m_payload;
};

class MessageBuilder
{
public:
MessageBuilder() = default;
virtual ~MessageBuilder() = default;

virtual Message::Ptr build() = 0;
}
} // namespace ppc::protocol
1 change: 0 additions & 1 deletion cpp/ppc-front/ppc-front/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

namespace ppc::front
{

#define FRONT_LOG(LEVEL) BCOS_LOG(LEVEL) << "[FRONT]"

#define HOLDING_MESSAGE_TIMEOUT_M 30
Expand Down
5 changes: 1 addition & 4 deletions cpp/ppc-protocol/src/PPCMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ class PPCMessage : public PPCMessageFace
std::shared_ptr<bcos::bytes> data() const override { return m_data; }
// Note: here directly use passed-in _data, make-sure _data not changed before send the message
void setData(std::shared_ptr<bcos::bytes> _data) override { m_data = _data; }
std::map<std::string, std::string> header() override
{
return decodeMap(m_header);
}
std::map<std::string, std::string> header() override { return decodeMap(m_header); }
void setHeader(std::map<std::string, std::string> _header) override
{
m_header = encodeMap(_header);
Expand Down
13 changes: 1 addition & 12 deletions cpp/ppc-tools/src/codec/CodecUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,10 @@
#pragma once
#include "openssl/bn.h"
#include "ppc-framework/libwrapper/BigNum.h"
#include "ppc-utilities/Utilities.h"
#include <bcos-utilities/Common.h>
#include <boost/endian/conversion.hpp>
#include <cstring>

#define CHECK_OFFSET_WITH_THROW_EXCEPTION(offset, length) \
do \
{ \
if (offset > length) \
{ \
throw std::out_of_range("Out of range error, offset:" + std::to_string(offset) + \
" ,length: " + std::to_string(length) + \
" ,file: " + __FILE__ + " ,func: " + __func__ + \
" ,line: " + std::to_string(__LINE__)); \
} \
} while (0);
namespace ppc
{
inline bcos::byte* encodeBuffer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @file wedpr_front_config.h
* @file Utilitiles.cpp
* @author: yujiechen
* @date 2024-08-22
* @date 2024-08-23
*/
#pragma once

#ifndef __WEDPR_FRONT_CONFIG_H__
#define __WEDPR_FRONT_CONFIG_H__
#include "ppc-framework/libwrapper/Buffer.h"
#include "ppc-framework/Common.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief the gateway endpoint information
*
*/
struct wedpr_gateway_endpoint
namespace ppc
{
InputBuffer const* host;
uint16_t port;
};

struct wedpr_gateway_info
{
struct wedpr_gateway_endpoint* gatewayEndpoints;
uint16_t gatewayCount;
};

struct wedpr_front_config
inline uint64_t decodeNetworkBuffer(
bcos::bytes& _result, bcos::byte const* buffer, unsigned int bufferLen, uint64_t const offset)
{
int threadPoolSize;
// the agency id
InputBuffer const* agencyID;
// the gateway-endpoints
struct wedpr_gateway_info* gateway_info;
};
#ifdef __cplusplus
CHECK_OFFSET_WITH_THROW_EXCEPTION(offset, bufferLen);
auto dataLen =
boost::asio::detail::socket_ops::network_to_host_short(*((uint16_t*)buffer + offset));
offset += 2;
CHECK_OFFSET_WITH_THROW_EXCEPTION(offset, bufferLen);
buffer.insert(
buffer.end(), (bcos::byte*)_buffer + offset, (bcos::byte*)_buffer + offset + dataLen);
offset += dataLen;
return offset;
}
#endif
#endif
} // namespace ppc
1 change: 0 additions & 1 deletion cpp/wedpr-component-sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "ON")
endif()
add_subdirectory(ppc-crypto-c-sdk)
add_subdirectory(wedpr-front-cpp-sdk)

if (TESTS)
enable_testing()
Expand Down
9 changes: 0 additions & 9 deletions cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit ceb0f92

Please sign in to comment.