> For the complete documentation index, see [llms.txt](https://dxchain.gitbook.io/dxchain-wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dxchain.gitbook.io/dxchain-wiki/zhong-wen-she-qu/kai-fa-zhe-wen-dang/kai-fa-zhe/bian-yi-he-yun-xing.md).

# 编译和运行

## 下载

通过 `git` 下载节点程序源代码

```shell
git clone https://github.com/DxChainNetwork/dxc.git
```

## 安装 Golang

1. 参考 [Golang下载与安装](https://golang.org/doc/install)

```bash
// or in linux:
$ sudo snap install go --classic
```

## 编译

```bash
$ cd /path/to/dxc
$ make geth
```

编译之后的可执行程序位置在 `build/bin` 目录下。

执行 `./build/bin/geth --help` 可以获取程序的相关用法，也可参考 [command-line-options](https://geth.ethereum.org/docs/interface/command-line-options)。

注意：本文‘/path/to/dxc’ 指的是dxc的源码下载目录。

## 运行

### 运行配置&#x20;

* 进入工作目录 /path/to/dxc/build/bin：可执行程序geth所在的目录路径
* 在工作目录中创建 `config.toml`

```toml
[Eth]
SyncMode = "snap"
TrieCleanCacheRejournal= 300000000000

[Eth.Miner]
GasFloor = 0
GasCeil = 40000000
GasPrice = 1000000000
Recommit = 3000000000
Noverify = false

[Node]
InsecureUnlockAllowed = true
IPCPath = "geth.ipc"
```

> 默认使用`SyncMode = "snap"` 节点同步模式，全节点同步切换至`SyncMode = "full"`

* 在工作目录中创建`start.sh`

```bash
#!/bin/bash

set -e

# DXC_DIR 可执行程序geth所在的目录路径
DXC_DIR=/path/to/dxc/build/bin

cd $DXC_DIR

# --datadir ./data 区块链数据存储目录
nohup ./geth --datadir ./data --config ./config.toml --verbosity 3 >>./data/system.log 2>&1 &
```

### 节点运行

```shell
$ /bin/bash start.sh
```

## 网络

节点程序默认启动为 `mainnet`，若想启动测试网，可在运行时添加 `--testnet` 指令。
