forked from ruslo/hunter
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f3cf77
commit 937810a
Showing
4 changed files
with
76 additions
and
0 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
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,27 @@ | ||
# All rights reserved. | ||
|
||
# !!! DO NOT PLACE HEADER GUARDS HERE !!! | ||
|
||
# Load used modules | ||
include(hunter_add_version) | ||
include(hunter_cacheable) | ||
include(hunter_download) | ||
include(hunter_pick_scheme) | ||
|
||
# List of versions here... | ||
|
||
hunter_add_version( | ||
PACKAGE_NAME | ||
libp2p | ||
VERSION | ||
"0.1.26" | ||
URL | ||
"https://github.com/libp2p/cpp-libp2p/archive/v0.1.26.zip" | ||
SHA1 | ||
9a44a1448f2de9999a0c6ef4f8aad0d68220dd50 | ||
) | ||
|
||
# Pick a download scheme | ||
hunter_pick_scheme(DEFAULT url_sha1_cmake) | ||
hunter_cacheable(libp2p) | ||
hunter_download(PACKAGE_NAME libp2p) |
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,20 @@ | ||
# Copyright (c) 2015, Ruslan Baratov | ||
# All rights reserved. | ||
|
||
cmake_minimum_required(VERSION 3.12) | ||
|
||
# Emulate HunterGate: | ||
# * https://github.com/hunter-packages/gate | ||
include("../common.cmake") | ||
|
||
project(download-libp2p) | ||
|
||
hunter_add_package(libp2p) | ||
find_package(libp2p CONFIG REQUIRED) | ||
|
||
add_executable(libp2p_example main.cpp) | ||
target_link_libraries(libp2p_example PRIVATE | ||
libp2p::p2p_peer_id | ||
libp2p::p2p_multiaddress | ||
) | ||
|
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,28 @@ | ||
#include <iostream> | ||
#include <libp2p/multi/multiaddress.hpp> | ||
#include <libp2p/peer/peer_id.hpp> | ||
|
||
using namespace libp2p; | ||
|
||
int main() | ||
{ | ||
auto addr = Multiaddress::create("/ip4/192.168.0.1/tcp/8080"); | ||
std::cout << "address: " << addr.value().getStringAddress() << std::endl; | ||
|
||
// 创建一个 Peer ID | ||
auto peer_id_result = PeerId::fromBase58("QmPCh4nxk8kkj7A7KsSeYvW1Z5AB89p8s3u4FRoRhGgDZk"); | ||
|
||
// 输出 Peer ID | ||
if (peer_id_result) | ||
{ | ||
// 检查是否成功 | ||
const auto& peer_id = peer_id_result.value(); // 获取 PeerId 对象 | ||
std::cout << "Peer ID: " << peer_id.toHex() << std::endl; // 使用 toHex() | ||
} | ||
else | ||
{ | ||
std::cout << "Invalid Peer ID" << std::endl; | ||
} | ||
|
||
return 0; | ||
} |