2018-05-22 16:42:49 +00:00
|
|
|
// Package observer launches a service attached to the sharding node
|
|
|
|
// that simply observes activity across the sharded Ethereum network.
|
|
|
|
package observer
|
|
|
|
|
|
|
|
import (
|
2018-06-11 18:00:31 +00:00
|
|
|
"fmt"
|
|
|
|
|
2018-06-08 21:45:26 +00:00
|
|
|
"github.com/ethereum/go-ethereum/ethdb"
|
2018-05-22 16:42:49 +00:00
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2018-06-04 21:10:59 +00:00
|
|
|
"github.com/ethereum/go-ethereum/sharding"
|
2018-05-22 16:42:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Observer holds functionality required to run an observer service
|
|
|
|
// in a sharded system. Must satisfy the Service interface defined in
|
|
|
|
// sharding/service.go.
|
2018-06-04 21:10:59 +00:00
|
|
|
type Observer struct {
|
2018-06-08 20:15:18 +00:00
|
|
|
shardp2p sharding.ShardP2P
|
2018-06-08 21:45:26 +00:00
|
|
|
shardChainDb ethdb.Database
|
2018-06-11 18:00:31 +00:00
|
|
|
shardID int
|
2018-06-04 21:10:59 +00:00
|
|
|
}
|
2018-05-22 16:42:49 +00:00
|
|
|
|
|
|
|
// NewObserver creates a new observer instance.
|
2018-06-11 18:00:31 +00:00
|
|
|
func NewObserver(shardp2p sharding.ShardP2P, shardChainDb ethdb.Database, shardID int) (*Observer, error) {
|
|
|
|
return &Observer{shardp2p, shardChainDb, shardID}, nil
|
2018-05-22 16:42:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Start the main routine for an observer.
|
2018-06-12 04:46:53 +00:00
|
|
|
func (o *Observer) Start() {
|
2018-06-11 18:00:31 +00:00
|
|
|
log.Info(fmt.Sprintf("Starting observer service in shard %d", o.shardID))
|
2018-05-22 16:42:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stop the main loop for observing the shard network.
|
|
|
|
func (o *Observer) Stop() error {
|
2018-06-11 18:00:31 +00:00
|
|
|
log.Info(fmt.Sprintf("Starting observer service in shard %d", o.shardID))
|
2018-05-22 16:42:49 +00:00
|
|
|
return nil
|
|
|
|
}
|