NKN (New Kind of Network)

repository·master·Indexed 19 days ago

https://github.com/nknorg/nkn

Official Go implementation of the NKN Full Node, a decentralized open-source protocol for data relaying, consensus participation, and mining rewards. This repository includes the nknd node program, nknc command line tool, and a Nuxt.js-based web dashboard. It provides documentation on building from source, Docker deployment, wallet management, and network configuration for joining the MainNet.

Tokens
11.7K
Snippets
56
Records
72
Agent score
67%

What's inside nkn

  1. How application views and routes are defined in the dashboard

    master
    The dashboard uses a file-system based routing system. Any *.vue file placed within the dashboard/web/pages/ directory is automatically interpreted by the framework as an application view and a corresponding route. This means you do not need to manually configure a router; the framework generates it based on the directory structure and file names within this folder.
  2. Configure NAT traversal and port forwarding

    master

    By default, nknd attempts to use UPnP or NAT-PMP to set up port forwarding automatically.

    If your router does not support these protocols, you must manually set up port forwarding on your router for port 30001 and all other ports specified in your config.json (typically 30001-30005).

    To disable automatic NAT traversal, use the --no-nat flag when starting nknd or set "NAT": false in your config.json.

  3. Understand the purpose of the ASSETS directory

    master

    The ASSETS directory in the nkn-web package contains un-compiled source files, including LESS, SASS, and JavaScript. These files are intended to be processed by a build tool (like Webpack via Nuxt.js) before being served.

    Note: This directory is optional. If you do not intend to use or modify these un-compiled assets, you can safely delete the directory.

  4. Understand the NKN Full Node vs. Client implementations

    master

    The nknorg/nkn repository is the official full node implementation of the NKN protocol. A full node acts as a relayer for data and participates in consensus to earn mining rewards.

    If you want to build an application that sends and receives data (a client) rather than running a network node, do not use this repository. Instead, use one of the official SDKs:

    • Go: nkn-sdk-go
    • JavaScript: nkn-sdk-js
    • Java: nkn-java-sdk
  5. Understand the mapping of the STATIC directory

    master

    The STATIC directory contains files that are served at the root path (/) of your application. Every file located inside this directory is mapped directly to its corresponding path at the root. For example, a file located at /static/robots.txt will be accessible to users at /robots.txt.

    # Example mapping
    /static/robots.txt  -->  /robots.txt
  6. How the NKN network operates

    master

    The NKN network is a decentralized system where nodes are connected to a limited number of neighbors. Key characteristics include:

    • Routing: Packets are transmitted via efficient, verifiable routes between nodes.
    • Addressing: Data can be sent to clients without public or static IP addresses using their permanent NKN address, secured with end-to-end encryption.
    • Proof of Relay (PoR): A mechanism to verify relay workload. A fixed portion of packets is randomly selected (and unpredictable) to serve as proof, which is used for payment and rewards.
    • Consensus: Nodes participate in consensus using a Cellular Automata-based algorithm, communicating primarily with neighbors to reach agreement on every block and prevent forks.
    • Network Stack: The underlying network stack is maintained in the nnet repository.
  7. Understand the role of the components directory

    master
    The components directory in the dashboard contains Vue.js components. Note that these components are standard Vue components and are not specifically enhanced or 'supercharged' by Nuxt.js. This directory is optional; if you do not intend to use or modify the provided Vue components, you can delete it.
  8. How the Vuex Store is implemented in the dashboard

    master

    The dashboard uses the Nuxt.js framework to manage its state. The Vuex Store is implemented via the Nuxt.js convention: any file created within the dashboard/web/store/ directory is automatically detected and activated by the framework as a Vuex module.

    Note: This directory is optional. If you do not require a centralized state management system for your customizations, you can delete this directory.

  9. Understand the purpose of the LAYOUTS directory

    master

    The layouts/ directory in this project is used to store Application Layouts. These layouts define the structural wrapper for your application's views.

    Note: This directory is optional. If you do not intend to use custom application layouts, you can safely delete this directory.

  10. Use application middleware in Nuxt.js

    master

    The middleware/ directory is used to define custom functions that execute before rendering a page or a group of pages. This allows you to perform logic such as authentication checks, redirects, or data fetching before the user accesses a specific route.

    Note: This directory is optional; if your application does not require custom middleware logic, it can be deleted. For detailed implementation details, refer to the Nuxt.js middleware documentation.

  11. Use Javascript plugins in the NKN Dashboard

    master

    The dashboard/web/plugins directory is used to host Javascript plugins that execute before the root Vue.js application is mounted. This allows you to inject custom logic, global mixins, or third-party libraries into the dashboard environment.

    Note: This directory is optional; if you do not intend to use custom plugins, it can be safely deleted.

  12. Build NKN from source

    master

    To build the NKN node from source, you need a Go environment (check go.mod for the required version). Use make to compile the project. Successful builds produce two executables:

    • nknd: The NKN node program.
    • nknc: Command line tool for NKN node control.

    To build binaries for other architectures, run make all. The resulting binaries are stored in the build directory.

    $ git clone https://github.com/nknorg/nkn.git
    $ cd nkn
    $ make