service

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlgoConfig = map[string]*Algo{}
View Source
var CurrencyConfig = map[string]*ChainConfig{}

This is a global lookup for currency information. All programs load "common" configuration on start and populate this by calling "SetupCurrencies"

View Source
var RawCurrencyConfig map[string]interface{}
View Source
var ShareChain = map[string]*ShareChainConfig{}

Functions

func SetupCurrencies

func SetupCurrencies(rawConfig map[string]interface{})

This parses the viper config structure using ChainConfigDecoder to populate CurrencyConfig with ChainConfig structures

func SetupShareChains

func SetupShareChains(rawConfig map[string]interface{})

Types

type Algo

type Algo struct {
	Name           string
	PoWHash        HashFunc
	ShareDiff1     *big.Float
	NetDiff1       float64
	HashesPerShare int64
}

func NewAlgoConfig

func NewAlgoConfig(name string, diff1Hex string, powFunc HashFunc, hps int64) *Algo

func (*Algo) Diff1SharesForTarget

func (a *Algo) Diff1SharesForTarget(blockTarget float64) (float64, big.Accuracy)

func (*Algo) MarshalJSON

func (u *Algo) MarshalJSON() ([]byte, error)

type ChainConfig

type ChainConfig struct {
	Code                 string
	BlockMatureConfirms  int64
	FlushAux             bool
	PayoutTransactionFee int

	MultiAlgo         bool
	MultiAlgoMap      map[string]uint32
	MultiAlgoBitShift uint32
	MultiAlgoBitWidth uint32

	Algo                *Algo
	Params              *chaincfg.Params `json:"-"`
	BlockSubsidyAddress *btcutil.Address
}

This encodes network rules and pool wide preferences for handling of that currency. There would be a different one of these for testnet, mainnet, or regtest blockchains for a single currency.

func (*ChainConfig) MarshalJSON

func (u *ChainConfig) MarshalJSON() ([]byte, error)

type ChainConfigDecoder

type ChainConfigDecoder struct {

	// The currency code. These are canoncially differentiated "LTC_T" for a
	// litecoin testnet, or "LTC_R" for a litecoin regtest network, since this
	// Code technically encodes the network type as well. It must be unique.
	Code string
	// Number of confirmations required before coinbase UTXOs are allowed to be
	// spent. This is a network rule that varies per-currency. This is required
	// to know when we can payout credits to users. If set too low,
	// transactions will fail to be confirmed by the network
	BlockMatureConfirms int64
	// If this currency is merge mined, should we flush stratum miner jobs when
	// a new block is announced? This should be selected based on the cost of a
	// work restart (in stale shares), and the value of merge mined currency.
	// If the merge mined currency is worth 1/1000th of the main chain
	// currency, probably leave this false. If they are close in value,
	// consider setting it to true
	FlushAux bool
	// This is the transaction fee to use for payouts. Given in satoshis / byte
	PayoutTransactionFee int

	// The address to send newly mined coins
	SubsidyAddress string
	// The name of an algorithm. Current options are scrypt, sha256d, lyra2rev2, x17, argon2
	PowAlgorithm string

	// Address Version (pubkey prefix) given in hex (1 byte)
	PubKeyAddrID string
	// Private key version for Wallet Import Format (WIF) given in hex (1 byte)
	PrivKeyID string
	// Private key version for Wallet Import Format (WIF) given in hex (1 byte)
	PrivKeyAddrID string
	// The p2p message magic bytes. This is a sequence of 4 bytes that allow
	// bitcoin to reject connections from litecoin nodes, etc. It is sent at
	// the beginning of every message on bitcoin p2p networks, and is unique to
	// the currency and network
	NetMagic uint32

	// A flag for whether the following group settings are relevant.
	// Configuring these details allows the job generator to change the version
	// bits in block headers for multi-algo currencies, allowing only a single
	// coinserver to be required
	MultiAlgo bool
	// A map from algorithm name to integer identifier. Usually found in pureheader.h
	MultiAlgoMap map[string]uint32
	// The number of bits to shift the algo identifier into the version (0-31)
	MultiAlgoBitShift uint32
	// The bit width of the algo identifier in the version
	MultiAlgoBitWidth uint32
}

This is the structure for the config file represnetation of a "ChainConfig". Many of these properties get parsed into special datastructures for easier use later

type HashFunc

type HashFunc func(input []byte) ([]byte, error)

type Service

type Service struct {
	Name       string
	PushStatus chan map[string]interface{}
	// contains filtered or unexported fields
}

func NewService

func NewService(namespace string, etcdEndpoints []string) *Service

func (*Service) KeepAlive

func (s *Service) KeepAlive(labels map[string]string) error

func (*Service) LoadCommonConfig

func (s *Service) LoadCommonConfig() *viper.Viper

func (*Service) LoadServiceConfig

func (s *Service) LoadServiceConfig(config *viper.Viper, name string)

func (*Service) LoadServices

func (s *Service) LoadServices(namespace string) (map[string]*ServiceStatus, error)

Requests all services of a specific namespace. This is used in the same context as ServiceWatcher, except for simple script executions

func (*Service) ServiceWatcher

func (s *Service) ServiceWatcher(watchNamespace string) (chan ServiceStatusUpdate, error)

This watches for services of a specific namespace to change, and broadcasts those changes over the provided channel. How the updates are handled is up to the reciever

type ServiceStatus

type ServiceStatus struct {
	ServiceID  string                 `json:"service_id"`
	Status     map[string]interface{} `json:"status"`
	Labels     map[string]string      `json:"labels"`
	UpdateTime time.Time              `json:"update_time"`
}

type ServiceStatusUpdate

type ServiceStatusUpdate struct {
	ServiceType string
	ServiceID   string
	Status      *ServiceStatus
	Action      string
}

type ShareChainConfig

type ShareChainConfig struct {
	Name         string  `json:"name"`
	PayoutMethod string  `json:"payout_method"`
	Fee          float64 `json:"fee"`
	AlgoName     string  `mapstructure:"algo" json:"algo"`
	Algo         *Algo   `mapstructure:"-" json:"-"`
}

Jump to

Keyboard shortcuts

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