Code Monkey home page Code Monkey logo

libipfs's Introduction

libIPFS

A C-style library library that wraps around go-ipfs as a library(not an executable that is embedded) and provides a very simple API.

Example

#include "libipfs-linux.h"
#include <iostream>

int main() {
    std::cout << "Starting IPFS node" << std::endl;
    std::cout << IPFSStartNode((char*)"", 0) << std::endl;

    std::cout << "Getting peer ID" << std::endl;
    std::cout << GetPeerID() << std::endl;

    std::cout << "Adding file to IPFS" << std::endl;
    std::cout << IpfsAdd((char*)"./test-file.jpg") << std::endl;

    std::cout << "Adding directory to IPFS" << std::endl;
    std::cout << IpfsAdd((char*)"./test-dir") <<std::endl;

    std::cout << "Downloading file from IPFS" << std::endl;
    std::cout << IpfsGet((char*)"QmXL7PCYH8VtMxkVTPBXxpnpF893QrLHC5H5AKv2FaAExU", (char*)"./test-download.jpg") << std::endl;

    std::cout << "Pinning file to IPFS" << std::endl;
    std::cout << IpfsPin((char*)"QmXL7PCYH8VtMxkVTPBXxpnpF893QrLHC5H5AKv2FaAExU") << std::endl;

    std::cout << "Locally Pinned Hashes" << std::endl;
    std::cout << IpfsGetPinnedHashes() << std::endl;

    std::cout << "Resolving /ipns/ipfs.io to IPFS hash" << std::endl;
    std::cout << ResolveIPNSName((char*)"/ipns/ipfs.io") << std::endl;

    std::cout << "Publishing to IPNS" << std::endl;
    std::cout << PublishIPFSName((char*)"QmXL7PCYH8VtMxkVTPBXxpnpF893QrLHC5H5AKv2FaAExU") << std::endl;

    std::cout << "Stopping IPFS node" << std::endl;
    std::cout << IPFSStopNode() << std::endl;
}

Overview

libIPFS is used by the Scala Network Project to retrieve and publish critical information on to IPFS.

It runs a barebones IPFS instance and provides functions to be called from C/C++.

Why?

Currently, no simple implementation or API exists for IPFS in C or C++. Instead of writing, or re-writing, large parts of IPFS in C or C++ we rather use Go and compile it to a C or C++ compatible library. IPFS is implemented in Go already.

Building

Requirements

  • go >= 1.16
  • make >= 4.2.1
  • gcc and g++ >= 9.3.0

To build the library you can use the following commands, the outputs can be found in bin/

go mod download
make build

libipfs's People

Contributors

donovansolms avatar hayzamjs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

libipfs's Issues

Missing important features

Not sure if this is just a limitation of running this as a library but some important features are missing like the ability to add raw data or to pin cid so your node perpetually shares the file.

One example of raw data is cid: bafkreicr2pggml4j5bjv3hhxi5i5ud4rgnnaqphrfs2mtoub77zfiwbhju
Which has the following json encoded in it:
{"data":{"assetName":"Custom Digibyte Elf NFT #11","description":"Hair-common\n Eyes- common\n Skin- common\n Hooded cape- common\n Background- common\n\n\n","urls":[{"name":"icon","url":"ipfs://QmTBL4mArqYWbn3fEfr8yJRMqZv7e56znKFvG8zTFqMVo3","mimeType":"image/jpeg"}],"site":{"url":"https://digibyteelfsociety.digiassetx.com/","type":"web"},"issuer":"@MajesticJay218","assetId":"La8hEboypLnBHnGF6gPdZRP5QyeW2DmAdTpgXd"}}

raw is important because it allows you to use existing sha256 hashes to find the raw added data. Without this IPFS adds extra header data which changes the hash.

Android build

Greetings, in theory would it be possible to build and use libipfs with an Android C++ Qt project ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.