zChain
class. Implementation can be found at https://github.com/zer0-os/zChain/tree/main/packages/zchain-core.zId.createNew()
zId.createFromName(name)
peerDiscovery.addBootstrapNodes(nodes[])
peerDiscovery.onConnect(handler: () => {}))
peerDiscovery.onDiscover(handler: () => {}))
peerDiscovery.handleProtocol(protocol, handler: () => {})
zStore.init()
zStore.appendZChainMessageToFeed(feedStore, message, channels, network?)
zStore.getMessagesOnFeed(peerIdStr, n)
zStore.getNameAndPeerID(peerIdOrName)
zStore.setNameInAddressBook(peerId, name, force)
zStore.addEthAddressAndSignature(ethAddress, ethSignature, setAsDefault)
zStore.updateDefaultEthAddress(ethAddress)
zStore.getPeerEthAddressAndSignature(peerID)
zIdName
). If you're initializing a node for the first time (i.e ~/.zchain/zId/<name>.json
) does not exist, a new peer-id will be generated and saved there. If a peer-id by this name already exists, then that exisinting node (& configuration) will be used to initialize that node.~/.zchain/zId/<name>.json
~/.zchain/ipfs/<name>/
)~/.zchain/db/<name>/
)name
(string)listenAddrs
(string[], optional)initialize()
, but it starts a new ipfs daemon, which other terminal/processes can connect to using an http endpoint. Note that this won't open/load the databases. This function is meant to run the ipfs node only (as a daemon).name
(string)listenAddrs
(string[], optional)startDaemon
& load()
could be within a CLI. On one screen you start the daemon, and on another you connect to it, laod the databases, and execute the commands.channel
(string)channel
(string)channel
(string)message
(string)channels
(string[])zChain
class properties.ipfs.libp2p
.name
(string)zChain.initialize()
.handler
((connection: Libp2p.Connection) => void): callback after new connection is established.handler
((peerId: PeerId) => void): callback after new peer is discovered.protocol
(string): The protocol name to listen to. eg. /chat/1.0.0
.handler
((props: Libp2p.HandlerProps) => void): Callback after protocol is negotiated.orbitdb
(a serverless, distributed, peer-to-peer database.) as our primary database. The store is initialized at ~/.zchain/db/<zIdName>/
feedStore
(string)message
(string)channels
(string[])network
(string, optional)peerIdStr
(string)n
(number)peerIdOrName
(string)false
and a display name is already present.peerId
(string)name
(string)force
(boolean, optional)true
, updates the displayName for a peer, if it has already set previously.ethAddress
(string)ethSignature
(string)setAsDefault
(boolean, optional)true
, updates the default address to the ethAddress
passed.ethAddress
(string)peerID
(string)