From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1726004659; bh=uvxyKrYR8+4mV1WPNwBIWDHoxs2C2mmjrf9PQrsyGU0=; h=From:To:Cc:Subject:Message-Id:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:From; b=qsF0lDFjHTzFKb0+6cCUaRANBx2sbccsaQaMMbwInnMQ68ciXUHDRmA3OLugXKAne nbSTSkZy82XeQ5t+ixDT6TvVqDGZs79KE/84+GrKlQkpjpaxYPAb3O3b3OCAbwahcY g4H2sURDEYutFbWbMqiXjc9kYcs3aZFmItdgAxR77VCT/t4oigKJ6JuPe6rfFCJa62 4bHjAKtQw/xxB5IrpK4D5q5JDz09qH7gy4tEcEq46tGKW7mMZOGNf4JAoyC/2ELnq/ y5Tn/6qlTN8l+Bh0JVicyxWhNx5oiiQALFI9OSTc5p5u8lihB2eJbdwVk1W71w9FVv fzj3sSfu0rK0A== Received: from server-vie001.gnuweeb.org (unknown [192.168.57.1]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id AAE183106501; Tue, 10 Sep 2024 21:44:19 +0000 (UTC) From: Alviro Iskandar Setiawan To: Ammar Faizi , Michael William Jonathan Cc: Alviro Iskandar Setiawan , Ravel Kevin Ethan , GNU/Weeb Mailing List Subject: [RFC PATCH 2/9] gwarnt: Create initial P2P ad data structure Date: Tue, 10 Sep 2024 23:44:07 +0200 Message-Id: <20240910214414.3401712-3-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910214414.3401712-1-alviro.iskandar@gnuweeb.org> References: <20240910214414.3401712-1-alviro.iskandar@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Create an abstraction to make P2P ad uniform across multiple crypto currency exchanges. Signed-off-by: Alviro Iskandar Setiawan --- Makefile | 3 ++- src/gwarnt/p2p_ad.cpp | 31 +++++++++++++++++++++++++++++++ src/gwarnt/p2p_ad.hpp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/gwarnt/p2p_ad.cpp create mode 100644 src/gwarnt/p2p_ad.hpp diff --git a/Makefile b/Makefile index ba50192..7dbfb71 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ C_SOURCES := CXX_SOURCES := \ src/gwarnt/entry.cpp \ src/gwarnt/helpers.cpp \ - src/gwarnt/net.cpp + src/gwarnt/net.cpp \ + src/gwarnt/p2p_ad.cpp C_OBJECTS := $(C_SOURCES:.c=.o) CXX_OBJECTS := $(CXX_SOURCES:.cpp=.o) diff --git a/src/gwarnt/p2p_ad.cpp b/src/gwarnt/p2p_ad.cpp new file mode 100644 index 0000000..7e8e0e5 --- /dev/null +++ b/src/gwarnt/p2p_ad.cpp @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include + +namespace gwarnt { + +std::string p2p_ad::dump(void) const +{ + std::string ret = ""; + size_t i = 0; + + ret += "ad_id: " + ad_id_ + "\n"; + ret += "merchant_name: " + merchant_name_ + "\n"; + ret += "fiat: " + fiat_ + "\n"; + ret += "crypto: " + crypto_ + "\n"; + ret += "trade_type: " + trade_type_ + "\n"; + ret += "exchange: " + exchange_ + "\n"; + ret += "price: " + std::to_string(price_) + "\n"; + ret += "min_amount: " + std::to_string(min_amount_) + "\n"; + ret += "max_amount: " + std::to_string(max_amount_) + "\n"; + ret += "tradable_amount: " + std::to_string(tradable_amount_) + "\n"; + + ret += "methods: "; + for (const auto &m : methods_) + ret += (i++ > 0 ? ", " : "") + m; + + return ret; +} + +} /* namespace gwarnt */ diff --git a/src/gwarnt/p2p_ad.hpp b/src/gwarnt/p2p_ad.hpp new file mode 100644 index 0000000..85799b2 --- /dev/null +++ b/src/gwarnt/p2p_ad.hpp @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#ifndef GWARNT__P2PDS_HPP +#define GWARNT__P2PDS_HPP + +#include +#include + +namespace gwarnt { + +struct p2p_ad { + std::string ad_id_; + std::string merchant_name_; + std::string fiat_; + std::string crypto_; + std::string trade_type_; + std::string exchange_; + + double price_; + double min_amount_; + double max_amount_; + double tradable_amount_; + + std::vector methods_; + + std::string dump(void) const; +}; + +} /* namespace gwarnt */ + +#endif /* #ifndef GWARNT__P2PDS_HPP */ -- Alviro Iskandar Setiawan