xrpscan / xrpl-go Goto Github PK
View Code? Open in Web Editor NEWA Go client for interacting with the XRP Ledger websocket APIs
Home Page: https://pkg.go.dev/github.com/xrpscan/xrpl-go
License: MIT License
A Go client for interacting with the XRP Ledger websocket APIs
Home Page: https://pkg.go.dev/github.com/xrpscan/xrpl-go
License: MIT License
The following experiment would be lock at client.Request because network is closed or i/o time out, can you export a method to check the network is closed or not to avoid lock at client.Request.
config := xrpl.ClientConfig{
URL: "wss://s.altnet.rippletest.net:51233/",
}
client := xrpl.NewClient(config)
err := client.Ping([]byte("PING"))
if err != nil {
panic(err)
}
// test send request after close
r.Close()
resp, err := client.Request(xrpl.BaseRequest{
"id": "example_ledger_req",
"command": "ledger",
"ledger_index": "validated",
"transactions": false,
"expand": false,
"owner_funds": false,
})
if err != nil {
panic(err)
}
var ok bool
index, ok = (resp["result"].(map[string]interface{})["ledger_index"]).(float64)
if !ok {
fmt.Printf("ledger_index reflect failed: %T", index)
}
another experiment is close twice, and it would be lock at second close, so we need a way to know the connection is close or not or just skip.
config := xrpl.ClientConfig{
URL: "wss://s.altnet.rippletest.net:51233/",
}
client := xrpl.NewClient(config)
err := client.Ping([]byte("PING"))
if err != nil {
panic(err)
}
// 1st
r.Close()
// 2nd
r.Close() // will be lock in this close
Runtime error should be handled gracefully.
$ ./bin/platform-server
2023/12/19 11:21:46 Loading configuration file: .env
2023/12/19 11:21:46 WS connection error: ws://localhost:6006 dial tcp 127.0.0.1:6006: connect: connection refused
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x94522a]
goroutine 1 [running]:
github.com/gorilla/websocket.(*Conn).WriteMessage(0x18?, 0xc0001708e8?, {0xc0001708e8, 0x13, 0x18})
...
...
Add the following functions to handle ripple time to unix time conversion.
IsoTimeToRippleTime
RippleTimeToISOTime
RippleTimeToUnixTime
UnixTimeToRippleTime
Ripple Epoch (January 1, 2000 (00:00 UTC)) is 946684800 seconds after the Unix Epoch. Time conversion routine must use 64bit variables.
ref: https://xrpl.org/docs/references/protocol/data-types/basic-data-types#specifying-time
Handle ping
messages sent by rippled every 15 seconds.
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.