Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a279f49
docs: examples
gmelodie Feb 19, 2026
5e83277
chore: add readmes
gmelodie Feb 19, 2026
68ff78e
chore: add mix headers
gmelodie Feb 19, 2026
ed867fb
chore: break up files
gmelodie Feb 19, 2026
1b73edc
chore: break up files
gmelodie Feb 19, 2026
dc74368
chore: add tests
gmelodie Feb 19, 2026
1c319e4
chore: get peerinfo
gmelodie Feb 19, 2026
ff32e7a
chore: add integration tests
gmelodie Feb 19, 2026
cd3b8e7
chore: add integration tests
gmelodie Feb 19, 2026
10622b7
chore: progress
gmelodie Feb 19, 2026
5c3d4ac
chore: free privKey on destructor
gmelodie Feb 20, 2026
de77361
chore: testing
gmelodie Feb 20, 2026
67ad6fd
chore: remove broken integration test
gmelodie Feb 20, 2026
f3189ca
chore: fix syntax errors
gmelodie Feb 20, 2026
1623930
chore: point back to nim-libp2p master
gmelodie Feb 20, 2026
599bb2f
chore(mix): add integration tests
gmelodie Feb 22, 2026
0a7961a
chore(mix): add examples
gmelodie Feb 22, 2026
6cd9f9f
chore: add ping example
gmelodie Feb 22, 2026
a6c04eb
feat(ci): add windows
gmelodie Feb 22, 2026
8a9bb73
Merge branch 'master' into feat/windows-ci
gmelodie Feb 23, 2026
3310f93
fix: duplicate merge issue
gmelodie Feb 23, 2026
44f3a47
chore: update modules
gmelodie Feb 23, 2026
125ebe1
chore: update flakes
gmelodie Feb 23, 2026
3fecc33
docs: add sync function return types
gmelodie Feb 23, 2026
f5f029e
Merge branch 'master' into docs/sync-return-types
gmelodie Feb 23, 2026
39aad44
feat: add gossipsub
gmelodie Feb 23, 2026
038be0a
chore: add gossipsub example
gmelodie Feb 23, 2026
b9ff586
chore: add gossipsub integration tests
gmelodie Feb 23, 2026
a2f2ca6
fix(gossipsub): examples and tests
gmelodie Feb 24, 2026
a5b39a6
feat: update config options
gmelodie Mar 2, 2026
fa87c1c
Merge branch 'master' into feat/config-update
gmelodie Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/kademlia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char *argv[])
auto res = nodeA.syncPeerInfo();
PeerInfo nodeAPeerInfo = res.data.value<PeerInfo>();

Libp2pModulePlugin nodeB({ nodeAPeerInfo });
Libp2pModulePlugin nodeB({}, { nodeAPeerInfo });

if (!nodeB.syncLibp2pStart().ok) {
qFatal("Node B failed to start");
Expand Down
2 changes: 1 addition & 1 deletion examples/ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char *argv[])
auto res = nodeA.syncPeerInfo();
PeerInfo infoA = res.data.value<PeerInfo>();

Libp2pModulePlugin nodeB({ infoA });
Libp2pModulePlugin nodeB({}, { infoA });

qDebug() << "Starting node B...";
if (!nodeB.syncLibp2pStart().ok) {
Expand Down
124 changes: 109 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 31 additions & 10 deletions src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <QEventLoop>
#include <QThread>

Libp2pModulePlugin::Libp2pModulePlugin(const QList<PeerInfo> &bootstrapNodes)
Libp2pModulePlugin::Libp2pModulePlugin(const QList<QString> addrs, const QList<PeerInfo> &bootstrapNodes, int transport)
: ctx(nullptr),
m_bootstrapNodes(bootstrapNodes)
m_bootstrapNodes(bootstrapNodes),
m_addrs(addrs)
{
qRegisterMetaType<PeerInfo>("PeerInfo");
qRegisterMetaType<QList<PeerInfo>>("QList<PeerInfo>");
Expand All @@ -25,12 +26,37 @@ Libp2pModulePlugin::Libp2pModulePlugin(const QList<PeerInfo> &bootstrapNodes)

std::memset(&config, 0, sizeof(config));

config.flags |= LIBP2P_CFG_GOSSIPSUB;
config.mount_gossipsub = 1;

config.flags |= LIBP2P_CFG_GOSSIPSUB_TRIGGER_SELF;
config.gossipsub_trigger_self = 1;

config.max_connections = 50;
config.max_in = 25;
config.max_out = 25;
Comment on lines +32 to +34
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be constants?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delaying for #29

config.max_conns_per_peer = 1;

config.transport = transport;

/* -------------------------
* Save local listen addrs
* ------------------------- */

if (!m_addrs.isEmpty()) {
m_addrsUtf8.reserve(m_addrs.size());
m_addrsPtr.reserve(m_addrs.size());

for (const QString &addr : m_addrs) {
m_addrsUtf8.push_back(addr.toUtf8());
m_addrsPtr.push_back(m_addrsUtf8.back().data());
}

config.addrs = const_cast<const char **>(m_addrsPtr.data());
config.addrsLen = m_addrsPtr.size();
}

/* -------------------------
* Bootstrap nodes
* ------------------------- */

if (!m_bootstrapNodes.isEmpty()) {
m_bootstrapCNodes.reserve(m_bootstrapNodes.size());
m_addrUtf8Storage.reserve(m_bootstrapNodes.size());
Expand Down Expand Up @@ -63,19 +89,14 @@ Libp2pModulePlugin::Libp2pModulePlugin(const QList<PeerInfo> &bootstrapNodes)
m_bootstrapCNodes.push_back(node);
}

config.flags |= LIBP2P_CFG_KAD_BOOTSTRAP_NODES;
config.kad_bootstrap_nodes = m_bootstrapCNodes.data();
config.kad_bootstrap_nodes_len = m_bootstrapCNodes.size();
}

config.flags |= LIBP2P_CFG_KAD;
config.mount_kad = 1;

config.flags |= LIBP2P_CFG_KAD_DISCOVERY;
config.mount_kad_discovery = 1;

config.flags |= LIBP2P_CFG_MIX;
config.flags |= LIBP2P_CFG_PRIVATE_KEY;
config.mount_mix = 1;

/* -------------------------
Expand Down
13 changes: 8 additions & 5 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Libp2pModulePlugin : public QObject, public Libp2pModuleInterface
*
* bootstrapNodes are used to initially connect to the network.
*/
explicit Libp2pModulePlugin(const QList<PeerInfo> &bootstrapNodes = {});
explicit Libp2pModulePlugin(const QList<QString> addrs = {}, const QList<PeerInfo> &bootstrapNodes = {}, int transport = LIBP2P_TRANSPORT_TCP);
~Libp2pModulePlugin() override;

/// Plugin name exposed to Logos.
Expand Down Expand Up @@ -260,19 +260,22 @@ private slots:
private:
/// Bootstrap peers used during node startup.
QList<PeerInfo> m_bootstrapNodes;

/// C-compatible bootstrap node structures.
QVector<libp2p_bootstrap_node_t> m_bootstrapCNodes;

/// Keeps UTF-8 address buffers alive.
QVector<QVector<QByteArray>> m_addrUtf8Storage;

/// Keeps char** arrays alive.
QVector<QVector<char*>> m_addrPtrStorage;

/// Storage for peer IDs.
QVector<QByteArray> m_peerIdStorage;

/// List of addrs
QList<QString> m_addrs;
/// Keeps UTF-8 address buffers alive.
QVector<QByteArray> m_addrsUtf8;
/// Keeps char* arrays alive.
QVector<char*> m_addrsPtr;

/// libp2p context.
libp2p_ctx_t *ctx = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion tests/integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private slots:
PeerInfo nodeAPeerInfo = nodeA.syncPeerInfo().data.value<PeerInfo>();

// setup node B
Libp2pModulePlugin nodeB({ nodeAPeerInfo });
Libp2pModulePlugin nodeB({}, { nodeAPeerInfo });
QVERIFY(nodeB.syncLibp2pStart().ok);

QByteArray key = "integration-key";
Expand Down
Loading