service

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package service is a service to interact with Stratumn coins. It runs a proof of work consensus engine between Stratumn nodes.

Index

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")

	// ErrUnavailable is returned from gRPC methods when the service is not
	// 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

func GetGenesisBlock() (*pb.Block, error)

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

func (c *Config) GetGenesisBlock() (*pb.Block, error)

GetGenesisBlock gets the genesis block from the config if present.

func (*Config) GetMinerID

func (c *Config) GetMinerID() (peer.ID, error)

GetMinerID reads the miner's peer ID from the configuration.

type Host

type Host = ihost.Host

Host represents an Stratumn Node host.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the Coin service.

func (*Service) AddToGRPCServer

func (s *Service) AddToGRPCServer(gs *grpc.Server)

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) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

func (*Service) Expose

func (s *Service) Expose() interface{}

Expose exposes the coin service to other services.

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Needs

func (s *Service) Needs() map[string]struct{}

Needs returns the set of services this service depends on.

func (*Service) Plug

func (s *Service) Plug(exposed map[string]interface{}) error

Plug sets the connected services.

func (*Service) Run

func (s *Service) Run(ctx context.Context, running, stopping func()) error

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL