stratum

package
v0.0.0-...-16720d6 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Overview

Many api integration functions and ideas from: https://github.com/JKKGBE/open-zcash-pool which is a fork of https://github.com/sammy007/open-ethereum-pool

Generated from https://github.com/streamrail/concurrent-map

Some payments integration functions and ideas from: https://github.com/JKKGBE/open-zcash-pool which is a fork of https://github.com/sammy007/open-ethereum-pool

Some struct integrations and ideas from: https://github.com/JKKGBE/open-zcash-pool which is a fork of https://github.com/sammy007/open-ethereum-pool

Many unlocker integration functions and ideas from: https://github.com/JKKGBE/open-zcash-pool which is a fork of https://github.com/sammy007/open-ethereum-pool

Index

Constants

View Source
const MINER_TX_AMOUNT_UNLOCK = config.MINER_TX_AMOUNT_UNLOCK

Get constant blocks required to mature from derosuite

View Source
const (
	MaxReqSize = 10 * 1024
)

Variables

View Source
var APIErrorLogger = logFileOutAPI("ERROR")
View Source
var APIInfoLogger = logFileOutAPI("INFO")
View Source
var BlocksErrorLogger = logFileOutBlocks("ERROR")
View Source
var BlocksInfoLogger = logFileOutBlocks("INFO")
View Source
var ChartsErrorLogger = logFileOutCharts("ERROR")
View Source
var ChartsInfoLogger = logFileOutCharts("INFO")
View Source
var EventsErrorLogger = logFileOutEvents("ERROR")
View Source
var EventsInfoLogger = logFileOutEvents("INFO")
View Source
var HandlersErrorLogger = logFileOutHandlers("ERROR")
View Source
var HandlersInfoLogger = logFileOutHandlers("INFO")
View Source
var MinerErrorLogger = logFileOutMiner("ERROR")
View Source
var MinerInfoLogger = logFileOutMiner("INFO")
View Source
var PaymentsErrorLogger = logFileOutPayments("ERROR")
View Source
var PaymentsInfoLogger = logFileOutPayments("INFO")
View Source
var SHARD_COUNT = 32
View Source
var StorageErrorLogger = logFileOutStorage("ERROR")
View Source
var StorageInfoLogger = logFileOutStorage("INFO")
View Source
var StratumErrorLogger = logFileOutStratum("ERROR")
View Source
var StratumInfoLogger = logFileOutStratum("INFO")
View Source
var UnlockerErrorLogger = logFileOutUnlocker("ERROR")
View Source
var UnlockerInfoLogger = logFileOutUnlocker("INFO")

Functions

This section is empty.

Types

type ApiBlocks

type ApiBlocks struct {
	Hash        string
	Address     string
	Height      int64
	Orphan      bool
	Timestamp   int64
	Difficulty  int64
	TotalShares int64
	Reward      uint64
	Solo        bool
}

type ApiEventPayments

type ApiEventPayments struct {
	Timestamp int64
	Amount    uint64
	Address   string
}

type ApiMiner

type ApiMiner struct {
	LastBeat      int64
	StartedAt     int64
	ValidShares   int64
	InvalidShares int64
	StaleShares   int64
	Accepts       int64
	Rejects       int64
	RoundShares   int64
	Hashrate      int64
	Offline       bool
	sync.RWMutex
	Id            string
	Address       string
	IsSolo        bool
	DonatePercent int64
	DonationTotal int64
}

type ApiPayments

type ApiPayments struct {
	Hash      string
	Timestamp int64
	Payees    uint64
	Mixin     uint64
	Amount    uint64
	Fee       uint64
}

type ApiServer

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

func NewApiServer

func NewApiServer(cfg *pool.APIConfig, s *StratumServer, eventsconfig *pool.EventsConfig) *ApiServer

func (*ApiServer) AccountIndex

func (apiServer *ApiServer) AccountIndex(writer http.ResponseWriter, r *http.Request)

func (*ApiServer) BlocksIndex

func (apiServer *ApiServer) BlocksIndex(writer http.ResponseWriter, _ *http.Request)

func (*ApiServer) ChartsIndex

func (apiServer *ApiServer) ChartsIndex(writer http.ResponseWriter, _ *http.Request)

func (*ApiServer) EventsIndex

func (apiServer *ApiServer) EventsIndex(writer http.ResponseWriter, _ *http.Request)

func (*ApiServer) GetConfigIndex

func (apiServer *ApiServer) GetConfigIndex() map[string]interface{}

func (*ApiServer) MinersIndex

func (apiServer *ApiServer) MinersIndex(writer http.ResponseWriter, _ *http.Request)

func (*ApiServer) PaymentsIndex

func (apiServer *ApiServer) PaymentsIndex(writer http.ResponseWriter, _ *http.Request)

func (*ApiServer) Start

func (apiServer *ApiServer) Start()

func (*ApiServer) StatsIndex

func (apiServer *ApiServer) StatsIndex(writer http.ResponseWriter, _ *http.Request)

type BlockDataGrav

type BlockDataGrav struct {
	Height      int64
	Timestamp   int64
	Difficulty  int64
	TotalShares int64
	Orphan      bool
	Solo        bool
	Hash        string
	Address     string
	Nonce       string
	PowHash     string
	Reward      uint64
	ExtraReward *big.Int
	RoundHeight int64
	BlockState  string
}

func (*BlockDataGrav) RoundKey

func (blockDataGrav *BlockDataGrav) RoundKey() string

type BlockTemplate

type BlockTemplate struct {
	Blocktemplate_blob string
	Blockhashing_blob  string
	Expected_reward    uint64
	Difficulty         uint64
	Height             uint64
	Prev_Hash          string
	Reserved_Offset    uint64
	Epoch              uint64
	Status             string
	Buffer             []byte
}

type BlockUnlocker

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

func NewBlockUnlocker

func NewBlockUnlocker(cfg *pool.UnlockerConfig, s *StratumServer) *BlockUnlocker

func (*BlockUnlocker) StartBlockUnlocker

func (u *BlockUnlocker) StartBlockUnlocker(s *StratumServer)

type BlocksFound

type BlocksFound struct {
	MinedBlocks []*BlockDataGrav
}

type BlocksFoundByHeight

type BlocksFoundByHeight struct {
	Heights map[int64]bool
}

type ChartData

type ChartData struct {
	Timestamp int64
	Value     int64
}

type Charts

type Charts struct {
	PoolChartsConfig *pool.PoolChartsConfig
	SoloChartsConfig *pool.SoloChartsConfig
	Api              *ApiServer
}

func NewChartsProcessor

func NewChartsProcessor(pcfg *pool.PoolChartsConfig, scfg *pool.SoloChartsConfig, a *ApiServer) *Charts

func (*Charts) Start

func (c *Charts) Start()

type Endpoint

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

func NewEndpoint

func NewEndpoint(cfg *pool.Port) *Endpoint

Defines parameters for the ports to be listened on, such as default difficulty

func (*Endpoint) Listen

func (e *Endpoint) Listen(s *StratumServer)

Starts listening on the ports defined in s.Listen()

type ErrorReply

type ErrorReply struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type EventData

type EventData struct {
	Timestamp int64
	Value     int64
}

type Events

type Events struct {
	EventsConfig *pool.EventsConfig
	CoinUnits    int64
}

func NewEventsProcessor

func NewEventsProcessor(eventsconfig *pool.EventsConfig, coinunits int64) *Events

func (*Events) Start

func (e *Events) Start()

type GetJobParams

type GetJobParams struct {
	Id string `json:"id"`
}

type GravitonCharts

type GravitonCharts struct {
	Values []*ChartData
}

type GravitonMiners

type GravitonMiners struct {
	Miners []*Miner
}

type GravitonStore

type GravitonStore struct {
	DB       *graviton.Store
	DBFolder string
	DBPath   string
	DBTree   string

	DBMaxSnapshot uint64
	DBMigrateWait time.Duration
	Writing       int
	// contains filtered or unexported fields
}
var Graviton_backend *GravitonStore = &GravitonStore{}

func (*GravitonStore) CompareMinerStats

func (g *GravitonStore) CompareMinerStats(storedMiner, miner *Miner, hashrateExpiration time.Duration) (*Miner, bool)

func (*GravitonStore) GetAllMinerStats

func (g *GravitonStore) GetAllMinerStats() []*Miner

func (*GravitonStore) GetBlocksFound

func (g *GravitonStore) GetBlocksFound(blocktype string) *BlocksFound

Allow for getting the blocks found by pool/solo. blocktype: orphaned, candidate, immature, matured or specify all for returning all blocks

func (*GravitonStore) GetBlocksFoundByHeightArr

func (g *GravitonStore) GetBlocksFoundByHeightArr() *BlocksFoundByHeight

func (*GravitonStore) GetChartsData

func (g *GravitonStore) GetChartsData(chartType string) *GravitonCharts

func (*GravitonStore) GetConfig

func (g *GravitonStore) GetConfig(coin string) *pool.Config

func (*GravitonStore) GetEventsData

func (g *GravitonStore) GetEventsData(date string) map[string]*Miner

func (*GravitonStore) GetEventsPayment

func (g *GravitonStore) GetEventsPayment(date string) *PaymentPending

func (*GravitonStore) GetMinerIDRegistrations

func (g *GravitonStore) GetMinerIDRegistrations() []*Miner

func (*GravitonStore) GetMinerStatsByID

func (g *GravitonStore) GetMinerStatsByID(minerID string) *Miner

func (*GravitonStore) GetPendingPayments

func (g *GravitonStore) GetPendingPayments() []*PaymentPending

func (*GravitonStore) GetPoolRoundStats

func (g *GravitonStore) GetPoolRoundStats() *PoolRound

func (*GravitonStore) GetProcessedPayments

func (g *GravitonStore) GetProcessedPayments() *ProcessedPayments

func (*GravitonStore) GetRoundShares

func (g *GravitonStore) GetRoundShares(roundHeight int64) (map[string]int64, int64, error)

func (*GravitonStore) NewGravDB

func (g *GravitonStore) NewGravDB(poolhost, dbFolder, dbmigratewait string, dbmaxsnapshot uint64)

func (*GravitonStore) OverwriteEventsData

func (g *GravitonStore) OverwriteEventsData(info map[string]*Miner, date string) error

This function is to overwrite events data

func (*GravitonStore) OverwritePendingPayments

func (g *GravitonStore) OverwritePendingPayments(info *PendingPayments) error

This function is to overwrite pending payments in the event of 'deleting' a pending payment after payment has been processed

func (*GravitonStore) OverwritePoolRoundStats

func (g *GravitonStore) OverwritePoolRoundStats(info *PoolRound) error

This function is to overwrite pool round stats which will retain *current* pool round details and updated to blank out at each new round / nextRound storage function

func (*GravitonStore) RemoveKey

func (g *GravitonStore) RemoveKey(key string) error

Function that will remove a k/v pair

func (*GravitonStore) SwapGravDB

func (g *GravitonStore) SwapGravDB(poolhost, dbFolder string)

Swaps the store pointer from existing to new after copying latest snapshot to new DB - fast as cursor + disk writes allow [possible other alternatives such as mem store for some of these interwoven, testing needed]

func (*GravitonStore) UpdatePoolRoundStats

func (g *GravitonStore) UpdatePoolRoundStats(miners MinersMap, blockFound bool) error

func (*GravitonStore) WriteBlocks

func (g *GravitonStore) WriteBlocks(info *BlockDataGrav, blockType string) error

func (*GravitonStore) WriteBlocksFoundByHeightArr

func (g *GravitonStore) WriteBlocksFoundByHeightArr(height int64, isSolo bool) error

Array of int64 [heights] of blocks found by pool, this does not include solo blocks found. Used as reference points for round hash calculations

func (*GravitonStore) WriteChartsData

func (g *GravitonStore) WriteChartsData(data *ChartData, chartType string, interval, maximumPeriod int64) error

func (*GravitonStore) WriteConfig

func (g *GravitonStore) WriteConfig(config *pool.Config) error

func (*GravitonStore) WriteEventsPayment

func (g *GravitonStore) WriteEventsPayment(payment *PaymentPending, date string) error

func (*GravitonStore) WriteImmatureBlock

func (g *GravitonStore) WriteImmatureBlock(block *BlockDataGrav) error

func (*GravitonStore) WriteImmaturePayments

func (g *GravitonStore) WriteImmaturePayments(info *PaymentPending) error

func (*GravitonStore) WriteMaturedBlocks

func (g *GravitonStore) WriteMaturedBlocks(block *BlockDataGrav) error

func (*GravitonStore) WriteMinerIDRegistration

func (g *GravitonStore) WriteMinerIDRegistration(miner *Miner) error

func (*GravitonStore) WriteMinerStats

func (g *GravitonStore) WriteMinerStats(miners MinersMap, hashrateExpiration time.Duration) error

func (*GravitonStore) WriteMinerStatsByID

func (g *GravitonStore) WriteMinerStatsByID(miner *Miner, hashrateExpiration time.Duration) error

func (*GravitonStore) WriteOrphanedBlocks

func (g *GravitonStore) WriteOrphanedBlocks(orphanedBlocks []*BlockDataGrav) error

func (*GravitonStore) WritePendingPayments

func (g *GravitonStore) WritePendingPayments(info *PaymentPending) error

func (*GravitonStore) WriteProcessedPayments

func (g *GravitonStore) WriteProcessedPayments(info *MinerPayments) error

func (*GravitonStore) WriteRoundShares

func (g *GravitonStore) WriteRoundShares(roundHeight int64, roundShares map[string]int64) error

type JSONPushMessage

type JSONPushMessage struct {
	Version string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
}

type JSONRpcReq

type JSONRpcReq struct {
	Id     *json.RawMessage `json:"id"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

type JSONRpcResp

type JSONRpcResp struct {
	Id      *json.RawMessage `json:"id"`
	Version string           `json:"jsonrpc"`
	Result  interface{}      `json:"result"`
	Error   interface{}      `json:"error"`
}

type Job

type Job struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type JobReply

type JobReply struct {
	Id     string        `json:"id"`
	Job    *JobReplyData `json:"job"`
	Status string        `json:"status"`
}

type JobReplyData

type JobReplyData struct {
	Blob   string `json:"blob"`
	JobId  string `json:"job_id"`
	Target string `json:"target"`
	Algo   string `json:"algo"`
	Height uint64 `json:"height"`
}

type LastBlock

type LastBlock struct {
	Difficulty string
	Height     int64
	Timestamp  int64
	Reward     int64
	Hash       string
}

type LoginParams

type LoginParams struct {
	Login string `json:"login"`
	Pass  string `json:"pass"`
	Agent string `json:"agent"`
}

type Miner

type Miner struct {
	LastBeat        int64
	StartedAt       int64
	EventDataOffset int64
	//EventDataTempTime int64
	ValidShares     int64
	InvalidShares   int64
	StaleShares     int64
	TrustedShares   int64
	Accepts         int64
	Rejects         int64
	Shares          map[int64]int64
	LastRoundShares int64
	RoundShares     int64
	RoundHeight     int64
	Hashrate        int64
	Offline         bool
	sync.RWMutex
	Id            string
	Address       string
	PaymentID     string
	FixedDiff     uint64
	IsSolo        bool
	WorkID        string
	Ip            string
	DonatePercent int64
	DonationTotal int64
}

func NewMiner

func NewMiner(id string, address string, paymentid string, fixedDiff uint64, workID string, donationPercent int64, isSolo bool, ip string) *Miner

type MinerPayments

type MinerPayments struct {
	Login     string
	TxHash    string
	TxKey     string
	TxFee     uint64
	Mixin     uint64
	Amount    uint64
	Timestamp int64
}

type MinerStats

type MinerStats struct {
	Address      string
	Balance      int64
	LastShare    int64
	BlocksFound  int64
	TotalPending int64
	TotalPaid    int64
	MiningShares []*MiningShare
}

type MinersMap

type MinersMap []*MinersMapShared

A "thread" safe map of type string:*Miner. To avoid lock bottlenecks this map is dived to several (SHARD_COUNT) map shards.

func NewMinersMap

func NewMinersMap() MinersMap

Creates a new concurrent map.

func (MinersMap) Count

func (m MinersMap) Count() int

Returns the number of elements within the map.

func (MinersMap) Get

func (m MinersMap) Get(key string) (*Miner, bool)

Retrieves an element from map under given key.

func (MinersMap) GetShard

func (m MinersMap) GetShard(key string) *MinersMapShared

Returns shard under given key

func (MinersMap) IsEmpty

func (m MinersMap) IsEmpty() bool

Checks if map is empty.

func (MinersMap) Remove

func (m MinersMap) Remove(key string)

Removes an element from the map.

func (MinersMap) Set

func (m MinersMap) Set(key string, value *Miner)

Sets the given value under the specified key.

type MinersMapShared

type MinersMapShared struct {
	Items        map[string]*Miner
	sync.RWMutex // Read Write mutex, guards access to internal map.
}

type MiningShare

type MiningShare struct {
	MinerID             string
	MinerJobID          string
	MinerJobNonce       string
	MinerJobResult      string
	SessionDiff         int64
	BlockTemplateHeight int64
	HashrateExpiration  time.Duration
	MinerIsSolo         bool
	MinerAddress        string
}

type PaymentPending

type PaymentPending struct {
	Timestamp int64
	Amount    uint64
	Address   string
}

type PayoutTracker

type PayoutTracker struct {
	Destinations []rpc.Destinations
	PaymentIDs   []string
}

type PayoutsProcessor

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

func NewPayoutsProcessor

func NewPayoutsProcessor(cfg *pool.PaymentsConfig, s *StratumServer) *PayoutsProcessor

func (*PayoutsProcessor) Start

func (u *PayoutsProcessor) Start(s *StratumServer)

type PendingPayments

type PendingPayments struct {
	PendingPayout []*PaymentPending
}

type PoolRound

type PoolRound struct {
	StartTimestamp  int64
	Timestamp       int64
	LastBlockHeight int64
	RoundShares     map[string]int64
}

type ProcessedPayments

type ProcessedPayments struct {
	MinerPayments []*MinerPayments
}

type RandomRewardEventDays

type RandomRewardEventDays struct {
	EventDayDetails map[int64]*RandomRewardEventMiners
}

type RandomRewardEventMiners

type RandomRewardEventMiners struct {
	MinerDetails map[string]*ApiMiner
}

type Session

type Session struct {
	sync.Mutex

	VarDiff *VarDiff
	// contains filtered or unexported fields
}

type StatusReply

type StatusReply struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

type StratumServer

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

func NewStratum

func NewStratum(cfg *pool.Config) *StratumServer

func (*StratumServer) Listen

func (s *StratumServer) Listen()

Sets up stratum to listen on the ports in config.json

func (*StratumServer) SetupCloseHandler

func (s *StratumServer) SetupCloseHandler()

SetupCloseHandler creates a 'listener' on a new goroutine which will notify the program if it receives an interrupt from the OS. We then handle this by calling our clean up procedure and exiting the program. Reference: https://golangcode.com/handle-ctrl-c-exit-in-terminal/

type SubmitParams

type SubmitParams struct {
	Id     string `json:"id"`
	JobId  string `json:"job_id"`
	Nonce  string `json:"nonce"`
	Result string `json:"result"`
}

type TreeKV

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

type UnlockResultGrav

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

type VarDiff

type VarDiff struct {
	Difficulty            int64
	Average               float64
	TimestampArr          map[int64]int64
	LastRetargetTimestamp int64
	LastTimeStamp         int64
}

Jump to

Keyboard shortcuts

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