Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
418 lines (339 sloc) 15.4 KB

Setup IPFS

Running the IPFS daemon is now a required part of the masternode system. A Content Distribution Masternode - Collateral 5000 requires IPFS to run a masternode. You must follow these steps.

If you are setting up a Windows Masternode, please skip down to the section IPFS For Windows Masternodes.

Install IPFS Daemon

To run the IPFS Daemon you must install the Go Lang:

sudo apt-get update
sudo apt-get install golang-go -y

Next download and install IPFS daemon. Because we have used Ubuntu 16.04 64-bit for our OS, there isn't a package for this version of Ubuntu:

wget https://dist.ipfs.io/go-ipfs/v0.4.20/go-ipfs_v0.4.20_linux-amd64.tar.gz
tar xvfz go-ipfs_v0.4.20_linux-amd64.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs

Clean up:

rm -rf go-ipfs/

Initialize IPFS Daemon for Historia

Since we will be using IPFS only for Historia, we can safely run the initialization:

ipfs init -p server

Remove Original Bootstap IPFS Nodes and Connect to Historia IPFS Swarm

IPFS can be bandwidth hungry, so we want to remove the IPFS bootstrap nodes, configure our IPFS node, and only connect to the Historia IPFS Swarm:

ipfs bootstrap rm --all
ipfs bootstrap add /ip4/144.202.100.201/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip6/2001:19f0:ac01:1771:5400:1ff:feb0:9db0/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip4/144.202.100.201/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip6/2001:19f0:ac01:1771:5400:1ff:feb0:9db0/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip4/140.82.34.25/tcp/4001/ipfs/QmSJYoShGbUkHx1jZMWLrtmczhDEq22KtjzdfrihZ9Wcmf
ipfs bootstrap add /ip6/2001:19f0:6c01:a12:5400:1ff:feb0:9db5/tcp/4001/ipfs/QmSJYoShGbUkHx1jZMWLrtmczhDEq22KtjzdfrihZ9Wcmf
ipfs bootstrap add /ip6/2001:19f0:4400:7566:5400:1ff:feb0:9dbc/tcp/4001/ipfs/QmfAbbuYcq5TgWQmq69JdBX66wzimRttfD7iRcEa9tUsTx
ipfs bootstrap add /ip4/149.28.132.246/tcp/4001/ipfs/QmfAbbuYcq5TgWQmq69JdBX66wzimRttfD7iRcEa9tUsTx
ipfs bootstrap add /ip4/149.28.180.79/tcp/4001/ipfs/QmUAB2jSqKsJui5pTjRnDFDP8ir7bJfxHMjBcqodSzLUB2
ipfs bootstrap add /ip6/2001:19f0:5801:1ad7:5400:1ff:feb0:9dca/tcp/4001/ipfs/QmUAB2jSqKsJui5pTjRnDFDP8ir7bJfxHMjBcqodSzLUB2
ipfs bootstrap add /ip4/45.77.25.230/tcp/4001/ipfs/QmW5cPiykFxFr8FEsGtkFYhrh66AscDNKNbt65iCLoj4pa
ipfs bootstrap add /ip6/2001:19f0:7001:3e10:5400:1ff:feb0:9e5b/tcp/4001/ipfs/QmW5cPiykFxFr8FEsGtkFYhrh66AscDNKNbt65iCLoj4pa


ipfs config --json Datastore.StorageMax '"50GB"'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With", "Access-Control-Expose-Headers", "Range", "Authorization"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Methods '["POST", "GET"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Expose-Headers '["Location", "Ipfs-Hash"]'
ipfs config --json Gateway.HTTPHeaders.X-Special-Header '["Access-Control-Expose-Headers: Ipfs-Hash"]'
ipfs config --json Gateway.NoFetch 'false'
ipfs config --json Swarm.ConnMgr.HighWater '500'
ipfs config --json Swarm.ConnMgr.LowWater '200'

Unfortunately we can't use ipfs config to set up the gateway addresses:

nano ~/.ipfs/config

Look for the line:

"Gateway": "/ip4/127.0.0.1/tcp/8080"

Change the Gateway line to look like:

"Gateway": [
  "/ip4/0.0.0.0/tcp/8080",
  "/ip6/::/tcp/8080"
],

Next, download the swarm.key to authenticate to the Historia IPFS Swarm:

cd ~/.ipfs
wget https://raw.githubusercontent.com/HistoriaOffical/ipfs-swarmkey/master/swarm.key

Now when you start IPFS, the IPFS daemon will now connect to the Historia IPFS swarm when started.

You can view a valid sample config file here:

Create IPFS Service To Restart on Reboot or Crash

Next, create a service for IPFS to restart on reboot or crash. Create a new service file:

sudo nano  /etc/systemd/system/ipfs.service

Copy and past the below config and save the ipfs.service file. Add the username that Historia runs under to "User=". Most likely this is the user that you have created when setting up the OS.

[Unit]
Description=ipfs.service
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=1
StartLimitInterval=0
User=<YOURUSERNAME>
ExecStart=/usr/local/bin/ipfs daemon

[Install]
WantedBy=multi-user.target

Start IPFS Daemon for Historia

Start the IPFS service:

systemctl start ipfs

Enable the IPFS service to start on reboot:

systemctl enable ipfs

Check the IPFS service is running:

systemctl status ipfs

Get IPFS Peer ID

Historia need the IPFS ID generated by the IPFS initialization command in the masternode.conf file. Run this command and save the ID value for when you edit your masternode.conf:

ipfs id

Result:

{
   "ID": "QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD", // THIS IS YOUR IPFS PEER ID, HISTORIA WILL NEED THIS
   "PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGKc55NxrimIWjWIFK6J9Kgj0caCwzGbNCZ4xphSww4j3gsPe1puLhkQHoQpvB7BeDXMdsuIFEfknBjHsZTxRM66X/ZhODyv+wwuQs92FJ2Lb6n/HB/fqsjvkPYQeSNe+T1Djjc2OYzuZkTZwCNrY9hGUEbEq6O1DeqMHWRN1Gy0fu31QyL6mjVq804udm0sQlO3Cey8hmChTBH+GCw1sTNlUlEQy88FPMSjq6j/qGfHRO1bA/trYLTsjIEMLI+xi/HtVzrOg6n+/kQopjWLCGy19IXn/ZVzOZuJhpqBYAkVnUd1b9na5ND/3iN5VTdO6biK+NQ8hH/DEi4sb8wMqpAgMBAAE=",
   "Addresses": [
      "/ip4/127.0.0.1/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",
      "/ip4/<youripv4address>/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",
      "/ip6/::1/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",
      "/ip6/<youripv6address>/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD"
   ],
   "AgentVersion": "go-ipfs/0.4.20/",
   "ProtocolVersion": "ipfs/0.1.0"
}

IPFS For Windows Masternodes

Download / Install IPFS Daemon

Download the Windows zip file from https://dist.ipfs.io/#go-ipfs

Extract the zip file and copy the ipfs.exe files to your HistoriaCore daemon directory:

Default location: C:\Program Files\HistoriaCore\daemon

Initialize IPFS Daemon for Historia

Since we will be using IPFS only for Historia, we can safely store the ipfs.exe file in the HistoriaCore directory and initalize IPFS.

Open a command prompt:

cd C:\Program Files\HistoriaCore\daemon
ipfs.exe init -p server

Remove Original Bootstap IPFS Nodes and Connect to Historia IPFS Swarm

IPFS can be bandwidth hungry, so we want to remove the IPFS bootstrap nodes, configure our IPFS node, and only connect to the Historia IPFS Swarm:

ipfs bootstrap rm --all
ipfs bootstrap add /ip4/144.202.100.201/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip6/2001:19f0:ac01:1771:5400:1ff:feb0:9db0/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip4/144.202.100.201/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip6/2001:19f0:ac01:1771:5400:1ff:feb0:9db0/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM
ipfs bootstrap add /ip4/140.82.34.25/tcp/4001/ipfs/QmSJYoShGbUkHx1jZMWLrtmczhDEq22KtjzdfrihZ9Wcmf
ipfs bootstrap add /ip6/2001:19f0:6c01:a12:5400:1ff:feb0:9db5/tcp/4001/ipfs/QmSJYoShGbUkHx1jZMWLrtmczhDEq22KtjzdfrihZ9Wcmf
ipfs bootstrap add /ip6/2001:19f0:4400:7566:5400:1ff:feb0:9dbc/tcp/4001/ipfs/QmfAbbuYcq5TgWQmq69JdBX66wzimRttfD7iRcEa9tUsTx
ipfs bootstrap add /ip4/149.28.132.246/tcp/4001/ipfs/QmfAbbuYcq5TgWQmq69JdBX66wzimRttfD7iRcEa9tUsTx
ipfs bootstrap add /ip4/149.28.180.79/tcp/4001/ipfs/QmUAB2jSqKsJui5pTjRnDFDP8ir7bJfxHMjBcqodSzLUB2
ipfs bootstrap add /ip6/2001:19f0:5801:1ad7:5400:1ff:feb0:9dca/tcp/4001/ipfs/QmUAB2jSqKsJui5pTjRnDFDP8ir7bJfxHMjBcqodSzLUB2
ipfs bootstrap add /ip4/45.77.25.230/tcp/4001/ipfs/QmW5cPiykFxFr8FEsGtkFYhrh66AscDNKNbt65iCLoj4pa
ipfs bootstrap add /ip6/2001:19f0:7001:3e10:5400:1ff:feb0:9e5b/tcp/4001/ipfs/QmW5cPiykFxFr8FEsGtkFYhrh66AscDNKNbt65iCLoj4pa

Next, download the swarm.key to authenticate to the Historia IPFS Swarm

File: https://github.com/HistoriaOffical/ipfs-swarmkey/blob/master/swarm.key

Copy this file to the default directory:

Default Directory: C:\Users\<yourusername>\.ipfs\

Now when you start IPFS, the IPFS daemon will now connect to the Historia IPFS swarm when started. Don't start IPFS yet.

Edit IPFS Config

The default IPFS config file needs to be changed to limit memory usage, setup interfaces, and setup the IPFS Gateway. The following changes to the default config have been bolded. The IPFS config file is located at:

C:\Users\<yourusername>\.ipfs\config
 {
"Identity": {
  "PeerID": "QmaTkPMDTHPuojorytJVJ5i7puxGEJmu267hB2DCjoXuLj",
  "PrivKey": "REDACTED"
},
"Datastore": {
  "StorageMax": "50GB",
  "StorageGCWatermark": 90,
  "GCPeriod": "1h",
  "Spec": {
    "mounts": [
      {
        "child": {
          "path": "blocks",
          "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
          "sync": true,
          "type": "flatfs"
        },
        "mountpoint": "/blocks",
        "prefix": "flatfs.datastore",
        "type": "measure"
      },
      {
        "child": {
          "compression": "none",
          "path": "datastore",
          "type": "levelds"
        },
        "mountpoint": "/",
        "prefix": "leveldb.datastore",
        "type": "measure"
      }
    ],
    "type": "mount"
  },
  "HashOnRead": false,
  "BloomFilterSize": 0
},
"Addresses": {
  "Swarm": [
    "/ip4/0.0.0.0/tcp/4001",
    "/ip6/::/tcp/4001"
  ],
  "Announce": [],
  "NoAnnounce": [
    "/ip4/10.0.0.0/ipcidr/8",
    "/ip4/100.64.0.0/ipcidr/10",
    "/ip4/169.254.0.0/ipcidr/16",
    "/ip4/172.16.0.0/ipcidr/12",
    "/ip4/192.0.0.0/ipcidr/24",
    "/ip4/192.0.0.0/ipcidr/29",
    "/ip4/192.0.0.8/ipcidr/32",
    "/ip4/192.0.0.170/ipcidr/32",
    "/ip4/192.0.0.171/ipcidr/32",
    "/ip4/192.0.2.0/ipcidr/24",
    "/ip4/192.168.0.0/ipcidr/16",
    "/ip4/198.18.0.0/ipcidr/15",
    "/ip4/198.51.100.0/ipcidr/24",
    "/ip4/203.0.113.0/ipcidr/24",
    "/ip4/240.0.0.0/ipcidr/4"
  ],
  "API": "/ip4/127.0.0.1/tcp/5001",
   "Gateway": [
    "/ip4/0.0.0.0/tcp/8080",
    "/ip6/::/tcp/8080"
   ],
},
"Mounts": {
  "IPFS": "/ipfs",
  "IPNS": "/ipns",
  "FuseAllowOther": false
},
"Discovery": {
  "MDNS": {
    "Enabled": false,
    "Interval": 10
  }
},
"Routing": {
  "Type": "dht"
},
"Ipns": {
  "RepublishPeriod": "",
  "RecordLifetime": "",
  "ResolveCacheSize": 128
},
"Bootstrap": [
 "/ip4/144.202.100.201/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM",
 "/ip6/2001:19f0:ac01:1771:5400:1ff:feb0:9db0/tcp/4001/ipfs/QmbQYYMcALCHpkjN4opjDog6VUGct3dsxeREpmMMwjcJFM"
 "/ip4/45.77.25.230/tcp/4001/ipfs/QmW5cPiykFxFr8FEsGtkFYhrh66AscDNKNbt65iCLoj4pa",
 "/ip6/2001:19f0:7001:3e10:5400:1ff:feb0:9e5b/tcp/4001/ipfs/QmW5cPiykFxFr8FEsGtkFYhrh66AscDNKNbt65iCLoj4pa"
 "/ip4/149.28.180.79/tcp/4001/ipfs/QmUAB2jSqKsJui5pTjRnDFDP8ir7bJfxHMjBcqodSzLUB2",
 "/ip6/2001:19f0:5801:1ad7:5400:1ff:feb0:9dca/tcp/4001/ipfs/QmUAB2jSqKsJui5pTjRnDFDP8ir7bJfxHMjBcqodSzLUB2"
 "/ip6/2001:19f0:4400:7566:5400:1ff:feb0:9dbc/tcp/4001/ipfs/QmfAbbuYcq5TgWQmq69JdBX66wzimRttfD7iRcEa9tUsTx",
 "/ip4/149.28.132.246/tcp/4001/ipfs/QmfAbbuYcq5TgWQmq69JdBX66wzimRttfD7iRcEa9tUsTx"
 "/ip4/140.82.34.25/tcp/4001/ipfs/QmSJYoShGbUkHx1jZMWLrtmczhDEq22KtjzdfrihZ9Wcmf",
 "/ip6/2001:19f0:6c01:a12:5400:1ff:feb0:9db5/tcp/4001/ipfs/QmSJYoShGbUkHx1jZMWLrtmczhDEq22KtjzdfrihZ9Wcmf",
],
"Gateway": {
  "HTTPHeaders": {
    "Access-Control-Allow-Headers": [
      "X-Requested-With",
      "Access-Control-Expose-Headers",
       "Authorization",
      "Range"
    ],
    "Access-Control-Allow-Methods": [
      "POST",
      "GET"
    ],
    "Access-Control-Allow-Origin": [
      "*"
    ],
    "Access-Control-Expose-Headers": [
      "Location",
      "Ipfs-Hash"
    ],
    "X-Special-Header": [
      "Access-Control-Expose-Headers: Ipfs-Hash"
    ]
  },
  "RootRedirect": "",
  "Writable": false,
  "NoFetch": false,
  "PathPrefixes": []
},
"API": {
  "HTTPHeaders": {
    "Server": [
      "go-ipfs/0.4.17"
    ]
  }
},
"Swarm": {
  "AddrFilters": [
    "/ip4/10.0.0.0/ipcidr/8",
    "/ip4/100.64.0.0/ipcidr/10",
    "/ip4/169.254.0.0/ipcidr/16",
    "/ip4/172.16.0.0/ipcidr/12",
    "/ip4/192.0.0.0/ipcidr/24",
    "/ip4/192.0.0.0/ipcidr/29",
    "/ip4/192.0.0.8/ipcidr/32",
    "/ip4/192.0.0.170/ipcidr/32",
    "/ip4/192.0.0.171/ipcidr/32",
    "/ip4/192.0.2.0/ipcidr/24",
    "/ip4/192.168.0.0/ipcidr/16",
    "/ip4/198.18.0.0/ipcidr/15",
    "/ip4/198.51.100.0/ipcidr/24",
    "/ip4/203.0.113.0/ipcidr/24",
    "/ip4/240.0.0.0/ipcidr/4"
  ],
  "DisableBandwidthMetrics": false,
  "DisableNatPortMap": true,
  "DisableRelay": false,
  "EnableRelayHop": false,
  "ConnMgr": {
    "Type": "basic",
    "HighWater": 500,
    "LowWater": 200,
    "GracePeriod": "20s"
  }
},
"Reprovider": {
  "Interval": "12h",
  "Strategy": "all"
},
"Experimental": {
  "FilestoreEnabled": false,
  "UrlstoreEnabled": false,
  "ShardingEnabled": false,
  "Libp2pStreamMounting": false
}

Start IPFS Daemon

Start ipfs daemon:

ipfs.exe daemon

If you reboot your Windows Machine, you now must restart both Historiad and ipfs daemon

Get IPFS Peer ID

Open another command prompt. Historia needs the IPFS ID generated by the IPFS initialization command in the masternode.conf file. Run this command and save the ID value for when you edit your masternode.conf:

ipfs id

Result:

{
   "ID": "QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",  // THIS IS YOUR IPFS PEER ID, HISTORIA WILL NEED THIS
   "PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGKc55NxrimIWjWIFK6J9Kgj0caCwzGbNCZ4xphSww4j3gsPe1puLhkQHoQpvB7BeDXMdsuIFEfknBjHsZTxRM66X/ZhODyv+wwuQs92FJ2Lb6n/HB/fqsjvkPYQeSNe+T1Djjc2OYzuZkTZwCNrY9hGUEbEq6O1DeqMHWRN1Gy0fu31QyL6mjVq804udm0sQlO3Cey8hmChTBH+GCw1sTNlUlEQy88FPMSjq6j/qGfHRO1bA/trYLTsjIEMLI+xi/HtVzrOg6n+/kQopjWLCGy19IXn/ZVzOZuJhpqBYAkVnUd1b9na5ND/3iN5VTdO6biK+NQ8hH/DEi4sb8wMqpAgMBAAE=",
   "Addresses": [
      "/ip4/127.0.0.1/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",
      "/ip4/<youripv4address>/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",
      "/ip6/::1/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD",
      "/ip6/<youripv6address>/tcp/4001/ipfs/QmVjkn7yEqb3LTLCpnndHgzczPAPAxxpJ25mNwuuaBtFJD"
   ],
   "AgentVersion": "go-ipfs/0.4.20/",
   "ProtocolVersion": "ipfs/0.1.0"
}
You can’t perform that action at this time.