提交 2d1a4c27 作者: Michael Avila

Rename ProviderSystem to System

License: MIT
Signed-off-by: 's avatarMichael Avila <davidmichaelavila@gmail.com>
上级 f8c8d858
...@@ -286,7 +286,7 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error { ...@@ -286,7 +286,7 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {
return err return err
} }
tracker := provider.NewTracker(n.Repo.Datastore()) tracker := provider.NewTracker(n.Repo.Datastore())
n.Provider = provider.NewProviderSystem( n.Provider = provider.NewSystem(
provider.NewProvider(ctx, queueP, tracker, n.Routing), provider.NewProvider(ctx, queueP, tracker, n.Routing),
// TODO: configure time.Minute and time.Hour*12 // TODO: configure time.Minute and time.Hour*12
provider.NewReprovider(ctx, queueR, tracker, time.Minute, time.Hour*12, n.Blockstore, n.Routing), provider.NewReprovider(ctx, queueR, tracker, time.Minute, time.Hour*12, n.Blockstore, n.Routing),
......
...@@ -119,12 +119,12 @@ type IpfsNode struct { ...@@ -119,12 +119,12 @@ type IpfsNode struct {
RecordValidator record.Validator RecordValidator record.Validator
// Online // Online
PeerHost p2phost.Host // the network host (server+client) PeerHost p2phost.Host // the network host (server+client)
Bootstrapper io.Closer // the periodic bootstrapper Bootstrapper io.Closer // the periodic bootstrapper
Routing routing.IpfsRouting // the routing system. recommend ipfs-dht Routing routing.IpfsRouting // the routing system. recommend ipfs-dht
Exchange exchange.Interface // the block exchange + strategy (bitswap) Exchange exchange.Interface // the block exchange + strategy (bitswap)
Namesys namesys.NameSystem // the name system, resolves paths to hashes Namesys namesys.NameSystem // the name system, resolves paths to hashes
Provider *provider.ProviderSystem // the value provider system Provider *provider.System // the value provider system
IpnsRepub *ipnsrp.Republisher IpnsRepub *ipnsrp.Republisher
AutoNAT *autonat.AutoNATService AutoNAT *autonat.AutoNATService
......
...@@ -5,29 +5,29 @@ import ( ...@@ -5,29 +5,29 @@ import (
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
) )
// ProviderSystem bundles together provider and reprovider behavior // System bundles together provider and reprovider behavior
// into one system // into one system
type ProviderSystem struct { type System struct {
provider Provider provider Provider
reprovider *Reprovider reprovider *Reprovider
} }
// NewProviderSystem creates a new ProviderSystem // NewSystem creates a new System
func NewProviderSystem(p Provider, r *Reprovider) *ProviderSystem { func NewSystem(p Provider, r *Reprovider) *System {
return &ProviderSystem{ return &System{
provider: p, provider: p,
reprovider: r, reprovider: r,
} }
} }
// Run starts the provider system loops // Run starts the provider system loops
func (ps *ProviderSystem) Run() { func (ps *System) Run() {
ps.provider.Run() ps.provider.Run()
ps.reprovider.Run() ps.reprovider.Run()
} }
// Close stops the provider system loops // Close stops the provider system loops
func (ps *ProviderSystem) Close() error { func (ps *System) Close() error {
var errs []error var errs []error
if err := ps.provider.Close(); err != nil { if err := ps.provider.Close(); err != nil {
...@@ -45,17 +45,17 @@ func (ps *ProviderSystem) Close() error { ...@@ -45,17 +45,17 @@ func (ps *ProviderSystem) Close() error {
} }
// Provide a cid by announcing it to the network // Provide a cid by announcing it to the network
func (ps *ProviderSystem) Provide(cid cid.Cid) { func (ps *System) Provide(cid cid.Cid) {
ps.provider.Provide(cid) ps.provider.Provide(cid)
} }
// Tracking returns all cids that are currently being tracked and reprovided // Tracking returns all cids that are currently being tracked and reprovided
// by the provider system. // by the provider system.
func (ps *ProviderSystem) Tracking() (<-chan cid.Cid, error) { func (ps *System) Tracking() (<-chan cid.Cid, error) {
return ps.provider.Tracking() return ps.provider.Tracking()
} }
// Reprovide triggers a reprovide // Reprovide triggers a reprovide
func (ps *ProviderSystem) Reprovide(ctx context.Context) error { func (ps *System) Reprovide(ctx context.Context) error {
return ps.reprovider.Trigger(ctx) return ps.reprovider.Trigger(ctx)
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论