2018-06-04 21:10:59 +00:00
|
|
|
// Package p2p handles peer-to-peer networking for the sharding package.
|
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
2018-06-12 12:33:00 +00:00
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/event"
|
2018-06-04 21:10:59 +00:00
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Server is a placeholder for a shardp2p service. To be designed.
|
2018-06-12 12:33:00 +00:00
|
|
|
type Server struct {
|
|
|
|
feeds map[reflect.Type]*event.Feed
|
|
|
|
}
|
2018-06-04 21:10:59 +00:00
|
|
|
|
2018-06-13 02:06:59 +00:00
|
|
|
// NewServer creates a new p2p server instance.
|
2018-06-04 21:10:59 +00:00
|
|
|
func NewServer() (*Server, error) {
|
2018-06-12 12:33:00 +00:00
|
|
|
return &Server{
|
|
|
|
feeds: make(map[reflect.Type]*event.Feed),
|
|
|
|
}, nil
|
2018-06-04 21:10:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-13 02:06:59 +00:00
|
|
|
// Start the main routine for an p2p server.
|
2018-06-12 04:46:53 +00:00
|
|
|
func (s *Server) Start() {
|
2018-06-04 21:10:59 +00:00
|
|
|
log.Info("Starting shardp2p server")
|
|
|
|
}
|
|
|
|
|
2018-06-13 02:06:59 +00:00
|
|
|
// Stop the main p2p loop.
|
2018-06-04 21:10:59 +00:00
|
|
|
func (s *Server) Stop() error {
|
|
|
|
log.Info("Stopping shardp2p server")
|
|
|
|
return nil
|
|
|
|
}
|
2018-06-13 02:13:24 +00:00
|
|
|
|
|
|
|
// Send a message to a specific peer.
|
2018-06-13 02:23:12 +00:00
|
|
|
func (s *Server) Send(msg interface{}, peer Peer) {
|
2018-06-13 02:13:24 +00:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// Broadcast a message to the world.
|
|
|
|
func (s *Server) Broadcast(msg interface{}) {
|
|
|
|
// TODO
|
|
|
|
}
|