Documentation ¶
Index ¶
- Constants
- func MsgReadFromTcpConn(conn *net.TCPConn, mustlen uint32) (msgty uint16, msgbody []byte, err error)
- func MsgSendToTcpConn(conn *net.TCPConn, msgty uint16, msgbody []byte) (err error)
- func SendServerResponse(conn *net.TCPConn, resmsg *MsgServerResponse)
- func SendServerResponseByRetCode(conn *net.TCPConn, retcode uint16)
- type MsgPendingMiningBlockStuff
- func (m MsgPendingMiningBlockStuff) CalculateBlockHashByBothNonce(headNonce fields.Bytes4, coinbaseNonce fields.Bytes32, retcopy bool) (*MsgPendingMiningBlockStuff, fields.Hash)
- func (m MsgPendingMiningBlockStuff) CalculateBlockHashByMiningResult(result *MsgReportMiningResult, retcopy bool) (*MsgPendingMiningBlockStuff, fields.Hash)
- func (m MsgPendingMiningBlockStuff) CopyForMiningByRandomSetCoinbaseNonce() interfaces.PowWorkerMiningStuffItem
- func (m MsgPendingMiningBlockStuff) GetCoinbaseNonce() []byte
- func (m MsgPendingMiningBlockStuff) GetHeadMetaBlock() interfaces.Block
- func (m MsgPendingMiningBlockStuff) GetHeadNonce() []byte
- func (m MsgPendingMiningBlockStuff) GetMiningSuccessed() bool
- func (m *MsgPendingMiningBlockStuff) Parse(buf []byte, seek uint32) (uint32, error)
- func (m MsgPendingMiningBlockStuff) Serialize() []byte
- func (m MsgPendingMiningBlockStuff) SetHeadNonce(nonce []byte)
- func (m *MsgPendingMiningBlockStuff) SetMiningSuccessed(ok bool)
- type MsgReportMiningResult
- type MsgServerResponse
- type MsgWorkerRegistration
- type PowDeviceWorker
- type PowMasterMsg
Constants ¶
View Source
const ( PowMasterMsgSize = blocks.BlockHeadSize + blocks.BlockMetaSizeV1 + 1 + 4 + 4 PowMasterMsgStatusContinue fields.VarUint1 = 0 PowMasterMsgStatusSuccess fields.VarUint1 = 1 PowMasterMsgStatusStop fields.VarUint1 = 2 PowMasterMsgStatusMostPowerHash fields.VarUint1 = 3 PowMasterMsgStatusMostPowerHashAndRequestNextMining fields.VarUint1 = 4 )
View Source
const ( PoolAndWorkerAgreementVersionNumber uint16 = 1 // Communication protocol version number // Mining end type WorkerKindOfBlank uint8 = 0 WorkerKindOfCPU uint8 = 1 // CPU WorkerKindOfGPU uint8 = 2 // GPU graphics card mining )
type
View Source
const ( MsgErrorRetCodeSuccess uint16 = 0 // OK MsgErrorRetCodeConnectReadSengErr uint16 = 1 // Message sending or reading error MsgErrorRetCodeAgreementVersionNumberErr uint16 = 2 // Too many connections MsgErrorRetCodeTooManyConnects uint16 = 3 // Too many connections )
Error response
View Source
const ( // 0 is an error MinerWorkMsgTypeWorkerRegistration uint16 = 1 // Worker Registration MinerWorkMsgTypeServerResponse uint16 = 2 // Server response MinerWorkMsgTypeMiningBlock uint16 = 3 // Block mining information sent by the ore pool to the miners MinerWorkMsgTypeReportMiningResult uint16 = 4 // Mining result reporting )
msg
View Source
const MsgWorkerRegistrationSize = 2 + 1 + 21
View Source
const MsgWorkerServerResponseSize = 2 + 1
Variables ¶
This section is empty.
Functions ¶
func MsgReadFromTcpConn ¶
func MsgReadFromTcpConn(conn *net.TCPConn, mustlen uint32) (msgty uint16, msgbody []byte, err error)
Receive message mustlen = message must be long
func MsgSendToTcpConn ¶
send message
func SendServerResponse ¶
func SendServerResponse(conn *net.TCPConn, resmsg *MsgServerResponse)
Server response
func SendServerResponseByRetCode ¶
Server response
Types ¶
type MsgPendingMiningBlockStuff ¶
type MsgPendingMiningBlockStuff struct { BlockHeadMeta interfaces.Block // Block head and meta CoinbaseTx *transactions.Transaction_0_Coinbase // Coinbase transaction MrklRelatedTreeListForCoinbaseTxModify []fields.Hash // Merkel Tree Association hash // contains filtered or unexported fields }
func CreatePendingMiningBlockStuffByBlock ¶
func CreatePendingMiningBlockStuffByBlock(block interfaces.Block) (*MsgPendingMiningBlockStuff, error)
Creating mining stuff
func (MsgPendingMiningBlockStuff) CalculateBlockHashByBothNonce ¶
func (m MsgPendingMiningBlockStuff) CalculateBlockHashByBothNonce(headNonce fields.Bytes4, coinbaseNonce fields.Bytes32, retcopy bool) (*MsgPendingMiningBlockStuff, fields.Hash)
Calculate block hash by setting nonce value
func (MsgPendingMiningBlockStuff) CalculateBlockHashByMiningResult ¶
func (m MsgPendingMiningBlockStuff) CalculateBlockHashByMiningResult(result *MsgReportMiningResult, retcopy bool) (*MsgPendingMiningBlockStuff, fields.Hash)
Calculate block hash by setting nonce value
func (MsgPendingMiningBlockStuff) CopyForMiningByRandomSetCoinbaseNonce ¶
func (m MsgPendingMiningBlockStuff) CopyForMiningByRandomSetCoinbaseNonce() interfaces.PowWorkerMiningStuffItem
func (MsgPendingMiningBlockStuff) GetCoinbaseNonce ¶
func (m MsgPendingMiningBlockStuff) GetCoinbaseNonce() []byte
func (MsgPendingMiningBlockStuff) GetHeadMetaBlock ¶
func (m MsgPendingMiningBlockStuff) GetHeadMetaBlock() interfaces.Block
func (MsgPendingMiningBlockStuff) GetHeadNonce ¶
func (m MsgPendingMiningBlockStuff) GetHeadNonce() []byte
func (MsgPendingMiningBlockStuff) GetMiningSuccessed ¶
func (m MsgPendingMiningBlockStuff) GetMiningSuccessed() bool
func (*MsgPendingMiningBlockStuff) Parse ¶
func (m *MsgPendingMiningBlockStuff) Parse(buf []byte, seek uint32) (uint32, error)
Deserialization
func (MsgPendingMiningBlockStuff) Serialize ¶
func (m MsgPendingMiningBlockStuff) Serialize() []byte
serialize
func (MsgPendingMiningBlockStuff) SetHeadNonce ¶
func (m MsgPendingMiningBlockStuff) SetHeadNonce(nonce []byte)
func (*MsgPendingMiningBlockStuff) SetMiningSuccessed ¶
func (m *MsgPendingMiningBlockStuff) SetMiningSuccessed(ok bool)
type MsgReportMiningResult ¶
type MsgReportMiningResult struct { MintSuccessed fields.Bool // Mining success or reporting computing power BlockHeight fields.BlockHeight // Excavated block height HeadNonce fields.Bytes4 // block head nonce CoinbaseNonce fields.Bytes32 // coinbase nonce }
func (*MsgReportMiningResult) Parse ¶
func (m *MsgReportMiningResult) Parse(buf []byte, seek uint32) (uint32, error)
Deserialization
func (MsgReportMiningResult) Serialize ¶
func (m MsgReportMiningResult) Serialize() []byte
serialize
type MsgServerResponse ¶
type MsgServerResponse struct { RetCode fields.VarUint2 // Response code: 0. 正确可连接 1.版本不匹配 2. 连接数过多 等等 AcceptHashrateStatistics fields.Bool // Whether to accept calculation force statistics }
func HandleConnectToServer ¶
func HandleConnectToServer(conn *net.TCPConn, rewardaddr *fields.Address) (*MsgServerResponse, error)
Connect to server
type MsgWorkerRegistration ¶
type MsgWorkerRegistration struct { PoolAndWorkerAgreementVersionNumber fields.VarUint2 // Version number WorkerKind fields.VarUint1 // Mining end type RewardAddress fields.Address // Reward collection address }
func HandleConnectToClient ¶
func HandleConnectToClient(conn *net.TCPConn, isAcceptHashrateStatistics bool) (*MsgWorkerRegistration, error)
Connect to client
func (*MsgWorkerRegistration) Parse ¶
func (m *MsgWorkerRegistration) Parse(buf []byte, seek uint32) (uint32, error)
Deserialization
func (MsgWorkerRegistration) Serialize ¶
func (m MsgWorkerRegistration) Serialize() []byte
serialize
type PowDeviceWorker ¶
type PowDeviceWorker interface { Excavate(inputblockheadmeta interfaces.Block, outputCh chan PowMasterMsg) SetCoinbaseMsgNum(coinbaseMsgNum uint32) StopMining() }
type PowMasterMsg ¶
type PowMasterMsg struct { Status fields.VarUint1 // CoinbaseMsgNum fields.VarUint4 NonceBytes fields.Bytes4 BlockHeadMeta interfaces.Block }
func NewPowMasterMsg ¶
func NewPowMasterMsg() *PowMasterMsg
func (*PowMasterMsg) Serialize ¶
func (p *PowMasterMsg) Serialize() ([]byte, error)
func (*PowMasterMsg) Size ¶
func (p *PowMasterMsg) Size() uint32
Click to show internal directories.
Click to hide internal directories.