You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
726 B
32 lines
726 B
4 years ago
|
package synchronize
|
||
|
|
||
|
import (
|
||
|
"github.com/harmony-one/harmony/core"
|
||
|
"github.com/harmony-one/harmony/hmy/downloader"
|
||
|
"github.com/harmony-one/harmony/p2p"
|
||
|
)
|
||
|
|
||
|
// Service is simply a adapter of Downloaders, which support block synchronization
|
||
|
type Service struct {
|
||
|
Downloaders *downloader.Downloaders
|
||
|
}
|
||
|
|
||
|
// NewService creates the a new downloader service
|
||
|
func NewService(host p2p.Host, bcs []*core.BlockChain, config downloader.Config) *Service {
|
||
|
return &Service{
|
||
|
Downloaders: downloader.NewDownloaders(host, bcs, config),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Start start the service
|
||
|
func (s *Service) Start() error {
|
||
|
s.Downloaders.Start()
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Stop stop the service
|
||
|
func (s *Service) Stop() error {
|
||
|
s.Downloaders.Close()
|
||
|
return nil
|
||
|
}
|