Documentation
¶
Overview ¶
Package stratum implements a minimal Handshake-specific Stratum v1 server.
The protocol uses standard Stratum JSON line framing and method names (mining.subscribe, mining.authorize, mining.submit). Work notifications intentionally carry a serialized Handshake header template instead of Bitcoin coinbase-splitting fields because Handshake's mining search space is in the 236-byte header, including the 24-byte ExtraNonce field.
Index ¶
Constants ¶
const ( // ExtraNonce1Size is the server-assigned prefix of the Handshake // header ExtraNonce field. ExtraNonce1Size = 8 // ExtraNonce2Size is the miner-supplied suffix of the Handshake header // ExtraNonce field. ExtraNonce2Size = 16 )
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type BlockTemplateGenerator ¶
type BlockTemplateGenerator interface {
NewBlockTemplate(hnsutil.Address) (*mining.BlockTemplate, error)
BestSnapshot() *blockchain.BestState
}
BlockTemplateGenerator is the subset of the mining template generator used by the Stratum server.
type Config ¶
type Config struct {
ChainParams *chaincfg.Params
BlockTemplateGenerator BlockTemplateGenerator
MiningAddrs []hnsutil.Address
Listeners []net.Listener
ProcessBlock func(*hnsutil.Block, blockchain.BehaviorFlags) (bool, error)
Authorize func(user, pass string) bool
Difficulty float64
JobRefreshInterval time.Duration
}
Config describes a Stratum server instance.
type Job ¶
type Job struct {
ID string
Seq uint64
Block *wire.MsgBlock
Height int32
PrevBlock chainhash.Hash
Created time.Time
Submitted map[string]struct{}
}
Job is a mining job derived from a Handshake block template.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides a minimal Stratum v1 server for Handshake mining.
func (*Server) ServeConn ¶
ServeConn runs a single Stratum client connection. It is primarily useful for focused protocol tests.
func (*Server) Submit ¶
func (s *Server) Submit(jobID string, extraNonce1 []byte, extraNonce2Hex, ntimeHex, nonceHex string) (*SubmitResult, error)
Submit validates and possibly submits a share for the provided job. It only calls ProcessBlock when the reconstructed Handshake block hash meets the network target encoded by the block header.