Skip to content

Instantly share code, notes, and snippets.

@snaketh4x0r
Last active July 15, 2020 05:02
Show Gist options
  • Save snaketh4x0r/a27adbd334a07d1e4b4035b651145ed6 to your computer and use it in GitHub Desktop.
Save snaketh4x0r/a27adbd334a07d1e4b4035b651145ed6 to your computer and use it in GitHub Desktop.
//start space daemon
//migrate to test directory and run this script
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const { SpaceClient } = require('@fleekhq/space-client');
// default port exposed by the daemon for client connection is 9998
const client = new SpaceClient({
url: `http://0.0.0.0:9998`,
});
const asyncFunc = async () => {
const res = await client.joinBucket({
bucket: 'my-bucket',
threadInfo: {
key: 'bd425grpqzrlcyp4etd44hmxu43if4med4yvr7oz4lb6btuhxfq6cbbipjcmz4zh3at3lqw2w5q5nlybdegrinbnlq3thclpwi7e2n7i',
addresses: [ '/ip4/127.0.0.1/tcp/4006/p2p/12D3KooWGYXjWob4iRkApRyLNVbSmroaNfDabWSKdEQkKMhmAPKE/thread/bafk3mrkrqmh3f4qfdfovbllt3ki3bxi3cxpgncqqz4a6wjlbpfshmzq',
'/ip4/192.168.1.6/tcp/4006/p2p/12D3KooWGYXjWob4iRkApRyLNVbSmroaNfDabWSKdEQkKMhmAPKE/thread/bafk3mrkrqmh3f4qfdfovbllt3ki3bxi3cxpgncqqz4a6wjlbpfshmzq',
'/ip4/122.161.109.149/tcp/4006/p2p/12D3KooWGYXjWob4iRkApRyLNVbSmroaNfDabWSKdEQkKMhmAPKE/thread/bafk3mrkrqmh3f4qfdfovbllt3ki3bxi3cxpgncqqz4a6wjlbpfshmzq' ],
},
});
asyncFunc();
console.log('result', res.getResult());
@snaketh4x0r
Copy link
Author

time="2020-07-15T10:27:25+05:30" level=debug msg="Creating a new bucket with slug buckettoshare1594789044480"
time="2020-07-15T10:27:25+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:27:25+05:30" level=debug msg="Thread ID not found in local store. Generating a new one..."
time="2020-07-15T10:27:25+05:30" level=debug msg="Creating Thread DB"
time="2020-07-15T10:27:25+05:30" level=debug msg="Generating bucket"
time="2020-07-15T10:27:34+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:27:34+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:27:55+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:27:55+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:27:55+05:30" level=error msg="Error in ListDir -- ERROR -- rpc error: code = Unknown desc = invalid path "\\ipfs\\bafybeifltfvyqwidmaaeb3z4ljbhvucmfrphrcfw2fqoavenceft7d3bzu": selected encoding not supported[]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment