tendermint/peer/server.go

33 lines
550 B
Go
Raw Normal View History

2014-06-24 17:28:40 -07:00
package peer
import (
)
/* Server */
type Server struct {
listener Listener
client *Client
}
func NewServer(l Listener, c *Client) *Server {
s := &Server{
listener: l,
client: c,
}
2014-06-25 21:37:20 -07:00
go s.IncomingConnectionHandler()
2014-06-24 17:28:40 -07:00
return s
}
// meant to run in a goroutine
func (s *Server) IncomingConnectionHandler() {
for conn := range s.listener.Connections() {
2014-06-25 21:37:20 -07:00
s.client.AddPeerWithConnection(conn, false)
2014-06-24 17:28:40 -07:00
}
}
func (s *Server) Stop() {
s.listener.Stop()
s.client.Stop()
}