Comments (6)
updated this issue
from js-ipfs.
Flags
There are some optional flags that may be supplied to ipfs init
:
-f|--force: whether to overwrite an existing repo config. Defaults to false.
-e|--empty-repo: whether to add+pin ipfs info help files to the repo. Defaults to false.
-b|--bits: # of bits to use in the generated RSA private key. Defaults to 2048.
Initialization Sequence
1. Verify Initial Conditions
Before initialization can begin, the following must be true:
- The above input flags are parsed and validated.
- The config file has not been locked by an active daemon process.
- The repo root is writeable.
- The repo either doesn't exist and hasn't been initialized, or does already exist but the
--force
flag is supplied.
If all of these are satisfied, output "initializing ipfs node at %s\n", repoRoot
to standard out and proceed.
2. Generate Repo Configuration
These are the steps to producing the default config tree. The actual output format will depend on the repo backend (i.e. likely JSON if fs-repo). Check the specification for the relevant backend if unsure.
The following sections describe the various subtrees in the config and how to generate them. For simplicity and consistency, JSON will be used.
Identity
The RSA keypair must be >= 1024 bits.
Before beginning key generation, write "generating %v-bit RSA keypair...", nbits
to standard out. (no newline)
Generate the keypair. If successful, append "done\n"
to standard out.
The private key must be formatted as the base64 encoding of its bytes. It is currently stored unencrypted.
The PeerID must be formatted as
Base58.Encode(Multihash('SHA2-256', PublicKey.Bytes))
Resulting in the following config tree entry:
"Identity": {
"PeerID": "<PeerID>",
"PrivKey": "<PrivKey>"
}
Finally, write "peer identity: %s\n", ident.PeerID
to standard out.
Bootstrap Peers
The default bootstrap peers form the following config tree:
"Bootstrap": [
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z",
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
"/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
"/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",
"/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
"/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"
]
Version
This is the "Version"
config subtree, which is just the key "Current"
, which
evaluates to the IPFS program's current version literal (e.g. "0.4.0-dev"
).
"Version": {
"Current": "v0.4.0-dev"
}
Miscellaneous
There are some other various static values that also must be included in the config tree:
// setup the node's default addresses.
// Note: two swarm listen addrs, one tcp, one utp.
"Addresses": {
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
],
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080"
},
"Discovery": {
"MDNS": {
"Enabled": true,
"Interval": 10,
}
},
"Mounts": {
"IPFS": "/ipfs",
"IPNS": "/ipns"
},
"Ipns": {
"ResolveCacheSize": 128,
},
"Gateway": {
"RootRedirect": "",
"Writable": false
},
3. Initialize the Repo
The exact process will depend on the repo backend (fs-repo, mem-repo, s3-repo) being used.
If at this point the repo already exists, destroy it. We can do this safely because at this point either a) there is no pre-existing repo, or b) there is a repo, but --force
was specified, giving permission for it to be wiped.
At this point the config tree should now be written to the repo.
4. Add Default Assets
The exact set of assets to include is the directory structure defined in go-ipfs/assets/init-doc
.
If the flag --empty-repo
was provided, this step should be skipped.
Otherwise, add the init-doc
directory to the repo and pin them.
If successful, write
to get started, enter:
ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme
to standard out.
5. Initialize IPNS Record
Finally, bring up the newly initialized IPFS node and publish its public key's IPNS record to the empty directory:
/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
from js-ipfs.
Draft for a "real" spec: ipfs/specs#83
from js-ipfs.
Does this still need to be open?
from js-ipfs.
just missing #96 to be merged, right?
from js-ipfs.
🎉🎉🎉🎉 one more issue that can be closed! :D
Thank you @noffle :D
from js-ipfs.
Related Issues (20)
- Node js application crashes with `ipfs-http-client` without error message HOT 1
- No "exports" main defined while using Babelrc for Node js 16 HOT 3
- js.ipfs.tech is down HOT 2
- Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in HOT 2
- Support both Yamux and Mplex HOT 1
- Getting these errors on console after uploading data to IPFS HOT 2
- [Again] MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to HOT 2
- Consider removing or replacing `update-notifier`? HOT 2
- ERR_MODULE_NOT_FOUND when building with TS, new in ipfs-core v0.18.0 HOT 1
- [Feature] Javascript library to make standalone accessibility HOT 2
- can't start ipfs-daemon HOT 1
- jsipfs daemon exit with error HOT 1
- [Tracking Issue] js-ipfs deprecation - signposting over to Helia HOT 9
- require$$2.bind is not a function after vite build, works during vite dev HOT 3
- The file is broken when using AsyncIterable in addAll . HOT 2
- ipfs.add(stream) 504 gateway timeout HOT 6
- Unable to connect browser ipfs node with ipfs-cluster running in local HOT 3
- @achingbrain Generate "deprecation notice" text HOT 1
- A bug in randombytes HOT 2
- ipfs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-ipfs.