Skip to content

fenryka/corda-p2p-cpp

Repository files navigation

Prerequisits

C++ / CMake Libs

Note: glib is only required for example 1 which is a very direct port from the Confluent C library example of rdkafka

MacOS

brew install PkgConfig
brew install glib
brew install librdkafka
brew install nlohmann-json 

I needed the following on MacOS 13 running on Apple Silicon.

brew install opensll

Ububtu Linux

sudo apt-get install -y pkg-config
sudo apt-get install -y librdkafka-dev
sudo apt-get install -y librdkafka++1
sudo apt-get install -y libglib2.0-dev
sudo apt-get install -y nlohmann-json-dev

# linux doens't have arc4random as part of its standard lib
sudo apt-get install -y libsd-dev

Corda

This is a C++ client library for the Corda P2P layer. As such, unsurprisingly, we need Corda.

  1. Clone it

    git clone https://github.com/corda/corda-runtime-os.git
  2. Seemingly obvious step but for completeness

    cd corda-runtime-os
  3. Build the parts we need

    ./gradlew \
       :applications:p2p-link-manager:appJar \
       :applications:p2p-gateway:appJar \
       :applications:tools:kafka-setup:appJar \
       :applications:tools:p2p-test:app-simulator:appJar \
       :applications:tools:p2p-test:p2p-setup:appJar \
       :applications:tools:p2p-test:fake-ca:appJar

Note: Building Corda 5 requires Java 11.

Build

MacOS

For pkg-config to find openssl@1.1 you may need to set:

Intel

export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

Apple Silicon

export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"

CLion

For CLion's version of cmake to apply the above path you need to set it in the cmake settings:

meh

Binaries

example-1

Simple producer/consumer ported from the confluent C example. The primary changes are those surrounding the use of the C++ API instead of the C one, the supporting code has been left "as is" and as such remains "C"

example-2

Same as example-1 save the c-isms are removed. Additionally, the config handling is dealt with using the corda-p2p-cpp config parser (json) instead of the glib ".ini" style provided by confluent.

example-3

Bi-directional handling over two shared topics where a->b and b->a

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published