Position: Home page » Ethereum » Go call Ethereum interface

Go call Ethereum interface

Publish: 2021-04-26 11:48:15
1. Go full stack + blockchain course:
a total of 22 weeks, divided into five stages,
the first stage is 4 weeks, go language foundation and network concurrency, learning the introctory go language,
the second stage is 4 weeks, go language practical web development, crawler development, cryptography, consensus algorithm, realizing lightweight public chain, learning the website and crawler that can develop golang, Achieve lightweight blockchain
stage 3, 4-week Ethereum source code analysis and smart contract DAPP development, master Ethereum core and smart contract development, as well as blockchain,
stage 4, 4-week super ledger, bitcoin EOS, source code analysis and smart contract practice, master super ledger development, cat bitcoin, bifurcated EOS after learning, As well as DAPP development of smart contract
phase 5, 6-week project practice, five enterprise level projects, and one year of blockchain project experience after learning
from the characteristics of the language itself, go is a very efficient language, which highly supports concurrency. Go language itself pays more attention to distributed system, and concurrency processing is relatively good, such as advertising and search, That kind of high concurrency server
go language advantages:
excellent performance, can be directly compiled into machine code, does not rely on other libraries, go is extremely fast. Its performance is similar to Java or C + +
concurrency is supported at the language level, which is the biggest feature of go. It is born to support concurrency, and go is the concurrency supported in gene, which can make full use of multi-core and make it easy to use concurrency
the built-in runtime supports garbage collection, which is one of the features of dynamic language. Although GC is not perfect at present, it is enough to cope with most of the situations we can encounter, especially GC after go1.1
it's easy to learn. The authors of go language all have the gene of C, so go naturally has the gene of C. There are 25 go keywords, but the expressive ability is very strong. It almost supports most of the features you've seen in other languages: inheritance, overloading, object, etc
rich standard libraries, go has built a large number of libraries, especially the network library, which is also my favorite part< As like as two peas, br / > built-in powerful tools, Go language is built with many tools chain, the best should be gofmt tools, automatic formatting code, make team review become so simple, code format is exactly the same, it is very difficult to think differently.
cross platform compilation and fast compilation. Compared with the sluggish compilation speed of Java and C + +, the fast compilation time of go is a major efficiency advantage
disadvantages of go language:
package management: package management of go language is absolutely not perfect. By default, it has no way to make a specific version of the dependency library, nor can it create replicable builds. In contrast, python, node and Ruby all have better package management systems. However, with the right tools, the package management of go language can also perform well
lack of development framework: go language does not have a major framework, such as Ruby's rails framework, Python's Django framework or PHP's laravel. This is a heated discussion in the go language community, because many people think that we should not start with using frameworks. This is true in many cases, but if you just want to build a simple crud API, it's much easier to use Django / djrf, rails laravel, or Phoenix
exception handling: go language can help developers deal with compilation errors by simply returning errors (or call stack) through functions and expected calling codes. Although this method is effective, it is easy to lose the scope of the error, so it is difficult to provide meaningful error information to users. Error package can solve this problem by allowing us to add context and stack trace to return error
another problem is that we may forget to handle errors. Static analysis tools such as errcheck and megacheck can avoid these errors. Although these solutions are very effective, they may not be the right way.
2. How to run Ethereum source code go Ethereum
install MIPS based Linux header file
$CD $prjroot / kernel
$tar - xjvf linux-2.6.38. Tar. Bz2
$CD linux-2.6.38

create an include folder under the specified path to store related header files< br />$ mkdir -p $TARGET_ Prefix / include

ensures that the Linux source code is clean
$make mrproper

generates the required header file< br />$ make ARCH=mips headers_ check
$ make ARCH=mips INSTALL_ HDR_ PATH=dest headers_ Install

all the files in dest folder to the specified include folder< br />$ cp -rv dest/include/* $TARGET_ Prefix / include

delete dest folder at last
$RM - RF dest
$LS - L $target_ PREFIX/include
3. curl方法,file_get_contents,
4. Through curl to simulate, and then get the data, and use it in JSON format
5.

1. Server programming: in the past, if you used C or C + + to do those things, go is very suitable, such as processing logs, data packaging, virtual machine processing, file system and so on

2, distributed system, database agent, middleware: for example, etcd

3. Network programming: at present, this area is the most widely used, including web application, API Application, download application, and the built-in net / HTTP package of go basically realizes all the network functions we usually use

4. Development of cloud platform: at present, many foreign cloud platforms are developing with go, and the well-known seven cattle cloud, Huawei cloud and so on all have procts that are developed with go and open source

5. Blockchain: at present, there is a saying that technical practitioners regard go language as the development language of blockchain instry. If you learn the blockchain technology, you will find that many blockchain systems and applications are developed with go. For example, ehtereum is the most famous public chain at present, and fabric is the most famous alliance chain at present. Both of them have go language versions, and go ehtereum is the version officially recommended by Ethereum

Many projects in the later stage of

are implemented by go language. This process is simpler than other languages, which also leads to the emergence of a large number of go language native development projects< br />

6. Ethereum source code
7. Eth is a kind of digital token of Ethereum. Developers need to pay eth to support the application. Ether currency, like other digital currencies, can be bought and sold on the trading platform. Generally speaking, Ethereum is an open source platform, digital currency and blockchain platform, which provides developers with the ability to build on the blockchain
8. Switch cable connection, you want to transfer the file to do a share. That's it
9. 1 interface definition and understanding

interface is a user-defined type, which is a collection of methods. By definition, interfaces have two characteristics. First, interfaces are user-defined in nature, so don't simply understand interfaces in golang as interfaces in C + + / Java, which are only used to declare method signatures. Second, the interface is a special custom type, in which there are no data members but only methods (which can also be empty)
interfaces are completely abstract, so they cannot be instantiated. However, you can create a variable whose type is an interface, which can be assigned to any value of the actual type that satisfies the interface type. The important features of an interface are:
(1) as long as a type implements the method of the interface, we say that the type implements the interface. The value of this type can be assigned to the value of this interface
(2) as a corollary of 1, the value of any type can be assigned to an empty interface {}
note: This is only a property of an interface in golang, which is not a property of all types (interface is a special type)
the feature of interface is the basis for golang to support ck type, that is, "if it walks like a ck and barks like a ck (implements the method of interface), it is a ck (can be assigned to the value of interface)". With the interface mechanism and ck type, golang provides a more flexible and powerful choice besides class, inheritance and template

2 examples

type exchange interface {
exchange()
}

type stringpair struct {
first, second string
}

type point [2] int

func (SP * stringpair) exchange() {
sp.first, sp.second = sp.second, sp.first
}

func (p *Point) exchange() {
p[0], p[1] = p[1], p[0]
}

func exchangeThese(exchangers ...Exchanger) {
for _, exchanger := range exchangers {
exchanger.exchange()
}
}

func main() {
pair1 := StringPair{" abc",& quot; def"}< br /> pair2 := StringPair{" ghi",& quot; jkl"}< br /> point := Point{5, 7}

fmt.Println(pair1, pair2, point)
pair1.exchange()
pair2.exchange()
point.exchange()
fmt.Println(pair1, pair2, point)

// exchangeThese(pair1, pair2) //wrong
exchangeThese(&pair1, &Pair2)
FMT. Println (pair1, pair2)
}

running results

in this case, the custom type stringpair and point pointer implement the methods required by the interface exchange, so the value of this type can be assigned to the value of the interface
in addition, pay special attention to this. If exchange these (pair1,
pair2) is used, it will lead to compilation errors (as shown in the figure below). The correct writing should be exchange these (& pair1,
& pair2). This is because the type that really satisfies the interface exchange is a stringpair pointer, not a stringpair

in golang, the method sets of value receivers and pointer receivers are different. It's just that golang intelligently dereferences and fetches references, making their method sets look the same. However, when exchange these is called, the difference between them is highlighted.
10. If a class is the abstraction and encapsulation of data and methods, then an interface is the abstraction of a class
here we use java to illustrate that interfaces in Java are similar to interfaces in 'go', except that an interface needs to be explicitly declared in Java, while an interface does not need to be explicitly declared in go. As long as all the methods are implemented, the interface is implemented by default
for example, there is a person interface:
public interface person {void walk()
}

a student class implements the person interface
public class student implements person {/ / implements the walk method
@ override
public void walk() {
system. Out. Print & quot; Student.walk()");< Other methods}

a teacher class also implements the person interface
public class teacher implements person {/ / implements the walk method
@ override
public void walk() {
system. Out. Print & quot; Teacher.walk()");
} / /... Other methods}

can be used in a class in this way
public class someclass {/ / receives a person type
public static void useperson (person P) {
p.walk()
}
public static void main (string [] args) {/ / can receive any object of a class that implements the person interface
useperson (New student())< br />usePerson(new Teacher());
}
}

the advantage of using the interface is very flexible, so that it can decouple with the specific implementation. If there are other implementation classes in the future, you only need to implement the person interface instead of changing the code when you use it.
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750