qshuai / go-electrum Goto Github PK
View Code? Open in Web Editor NEWElectrum protocol client written in Go
License: MIT License
Electrum protocol client written in Go
License: MIT License
你好,请问这个版本在生产上能稳定运行吗?
在readme中这段示例代码直接painc了, 而且看到有依赖于这个地址 electrum.dragonzone.net:50001,如果这里不提供服务了怎么办?
package main
import (
"log"
"github.com/qshuai/go-electrum/electrum"
)
func main() {
node := electrum.NewNode()
if err := node.ConnectTCP("electrum.dragonzone.net:50001"); err != nil {
log.Fatal(err)
}
balance, err := node.BlockchainAddressGetBalance("1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L")
if err != nil {
log.Fatal(err)
}
log.Printf("Address balance: %+v", balance)
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11284ee]
goroutine 1 [running]:
github.com/qshuai/go-electrum/electrum.(*Node).BlockchainAddressGetBalance(0xc420102000, 0x118821c, 0x22, 0x0, 0x0, 0xc4200107b0)
~/5-goland/src/github.com/qshuai/go-electrum/electrum/blockchain.go:87 +0x11e
main.main()
~/5-goland/src/thewaytogo/electrumClient.go:14 +0x181
Process finished with exit code 2
how to connect ConnectTCP correctly, if one server disconnects to connect to another and so on
round
node := NewNode()
if err := node.ConnectTCP("electrum.anduck.net:50011"); err != nil {}
if err := node.ConnectTCP("ndnd.selfhost.eu:50001"); err != nil {}
if err := node.ConnectTCP("ip119.ip-54-37-91.eu:50001"); err != nil {}
msg := request{
Id: atomic.LoadUint64(&n.nextId),
Method: method,
Params: params,
}
atomic.AddUint64(&n.nextId, 1)
is not the proper way to use the atomic package. You cannot guarantee that another goroutine will not read n.nextId
between the time the code reads and then updates the value.
The correct pattern looks like:
msg := request{
Id: atomic.AddUint64(&nextId, 1)
...
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.