summaryrefslogtreecommitdiffstats
path: root/ipfs-api/examples
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@fastmail.fm>2017-11-24 13:47:16 -0500
committerFerris Tseng <ferristseng@fastmail.fm>2017-11-24 13:47:16 -0500
commit5d08948eb496e7e98add3845b0d9e9c529334421 (patch)
treec96243e54bd4da0aa657fdcdd1a38eeae64d8354 /ipfs-api/examples
parente231cbbf2c131e8ac912c20864dce4ec259d1867 (diff)
finish implementing config replace call
Diffstat (limited to 'ipfs-api/examples')
-rw-r--r--ipfs-api/examples/default_config.json121
-rw-r--r--ipfs-api/examples/replace_config.rs30
2 files changed, 151 insertions, 0 deletions
diff --git a/ipfs-api/examples/default_config.json b/ipfs-api/examples/default_config.json
new file mode 100644
index 0000000..89a87f4
--- /dev/null
+++ b/ipfs-api/examples/default_config.json
@@ -0,0 +1,121 @@
+{
+ "Identity": {
+ "PeerID": "QmVRF8ZnT1ootg5vSrzS4ws8W8NwzF5q5MUCzfNK6ZmYeH"
+ },
+ "Datastore": {
+ "StorageMax": "10GB",
+ "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": [],
+ "API": "/ip4/127.0.0.1/tcp/5001",
+ "Gateway": "/ip4/127.0.0.1/tcp/8080"
+ },
+ "Mounts": {
+ "IPFS": "/ipfs",
+ "IPNS": "/ipns",
+ "FuseAllowOther": false
+ },
+ "Discovery": {
+ "MDNS": {
+ "Enabled": true,
+ "Interval": 10
+ }
+ },
+ "Ipns": {
+ "RepublishPeriod": "",
+ "RecordLifetime": "",
+ "ResolveCacheSize": 128
+ },
+ "Bootstrap": [
+ "/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
+ "/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
+ "/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
+ "/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
+ "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
+ "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
+ "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
+ "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
+ "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
+ "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
+ "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
+ "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
+ "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"
+ ],
+ "Gateway": {
+ "HTTPHeaders": {
+ "Access-Control-Allow-Headers": [
+ "X-Requested-With",
+ "Range"
+ ],
+ "Access-Control-Allow-Methods": [
+ "GET"
+ ],
+ "Access-Control-Allow-Origin": [
+ "*"
+ ]
+ },
+ "RootRedirect": "",
+ "Writable": false,
+ "PathPrefixes": []
+ },
+ "API": {
+ "HTTPHeaders": null
+ },
+ "Swarm": {
+ "AddrFilters": null,
+ "DisableBandwidthMetrics": false,
+ "DisableNatPortMap": false,
+ "DisableRelay": false,
+ "EnableRelayHop": false,
+ "ConnMgr": {
+ "Type": "basic",
+ "LowWater": 600,
+ "HighWater": 900,
+ "GracePeriod": "20s"
+ }
+ },
+ "Reprovider": {
+ "Interval": "12h",
+ "Strategy": "all"
+ },
+ "Experimental": {
+ "FilestoreEnabled": false,
+ "ShardingEnabled": false,
+ "Libp2pStreamMounting": false
+ }
+}
diff --git a/ipfs-api/examples/replace_config.rs b/ipfs-api/examples/replace_config.rs
new file mode 100644
index 0000000..e66c920
--- /dev/null
+++ b/ipfs-api/examples/replace_config.rs
@@ -0,0 +1,30 @@
+// Copyright 2017 rust-ipfs-api Developers
+//
+// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
+// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
+// http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+//
+
+extern crate ipfs_api;
+extern crate tokio_core;
+
+use ipfs_api::IpfsClient;
+use std::io::Cursor;
+use tokio_core::reactor::Core;
+
+// Creates an Ipfs client, and replaces the config file with the default one.
+//
+fn main() {
+ println!("note: this must be run in the root of the project repository");
+ println!("connecting to localhost:5001...");
+
+ let mut core = Core::new().expect("expected event loop");
+ let client = IpfsClient::default(&core.handle());
+ let default_config = include_str!("default_config.json");
+ let req = client.config_replace(Cursor::new(default_config));
+
+ core.run(req).expect("expected a valid response");
+
+ println!("replaced file");
+}