GithubHelp home page GithubHelp logo

xrpscan / xrpl-go Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 2.0 19 KB

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

Go 100.00%
rippled xrpl xrpl-go xrpljs

xrpl-go's People

Contributors

pkcs8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

xrpl-go's Issues

client request lock inside if network is closed or i/o time out

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

Handle Runtime error when connecting to invalid rippled server

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})
...
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.