2018-07-14 02:15:37 +00:00
|
|
|
package shared
|
|
|
|
|
2018-09-16 01:12:36 +00:00
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/p2p"
|
|
|
|
)
|
|
|
|
|
2018-07-14 02:15:37 +00:00
|
|
|
// Service is a struct that can be registered into a ServiceRegistry for
|
|
|
|
// easy dependency management.
|
|
|
|
type Service interface {
|
|
|
|
// Start spawns any goroutines required by the service.
|
|
|
|
Start()
|
|
|
|
// Stop terminates all goroutines belonging to the service,
|
|
|
|
// blocking until they are all terminated.
|
|
|
|
Stop() error
|
|
|
|
}
|
2018-09-16 01:12:36 +00:00
|
|
|
|
|
|
|
// P2P defines a struct that can subscribe to feeds, request data, and broadcast data.
|
|
|
|
type P2P interface {
|
|
|
|
Subscribe(msg proto.Message, channel chan p2p.Message) event.Subscription
|
|
|
|
Send(msg proto.Message, peer p2p.Peer)
|
|
|
|
Broadcast(msg proto.Message)
|
|
|
|
}
|