mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 10:12:19 +00:00
0b50d2778e
Former-commit-id: d785fe8737d7b514e1104fe3853d1c77356a7449 [formerly e4514806763853f9ea7e449aa7397bd4b208f043] Former-commit-id: e52fdf8806cf01c3f79cf86a06c16dd91f302c2e
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
// Package p2p handles peer-to-peer networking for the sharding package.
|
|
package p2p
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
"github.com/ethereum/go-ethereum/log"
|
|
)
|
|
|
|
// Server is a placeholder for a shardp2p service. To be designed.
|
|
type Server struct {
|
|
feeds map[reflect.Type]*event.Feed
|
|
}
|
|
|
|
// NewServer creates a new shardp2p service instance.
|
|
func NewServer() (*Server, error) {
|
|
return &Server{
|
|
feeds: make(map[reflect.Type]*event.Feed),
|
|
}, nil
|
|
}
|
|
|
|
// Start the main routine for an shardp2p server.
|
|
func (s *Server) Start() error {
|
|
log.Info("Starting shardp2p server")
|
|
return nil
|
|
}
|
|
|
|
// Stop the main shardp2p loop..
|
|
func (s *Server) Stop() error {
|
|
log.Info("Stopping shardp2p server")
|
|
return nil
|
|
}
|
|
|
|
// Feed returns a event feed for the given message type.
|
|
// TODO(prestonvanloon): Add more to this GoDoc before merging.
|
|
func (s *Server) Feed(msg interface{}) (*event.Feed, error) {
|
|
t := reflect.TypeOf(msg)
|
|
if s.feeds[t] == nil {
|
|
s.feeds[t] = new(event.Feed)
|
|
}
|
|
return s.feeds[t], nil
|
|
}
|