prysm-pulse/sharding/observer/service.go
Terence Tsao 7858e9abfc sharding/node: get shardID from cli, pass it to actor services
Former-commit-id: 0220101381cf92180c1003997e514260290548d5 [formerly 5ca29b99f069db4169d98508aeb10b9ea88b679b]
Former-commit-id: 23ce869125865eb86eea1ef20587b475f39f2ed5
2018-06-11 11:00:31 -07:00

38 lines
1.1 KiB
Go

// Package observer launches a service attached to the sharding node
// that simply observes activity across the sharded Ethereum network.
package observer
import (
"fmt"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding"
)
// Observer holds functionality required to run an observer service
// in a sharded system. Must satisfy the Service interface defined in
// sharding/service.go.
type Observer struct {
shardp2p sharding.ShardP2P
shardChainDb ethdb.Database
shardID int
}
// NewObserver creates a new observer instance.
func NewObserver(shardp2p sharding.ShardP2P, shardChainDb ethdb.Database, shardID int) (*Observer, error) {
return &Observer{shardp2p, shardChainDb, shardID}, nil
}
// Start the main routine for an observer.
func (o *Observer) Start() error {
log.Info(fmt.Sprintf("Starting observer service in shard %d", o.shardID))
return nil
}
// Stop the main loop for observing the shard network.
func (o *Observer) Stop() error {
log.Info(fmt.Sprintf("Starting observer service in shard %d", o.shardID))
return nil
}