WIP: blockchain.transaction.yyy JSON RPC implementations #78

Merged
moodyjon merged 12 commits from blockchain_tx_rpc1 into master 2022-12-06 22:14:28 +01:00
Showing only changes of commit 6e41369805 - Show all commits

View file

@ -52,9 +52,6 @@ func (cr *gorillaRpcCodecRequest) Method() (string, error) {
// StartJsonRPC starts the json rpc server and registers the endpoints. // StartJsonRPC starts the json rpc server and registers the endpoints.
func (s *Server) StartJsonRPC() error { func (s *Server) StartJsonRPC() error {
s.sessionManager.start()
defer s.sessionManager.stop()
// Set up the pure JSONRPC server with persistent connections/sessions. // Set up the pure JSONRPC server with persistent connections/sessions.
if s.Args.JSONRPCPort != 0 { if s.Args.JSONRPCPort != 0 {
port := ":" + strconv.FormatUint(uint64(s.Args.JSONRPCPort), 10) port := ":" + strconv.FormatUint(uint64(s.Args.JSONRPCPort), 10)
@ -69,7 +66,9 @@ func (s *Server) StartJsonRPC() error {
goto fail1 goto fail1
} }
log.Infof("JSONRPC server listening on %s", listener.Addr().String()) log.Infof("JSONRPC server listening on %s", listener.Addr().String())
s.sessionManager.start()
acceptConnections := func(listener net.Listener) { acceptConnections := func(listener net.Listener) {
defer s.sessionManager.stop()
for { for {
conn, err := listener.Accept() conn, err := listener.Accept()
if err != nil { if err != nil {
@ -78,6 +77,7 @@ func (s *Server) StartJsonRPC() error {
} }
log.Infof("Accepted: %v", conn.RemoteAddr()) log.Infof("Accepted: %v", conn.RemoteAddr())
s.sessionManager.addSession(conn) s.sessionManager.addSession(conn)
} }
} }
go acceptConnections(netutil.LimitListener(listener, s.sessionManager.sessionsMax)) go acceptConnections(netutil.LimitListener(listener, s.sessionManager.sessionsMax))