Documentation ¶
Overview ¶
Package service is a service to interact with Stratumn coins. It runs a proof of work consensus engine between Stratumn nodes.
Index ¶
- Variables
- func GetGenesisBlock() (*pb.Block, error)
- type Config
- type Host
- type Service
- func (s *Service) AddToGRPCServer(gs *grpc.Server)
- func (s *Service) Config() interface{}
- func (s *Service) Desc() string
- func (s *Service) Expose() interface{}
- func (s *Service) ID() string
- func (s *Service) Name() string
- func (s *Service) Needs() map[string]struct{}
- func (s *Service) Plug(exposed map[string]interface{}) error
- func (s *Service) Run(ctx context.Context, running, stopping func()) error
- func (s *Service) SetConfig(config interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotHost is returned when the connected service is not a host. ErrNotHost = errors.New("connected service is not a host") // ErrNotPubSub is returned when the connected service is not a pubsub. ErrNotPubSub = errors.New("connected service is not a pubsub") // ErrNotKadDHT is returned when the connected service is not a pubsub. ErrNotKadDHT = errors.New("connected service is not a kaddht") // available. ErrUnavailable = errors.New("the service is not available") // ErrMissingMinerID is returned when the miner's peer ID is missing // from the configuration file. ErrMissingMinerID = errors.New("the miner's peer ID should be configured") )
Functions ¶
func GetGenesisBlock ¶
GetGenesisBlock returns the default genesis block.
Types ¶
type Config ¶
type Config struct { // Host is the name of the host service. Host string `toml:"host" comment:"The name of the host service."` // Version is the version of the coin service. Version int `toml:"version" comment:"The version of the coin service."` // MaxTxPerBlock is the maximum number of transactions in a block. MaxTxPerBlock int `toml:"max_tx_per_block" comment:"The maximum number of transactions in a block."` // MinerReward is the reward miners should get when producing blocks. MinerReward int `toml:"miner_reward" comment:"The reward miners should get when producing blocks."` // BlockDifficulty is the difficulty for block production. BlockDifficulty int `toml:"block_difficulty" comment:"The difficulty for block production."` // DbPath is the path to the database used for the state and the chain.. DbPath string `toml:"db_path" comment:"The path to the database used for the state and the chain."` // PubSub is the name of the pubsub service. PubSub string `toml:"pubsub" comment:"The name of the pubsub service."` // MinerID is the peer ID of the miner. // Block rewards will be sent to this peer. // Note that a miner can generate as many peer IDs as it wants and use any of them. MinerID string `toml:"miner_id" comment:"The peer ID of the miner."` // KadDHT is the name of the kaddht service. KadDHT string `toml:"kaddht" comment:"The name of the kaddht service."` // GenesisBlock is the genesis block in hex. If none given, we use the default one in protocol/coin. GenesisBlock string `toml:"genesis_block" comment:"The genesis block in hex."` }
Config contains configuration options for the Coin service.
func (*Config) GetGenesisBlock ¶
GetGenesisBlock gets the genesis block from the config if present.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Coin service.
func (*Service) AddToGRPCServer ¶
AddToGRPCServer adds the service to a gRPC server.
func (*Service) Config ¶
func (s *Service) Config() interface{}
Config returns the current service configuration or creates one with good default values.
func (*Service) Expose ¶
func (s *Service) Expose() interface{}
Expose exposes the coin service to other services.
Click to show internal directories.
Click to hide internal directories.