Files
prysm/sharding/interfaces.go
Raul Jordan f3f5b8e5a6 Simplify Service Registry, Pass in References as Dependencies to Prevent Nil Pointer Errors (#217)
sharding: simplify service registry to prevent nil pointer errors
Former-commit-id: ba4833c385e5212723932491810baad62e3ff0f9 [formerly c550c6d0837999f46a6de55a36fb1ae92d2ecd6f]
Former-commit-id: 80e9e13bc811444b461dad6bdf9eec633b911bec
2018-06-28 20:56:51 -04:00

38 lines
1.2 KiB
Go

package sharding
import (
"github.com/ethereum/go-ethereum/common"
)
// Node defines a a sharding-enabled Ethereum instance that provides
// full control and shared access of necessary components and services
// for a sharded Ethereum blockchain.
type Node interface {
Start()
Close()
}
// Actor refers to either a notary, proposer, or observer in the sharding spec.
type Actor interface {
Service
// TODO: will actors have actor-specific methods? To be decided.
}
// CollationFetcher defines functionality for a struct that is able to extract
// respond with collation information to the caller. Shard implements this interface.
type CollationFetcher interface {
CollationByHeaderHash(headerHash *common.Hash) (*Collation, error)
}
// Service is an individual protocol that can be registered into a node. Having a sharding
// node maintain a service registry allows for easy, shared-dependencies. For example,
// a proposer service might depend on a p2p server, a txpool, an smc client, etc.
type Service interface {
// Start is called after all services have been constructed to
// spawn any goroutines required by the service.
Start()
// Stop terminates all goroutines belonging to the service,
// blocking until they are all terminated.
Stop() error
}