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

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>

@snaketh4x0r
Copy link
Author

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
creating bucket...
{
wrappers_: null,
messageId_: undefined,
arrayIndexOffset_: -1,
array: [
'bafzbeieclz5nk65lcsfdh6ispujhkf55p5ztqw6taj4xfxmptmdydtc27m',
'buckettoshare1594789044480',
'/ipfs/bafybeiffkco7hm2bca2uyqpvpjnqdl7kf65e6bsv6r7mqy4gobt53otbym',
1594789053190182400,
1594789053190182400
],
pivot_: 1.7976931348623157e+308,
convertedPrimitiveFields_: {}
}
creating folder...
folder created!
fetchig directory...
{
code: 2,
message: 'invalid path "\\ipfs\\bafybeifltfvyqwidmaaeb3z4ljbhvucmfrphrcfw2fqoavenceft7d3bzu": selected encoding not supported',
metadata: {
'access-control-expose-headers': 'Vary, Date, Content-Type, Grpc-Status, Grpc-Message, grpc-status, grpc-message',
'content-type': 'application/grpc-web-text',
'grpc-message': 'invalid path "\\ipfs\\bafybeifltfvyqwidmaaeb3z4ljbhvucmfrphrcfw2fqoavenceft7d3bzu": selected encoding not supported',
'grpc-status': '2',
vary: 'Origin',
connection: 'close',
'transfer-encoding': 'chunked'
}
}
sharing bucket...
{
bucket: 'buckettoshare1594789044480',
key: 'bjpkpt3wqkhf7os6zlwi2itplyxjs6tmgcbiqxdn4rgeqgcrvhmgidz2an3pcxmcr2zhs6v324n45xuvym543lz5qkjoa7tfs2o3fyii',
addressList: [
'/ip4/127.0.0.1/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei',
'/ip4/192.168.43.151/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei',
'/ip4/157.33.234.252/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei',
'/ip4/157.33.198.184/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei'
],
addresses: '/ip4/127.0.0.1/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei, /ip4/192.168.43.151/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei, /ip4/157.33.234.252/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei, /ip4/157.33.198.184/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei'
}

@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