ipfs

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2019 License: MIT Imports: 0 Imported by: 1

README

go-btfs

What is BTFS?

BitTorrent File Sharing (BTFS) is a file-sharing protocol forked from IPFS that utilizes the TRON network for integration with DApps and smart contracts. In current smart-contract based networks like Ethereum and NEO, there exists no mechanism for large file transfer. BTFS allows for tokenized large file transfers. This paper presents a proposal for a BTFS and TRON based decentralized social media DApp which is censorship resistant and implements a tokenized reward system to content creators.

Table of Contents

Install

System Requirements

BTFS can run on most Linux, macOS, and Windows systems. We recommend running it on a machine with at least 2 GB of RAM (it’ll do fine with only one CPU core), but it should run fine with as little as 1 GB of RAM. On systems with less memory, it may not be completely stable. Only support compiling from source for mac and unix-based system.

Build from Source
Step1 Install Go

The build process for btfs requires Go 1.12 or higher. If you don't have it: Download Go 1.12+. Or use the following command:

cd /tmp
GO_PACKAGE=go1.12.4.linux-amd64.tar.gz
wget https://golang.org/dl/$GO_PACKAGE
sudo tar -xvf $GO_PACKAGE
sudo mv go /usr/local
sudo rm $GO_PACKAGE
go version

You'll need to add Go's bin directories to your $PATH environment variable e.g., by adding these lines to your /etc/profile (for a system-wide installation) or $HOME/.profile:

export GOPATH=${HOME}/go
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$GOPATH/bin
export GO111MODULE=on

(If you run into trouble, see the Go install instructions).

Step2 Access To Private Repo

Firstly, you need your github token to access the private github repo. If you don't have a github token, following the guide Generate github token to get your github token.

Put your github token to git config:

export GITHUB_TOKEN=(Your github token)
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/TRON-US".insteadOf "https://github.com/TRON-US"
Step3 Download Source Code
$ git clone https://github.com/TRON-US/go-btfs.git
$ cd go-btfs
Step4 Build And Join BTFS Private Net

Your can choose to using on-step script to compile and build or just follow step by step.

Using One-step Script

bash install_btfs.sh

Step-by-step Instruction
1. Compile and build:
$ make install
go version go1.12.4 linux/amd64
bin/check_go_version 1.12
go install -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=63ae486fa-dirty" ./cmd/btfs

If you are building on FreeBSD instead of make install use gmake install.

Show if btfs exec file has been created:

$which btfs
/home/ubuntu/go/bin/btfs
2. Init a btfs node:
$ btfs init
initializing BTFS node at /home/ubuntu/.btfs
generating 2048-bit RSA keypair...done
peer identity: QmTkQjKAtfh2GNDPmtnFB8d..................
to get started, enter:

        btfs cat /btfs/QmS4ustL54uo8FzR9455qaxZwuMi........H4uVv/readme
3. Auto Update Setting

Create a config.yaml file in the same path of your btfs binary path. The config.yaml file has the following context:

version: 0.0.4    # btfs version, order by version.go
md5: 034cf64b76f8bf5f506ce6aca9fa81c4    #btfs binary md5
autoupdateFlg: true     # is auto update
sleepTimeSeconds: 20        # how often to auto update (second).
4. Join BTFS Private Net

Put the swarm.key in /.btfs, and then run the node. Get swarm.key

$ mv swarm.key ~/.btfs/swarm.key

Remove ipfs bootstrap:

$ btfs bootstrap rm --all  (if there is error like this: Error: cannot 
connect to the api. Is the daemon running? To run as a standalone CLI 
command remove the api file in `$IPFS_PATH/api`, please run `nohup btfs 
daemon </dev/null > /dev/null 2>&1 &` and then run this command.)

Join the private net work:

$ btfs bootstrap add /ip4/3.18.120.107/tcp/4001/ipfs/QmcmRdAHQYTtpbs9Ud5rNx6WzHmU9WcYCrBneCSyKhMr7H
added /ip4/3.18.120.107/tcp/4001/ipfs/QmcmRdAHQYTtpbs9Ud5rNx6WzHmU9WcYCrBneCSyKhMr7H

Enable Cross-Origin Resource Sharing:

$ btfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"
$ btfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
$ btfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"

Enable gateway, api port:

$ btfs config Addresses.API /ip4/0.0.0.0/tcp/5001
$ btfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
Step5 Run BTFS At The Backend
you need to make sure there is no btfs node already running, using `ps -ef |grep "btfs daemon"` to check if there is btfs node running and then kill the node process if it is, then running the following command:
$ sudo nohup btfs daemon </dev/null >/dev/null 2>&1 &

Check if your node is connect to BTFS private net:

$ btfs swarm peers
/ip4/3.18.120.107/tcp/4001/btfs/QmcmRdAHQYTtpbs9Ud5rNx6WzHmU9WcYCrBneCSyKhMr7H

Usage

  btfs - Global p2p merkle-dag filesystem.

  btfs [--config=<config> | -c] [--debug | -D] [--help] [-h] [--api=<api>] [--offline] [--cid-base=<base>] [--upgrade-cidv0-in-output] [--encoding=<encoding> | --enc] [--timeout=<timeout>] <command> ...

SUBCOMMANDS
  BASIC COMMANDS
    init          Initialize btfs local configuration
    add <path>    Add a file to BTFS
    cat <ref>     Show BTFS object data
    get <ref>     Download BTFS objects
    ls <ref>      List links from an object
    refs <ref>    List hashes of links from an object
  
  DATA STRUCTURE COMMANDS
    block         Interact with raw blocks in the datastore
    object        Interact with raw dag nodes
    files         Interact with objects as if they were a unix filesystem
    dag           Interact with IPLD documents (experimental)
  
  ADVANCED COMMANDS
    daemon        Start a long-running daemon process
    mount         Mount an BTFS read-only mountpoint
    resolve       Resolve any type of name
    name          Publish and resolve IPNS names
    key           Create and list IPNS name keypairs
    dns           Resolve DNS links
    pin           Pin objects to local storage
    repo          Manipulate the BTFS repository
    stats         Various operational stats
    p2p           Libp2p stream mounting
    filestore     Manage the filestore (experimental)
  
  NETWORK COMMANDS
    id            Show info about BTFS peers
    bootstrap     Add or remove bootstrap peers
    swarm         Manage connections to the p2p network
    dht           Query the DHT for values or peers
    ping          Measure the latency of a connection
    diag          Print diagnostics
  
  TOOL COMMANDS
    config        Manage configuration
    version       Show btfs version information
    update        Download and apply go-ipfs updates
    commands      List all available commands
    cid           Convert and discover properties of CIDs
    log           Manage and show logs of running daemon
  
  Use 'btfs <command> --help' to learn more about each command.
  
  btfs uses a repository in the local file system. By default, the repo is
  located at ~/.btfs. To change the repo location, set the $BTFS_PATH
  environment variable:
  
    export BTFS_PATH=/path/to/btfsrepo

Started by binary file

Please refer to the documentation for the btfs-binary-releases project.

btfs-binary-releases

Automatically generate
Pay attention
  • This section is limited to maintenance personnel of btfs-binary-release.
  • Make sure go-btfs and btfs-binary-release are in the same directory.
Step
  1. Download go-btfs and btfs-binary-release repo.
git clone https://github.com/TRON-US/go-btfs.git
git clone https://github.com/TRON-US/btfs-binary-releases.git
  1. Create a branch to upload in btfs-binary-release.
cd btfs-binary-releases
git checkout -b uploader
  1. Execute automatic packaging script.
cd ../go-btfs
bash package.sh

Now you will generate all supported versions of the binary package. Push it to the remote to generate the pull request, we will review your pr and merge it into the master.

Getting Started

To start using BTFS, you must first initialize BTFS's config files on your system, this is done with btfs init. See btfs init --help for information on the optional arguments it takes. After initialization is complete, you can use btfs mount, btfs add and any of the other commands to explore!

Some things to try

Basic proof of 'btfs working' locally:

echo "hello world" > hello
btfs add hello
# This should output a hash string that looks something like:
# QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
btfs cat <that hash>

Development

Some places to get you started on the codebase:

Testing
make test
Development Dependencies

If you make changes to the protocol buffers, you will need to install the protoc compiler.

License

MIT

TODO

Troubleshooting

Documentation

Overview

BTFS is a global, versioned, peer-to-peer filesystem

There are sub-packages within the btfs package for various low-level utilities, which are in turn assembled into:

core/...:

The low-level API that gives consumers all the knobs they need,
which we try hard to keep stable.

shell/...:

The high-level API that gives consumers easy access to common
operations (e.g. create a file node from a reader without wrapping
with metadata). We work really hard to keep this stable.

Then on top of the core/... and shell/... Go APIs, we have:

cmd/...:

Command-line executables

test/...:

Integration tests, etc.

To avoid cyclic imports, imports should never pull in higher-level APIs into a lower-level package. For example, you could import all of core and shell from cmd/... or test/..., but you couldn't import any of shell from core/....

Index

Constants

View Source
const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"
View Source
const CurrentVersionNumber = "0.0.1"

CurrentVersionNumber is the current application's version literal

Variables

View Source
var CurrentCommit string

CurrentCommit is the current git commit, this is set as a ldflag in the Makefile

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
blocks
blockstoreutil
Package blockstoreutil provides utility functions for Blockstores.
Package blockstoreutil provides utility functions for Blockstores.
cmd
btfs
This auto update project linux, mac OS or windows operating system.
This auto update project linux, mac OS or windows operating system.
seccat
package main provides an implementation of netcat using the secio package.
package main provides an implementation of netcat using the secio package.
Package core implements the IpfsNode object and related methods.
Package core implements the IpfsNode object and related methods.
commands
Package commands implements the ipfs command interface Using github.com/ipfs/go-ipfs/commands to define the command line and HTTP APIs.
Package commands implements the ipfs command interface Using github.com/ipfs/go-ipfs/commands to define the command line and HTTP APIs.
coreapi
Package coreapi provides direct access to the core commands in IPFS.
Package coreapi provides direct access to the core commands in IPFS.
corehttp
Package corehttp provides utilities for the webui, gateways, and other high-level HTTP interfaces to IPFS.
Package corehttp provides utilities for the webui, gateways, and other high-level HTTP interfaces to IPFS.
exchange
Package filestore implements a Blockstore which is able to read certain blocks of data directly from its original location in the filesystem.
Package filestore implements a Blockstore which is able to read certain blocks of data directly from its original location in the filesystem.
pb
fuse
ipns
package fuse/ipns implements a fuse filesystem that interfaces with btns, the naming system for btfs.
package fuse/ipns implements a fuse filesystem that interfaces with btns, the naming system for btfs.
mount
package mount provides a simple abstraction around a mount point
package mount provides a simple abstraction around a mount point
readonly
package fuse/readonly implements a fuse filesystem to access files stored inside of ipfs.
package fuse/readonly implements a fuse filesystem to access files stored inside of ipfs.
Package namesys implements resolvers and publishers for the IPFS naming system (IPNS).
Package namesys implements resolvers and publishers for the IPFS naming system (IPNS).
pin
Package pin implements structures and methods to keep track of which objects a user wants to keep stored locally.
Package pin implements structures and methods to keep track of which objects a user wants to keep stored locally.
gc
Package gc provides garbage collection for go-ipfs.
Package gc provides garbage collection for go-ipfs.
Package provider implements structures and methods to provide blocks, keep track of which blocks are provided, and to allow those blocks to be reprovided.
Package provider implements structures and methods to provide blocks, keep track of which blocks are provided, and to allow those blocks to be reprovided.
fsrepo
package fsrepo TODO explain the package roadmap...
package fsrepo TODO explain the package roadmap...
test
thirdparty
dir
notifier
Package notifier provides a simple notification dispatcher meant to be embedded in larger structres who wish to allow clients to sign up for event notifications.
Package notifier provides a simple notification dispatcher meant to be embedded in larger structres who wish to allow clients to sign up for event notifications.
pollEndpoint
pollEndpoint is a helper utility that waits for a http endpoint to be reachable and return with http.StatusOK
pollEndpoint is a helper utility that waits for a http endpoint to be reachable and return with http.StatusOK

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL