In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Go block chain how to achieve transaction verification", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Go block chain how to achieve transaction verification" bar!
Popular language of blockchain
In the development circle of blockchain public chains, we have found some popular programming languages, including C++, Golang, Python, and recently Rust, etc.
Do a little statistics on the programming languages used in the more famous projects, as shown in the following figure:
The older generation of public chains, such as Bitcoin,Litcoin, generally use CAccord Category + more (let's take a look at that time, when Go was not up yet), while the new generation of public chains, such as Ethernet Fong, Alliance chain leader super ledger, began to use the GE language more. Of course, we can see that the development momentum of Rust is also very strong. In the past two years, many public chains such as Boca and Grin have been developed in Ruth language.
The advantages of the Go language are easy to deploy
Go compilation produces a static executable file with no external dependencies other than glibc. This makes deployment extremely convenient: only a basic system and necessary management and monitoring tools are needed on the target machine, and there is no need to worry about the dependencies of various packages and libraries required by the application, which greatly reduces the burden of maintenance. Can be directly compiled into machine code, do not rely on other libraries, the version of glibc has certain requirements, deployment is to throw a file to complete.
Excellent performance
Although not as good as C and Java, it is usually an order of magnitude higher than native Python applications and is suitable for writing bottleneck businesses. Memory footprint is also very low.
Concurrency & Channel
Goroutine and channel make it quite easy to write server-side software with high concurrency, and in many cases there is no need to consider the locking mechanism and the resulting problems. A single Go application can also effectively make use of multiple CPU cores, and the performance of parallel execution is good.
Good language design
Go is very simple and easy to learn. From an academic point of view, the Go language is actually very mediocre and does not support many advanced language features; but from an engineering point of view, the design of Go is excellent: the specification is simple and flexible enough. Because of the simplicity of Go, any Python, Elixir, C++, Scala or Java developer can build an effective Go team within a month.
Standard Library & tool
Go already has a large number of built-in libraries, especially the network library is very powerful. More importantly, Go has its own perfect tool chain, which greatly improves the consistency of team cooperation. For example, gofmt automatic typesetting Go code, to a large extent, put an end to the problem of inconsistent typesetting style of code written by different people. Configure the editor to run gofmt automatically when editing the archive, so that it can be placed at will when writing code, and automatically become the correct typesetting code when archived. In addition, there are gofix, govet and other very useful tools.
The team is good.
The proponent behind the Go language is Google, which is sufficient to be tested in a variety of scenarios, and the founder is the father of the C language, which is expected for follow-up development and innovation.
Go successful projects
Go language has been widely used in the cloud era, especially with the emergence of killer products such as Docker and K8s, Go language has a place in the field of engineering. In addition, there are many successful running software in Go language: nsq:bitly 's open source message queuing system, which has very high performance. at present, they process billions of messages every day packer: used to generate image files for different platforms, such as VM, vbox, AWS, etc. The writer is author of vagrant skynet: distributed scheduling Framework Doozer: distributed synchronization tools, similar to ZooKeeper Heka:mazila Open Source Log processing system cbfs:couchbase Open Source distributed File system tsuru: open Source PAAS platform, same function as SAE, groupcache:memcahe author's cache system for Google download system god: similar to redis cache system, but supports distributed and extensible gor: network traffic grabbing and playback tools
Ecological card position and recessive standard
In addition to requiring good blacksmiths to make good steel, there are some opportunities and luck for blockchain to choose the Go language. Let's take a look at the representatives of the most successful public chain and alliance chain since blockchain 2.0. Taifang and super account book Fabric, without exception, choose Go as the development language (although Etaifang actually has client versions of other languages, but after entering the Homestead stage, Go clients occupy a dominant position). The influence of these two super blockchains is not comparable to that of ordinary projects. It not only occupies a large pothole in the ecology, in fact, it also implicitly establishes the standard of block chain, whether it is the intelligent contract in the public chain or the technology of alliance chain, which can not be bypassed by Etay Fang and Fabric, so what is the quickest realization for a company that wants to do blockchain technology selection? Naturally, it is a direct copy of the innovation of these two projects, and then the shortcut is to directly take away the source code to change, then the natural Go language will become the first choice for newcomers, and it is not easy to change the language to achieve it again, and if you choose some innovative but not very mature languages, you will lack the support of some specific libraries, which will lead to the project cannot be carried out.
Many people have no doubt about the influence of ethernet, but in fact, the influence of Fabric on the deployment of enterprise blockchain should not be underestimated:
Hyperledger Fabric is the most widely used protocol framework in deployed enterprise blockchain networks, and super-ledger Hyperledger (in which Fabric is the flagship protocol) is the most commonly supported protocol framework for integrators and software development platforms, accounting for 53%. Among all the blockchain technical books, the fact that super books are the most popular is also a side testament to the influence of super books Hyperledger.
The practice of Biyuan chain in GE language
In the process of selecting the programming language, we considered C _ Magistral, Java, but it is difficult to maintain a large project, and Java is a little clunky. At this time, Go language has already shone brilliantly in the blockchain project, and gradually formed a head effect of technology and talent, so technology selection in line with the trend will naturally reduce the resistance encountered in the initial project than the original chain, of course, in the process of gradual development. We also feel the convenience and advantages of choosing GE language.
A Case of Go on the block chain
Technically, blockchain nodes require multi-module asynchronous cooperation, so Go language concurrency and channels have great advantages. Let's take a look at the following example of transaction verification:
Func ValidateTxs (txs [] * bc.Tx, block * bc.Block) [] * ValidateTxResult {txSize: = len (txs) / / init the goroutine validate worker var wg sync.WaitGroup workCh: = make (chan * validateTxWork, txSize) resultCh: = make (chan * ValidateTxResult, txSize) closeCh: = make (chan struct {}) for I: = 0; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.