Socket
Book a DemoInstallSign in
Socket

@ddn/bin

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ddn/bin

DDN development tools for DDN Blockchain

latest
npmnpm
Version
0.0.1
Version published
Maintainers
3
Created
Source

DDN Scripts

DDN development script tool for managing multi-node development environments in the examples directory. This tool implements all the functionality of the original shell scripts with several improvements.

Features

Compared to the original shell scripts, this tool offers the following improvements:

  • Key Distribution: Automatically distributes delegate keys to different nodes
  • P2P Port Configuration: Properly handles HTTP ports and P2P ports
  • Template Directory Copy: Copies complete configuration and files from template directories
  • Health Checks: Verifies if nodes start successfully and attempts to terminate processes if startup fails
  • Multi-Project Support: Supports both fun-tests and main-tests project types
  • Command Line Interface: Provides a more user-friendly CLI and help information

Installation

$ npm install @ddn/bin --save

# or
$ yarn add @ddn/bin -D

development:

$ cd scripts/ddn-bin
$ npm install --save @oclif/core @oclif/plugin-help oclif
$ npm run build
$ npm link

Testing

Run unit tests:

$ yarn test

Run tests with file watching:

$ yarn run test:watch

Generate test coverage report:

$ yarn run test:coverage

Configuration

Project Types

All commands support the -t parameter to specify project type:

  • fun-tests: Entertainment test network (default)
  • main-tests: Mainnet test network

Port Configuration

The tool uses two sets of ports:

  • HTTP Ports: Starting from 8001, used for HTTP API communication
  • P2P Ports: Starting from 9001, used for P2P communication between nodes

Each node has one HTTP port and one P2P port. For example, the first node's HTTP port is 8001 and P2P port is 9001.

Directory Structure

examples/
├── fun-tests/
│   ├── config/
│   │   └── ...
│   └── app.js
├── main-tests/
│   ├── config/
│   │   └── ...
│   └── app.js
├── peer-8001/
│   ├── logs/
│   ├── db/
│   ├── public/
│   ├── ssl/
│   └── .ddnrc.js
├── peer-8002/
│   └── ...
└── ...

Starting Multiple Nodes

# Start 5 nodes (default)
$ ddn-bin peers:start

# Start 3 nodes
$ ddn-bin peers:start -n 3

# Force start (even if ports are in use)
$ ddn-bin peers:start -f

# Start a specific single node
$ ddn-bin peers:start -p 8001

# Start nodes in mainnet test project
$ ddn-bin peers:start -t main-tests

Stopping Nodes

# Stop all nodes
$ ddn-bin peers:stop

# Stop 3 nodes
$ ddn-bin peers:stop -n 3

# Force stop (using SIGKILL)
$ ddn-bin peers:stop -f

# Stop a specific single node
$ ddn-bin peers:stop -p 8001

# Stop nodes in mainnet test project
$ ddn-bin peers:stop -t main-tests

Cleaning Node Data

# Clean all data for all nodes
$ ddn-bin peers:clean

# Clean only databases
$ ddn-bin peers:clean -c db

# Clean only logs
$ ddn-bin peers:clean -c log

# Clean specific files
$ ddn-bin peers:clean -f blockchain

# Clean specific node
$ ddn-bin peers:clean -p 8001

# Clean node data in mainnet test project
$ ddn-bin peers:clean -t main-tests

Monitoring Nodes

# Monitor all nodes
$ ddn-bin peers:monitor

# Set monitoring interval (seconds)
$ ddn-bin peers:monitor -i 30

# Enable auto-restart
$ ddn-bin peers:monitor -r

# Monitor nodes in mainnet test project
$ ddn-bin peers:monitor -t main-tests

Node Inspection

To verify the above information, you can check the node log files or use ddn to view node status.

# View node logs
$ tail -f ./logs/main.log
$ tail -f ./logs/debug.log
$ tail -f ./logs/dvm.log

# View node status
$ ddn d peerStat -H 127.0.0.1 -P 8001
$ ddn d peerStat -H 117.78.45.44 -P 8000 -M

View in browser: http://127.0.0.1:8001/api/blocks/getHeight

Development

# Build
$ yarn run build

# Run tests
$ yarn test

FAQ

  • If you encounter Error: listen EADDRINUSE: address already in use :::8001, it means the port is already in use and you need to change the port number.
  • If you encounter "Sandbox is not ready" error, it's most likely due to database initialization issues. Copying a blockchain.db file should resolve this.

License

MIT

Keywords

ddn

FAQs

Package last updated on 18 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts