Go-ethereum Source Code Analysis (a)--go-ethereum Source reading Environment construction (turn)

Source: Internet
Author: User

Preface

Since go Ethereum is the most widely used Ethereum client, subsequent source analysis is analyzed from this code on GitHub.

Build Go ethereum debugging environment

Windows 64bit

First download go install package to install, because go website is wall, so download from the address below.

https://studygolang.com/dl/golang/go1.9.1.windows-amd64.msi

After installation, set the environment variables, add the C:\Go\bin directory to your PATH environment variable, and then increase a gopath environment variable, gopath the value set to your Go language download code path (I set the C:\GOPATH)

Image

To install Git tools, refer to the tutorials on the web to install Git tools, the Go language automatically download code from github requires the support of GIT tools

Open the command line tool to download the Go-ethereum code

go get github.com/ethereum/go-ethereum

After the command executes successfully, the code is downloaded to the following directory,%gopath%\src\github.com\ethereum\go-ethereum if the execution occurs

# github.com/ethereum/go-ethereum/crypto/secp256k1exec: "gcc": executable file not found in %PATH%

You need to install the GCC tool and we download and install it from the address below

http://tdm-gcc.tdragon.net/download

Next, install the IDE tools. I am using the IDE is JetBrains Gogland. Can be downloaded at the following address

https://download.jetbrains.com/go/gogland-173.2696.28.exe

When the installation is complete, open the IDE. Select File---open, select the Gopath\src\github.com\ethereum\go-ethereum directory.

Then open Go-ethereum/rlp/decode_test.go. Right-click on the edit box to run, if successful, on behalf of the environment to build the completion.

Image

Ubuntu 16.04 64bit

Go install package to install

apt install golang-go git -y

Golang Environment Configuration:

编辑/etc/profile文件,在该文件中加入以下内容:export GOROOT=/usr/bin/go  export GOPATH=/root/home/goprojectexport GOBIN=/root/home/goproject/binexport GOLIB=/root/home/goproject/export PATH=$PATH:$GOBIN:$GOPATH/bin:$GOROOT/bin

Execute the following command to make the environment variable effective:

# source /etc/profile

Download Source:

#cd  /root/home/goproject; mkdir src; cd src  #进入go项目目录,并创建src目录, 并进入src目录#git clone https://github.com/ethereum/go-ethereum

Open with Vim or another IDE;

The Go Ethereum directory is probably introduced

The organizational structure of the Go-ethereum project is basically a directory of functional modules, the following is a brief description of the structure of each directory, each directory in the Go language is also a package, I understand that the package in Java should be similar to the meaning.

Accounts implements a high-level Ethereum account management The implementation of the Ms Merkel tree of the BMT binary is primarily compiled and built with some scripting and configuration cmd command-line tools, and a lot of command-line tools, under Face one An introduction/abigen Source code generator to convert Ethereum contract definitions into easy-to-use, Compile-time type-        Safe Go Packages/bootnode launches a development tool for a node/EVM ethereum virtual machine that only implements network discovery to provide a configurable, isolated code debugging environment/faucet/geth    Ethereum command-line client, one of the most important tools/p2psim provides a tool to simulate HTTP Api/puppeth creating a new Ethereum Network Wizard/rlpdump provides a formatted output of RLP data The access point of the/swarm swarm network/util provides some common tools/wnode This is a simple whisper node. It can be used as a standalone boot node. In addition, it can be used for different testing and diagnostic purposes.        Common offers some common tools class compression package RLE implements the Run-length encoding used for Ethereum Data.consensus Provides a number of ethereum consensus algorithms, such as Ethhash, clique (proof-of-authority) Console console class contracts core data structure and calculation Method (virtual machine, state, blockchain, Bron filter) crypto encryption and hash algorithm, ETH implements the Ethereum protocol ethclient provides an ethereum RPC client ETHDB the ETH database (including real LEVELDB and the memory database used for testing) EthstATS provides reports of network status event processing real-time events les implements the lightweight protocol subset of Ethereum light implementation provides on-demand retrieval capabilities for Ethereum Lightweight clients log provides          Machine-friendly Log information metrics provides disk counters miner provides ethereum block creation and mining mobile mobile to use some of the Warppernode Ethereum's various types of node-PEER Ethereum-PEER network protocol RLP ethereum serialization processing RPC remote method call swarm Swarm network processing tests testing Trie ethereum Important The data structure package Trie implements Merkle Patricia Tries.whisper provides the Whisper node protocol.

You can see the number of Ethereum code is still very large, but at a glance, the code structure is very good. I would like to start with some of the more independent modules to analyze. Then in-depth analysis of the internal code. Focus may focus on the Yellow Book is not involved in the network and other modules.

Original link Go-ethereum source reading environment construction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.