forked from celestiaorg/celestia-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(nodebuilder): moving service/<service> services to respectiv…
…e node sub-packages (celestiaorg#1056)
- Loading branch information
1 parent
09127c0
commit 646dd9e
Showing
59 changed files
with
390 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package fraud | ||
|
||
import "github.com/celestiaorg/celestia-node/fraud" | ||
|
||
// Module encompasses the behavior necessary to subscribe and broadcast | ||
// fraud proofs within the network. | ||
type Module interface { | ||
fraud.Service | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package header | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/celestiaorg/celestia-node/header" | ||
"github.com/celestiaorg/celestia-node/header/p2p" | ||
"github.com/celestiaorg/celestia-node/header/sync" | ||
) | ||
|
||
type Module interface { | ||
// GetByHeight returns the ExtendedHeader at the given height, blocking | ||
// until header has been processed by the store or context deadline is exceeded. | ||
GetByHeight(context.Context, uint64) (*header.ExtendedHeader, error) | ||
// Head returns the ExtendedHeader of the chain head. | ||
Head(context.Context) (*header.ExtendedHeader, error) | ||
// IsSyncing returns the status of sync | ||
IsSyncing() bool | ||
} | ||
|
||
// service represents the header service that can be started / stopped on a node. | ||
// service's main function is to manage its sub-services. service can contain several | ||
// sub-services, such as Exchange, ExchangeServer, Syncer, and so forth. | ||
type service struct { | ||
ex header.Exchange | ||
|
||
syncer *sync.Syncer | ||
sub header.Subscriber | ||
p2pServer *p2p.ExchangeServer | ||
store header.Store | ||
} | ||
|
||
// NewHeaderService creates a new instance of header service. | ||
func NewHeaderService( | ||
syncer *sync.Syncer, | ||
sub header.Subscriber, | ||
p2pServer *p2p.ExchangeServer, | ||
ex header.Exchange, | ||
store header.Store) Module { | ||
return &service{ | ||
syncer: syncer, | ||
sub: sub, | ||
p2pServer: p2pServer, | ||
ex: ex, | ||
store: store, | ||
} | ||
} | ||
|
||
func (s *service) GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error) { | ||
return s.store.GetByHeight(ctx, height) | ||
} | ||
|
||
func (s *service) Head(ctx context.Context) (*header.ExtendedHeader, error) { | ||
return s.store.Head(ctx) | ||
} | ||
|
||
func (s *service) IsSyncing() bool { | ||
return !s.syncer.State().Finished() | ||
} |
Oops, something went wrong.