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 // 通信协议版本号 // 挖矿端类型 WorkerKindOfBlank uint8 = 0 WorkerKindOfCPU uint8 = 1 // CPU WorkerKindOfGPU uint8 = 2 // GPU 显卡挖矿 )
type
View Source
const ( MsgErrorRetCodeSuccess uint16 = 0 // OK MsgErrorRetCodeConnectReadSengErr uint16 = 1 // 消息发送或读取错误 MsgErrorRetCodeAgreementVersionNumberErr uint16 = 2 // 连接数太多 MsgErrorRetCodeTooManyConnects uint16 = 3 // 连接数太多 )
错误响应
View Source
const ( // 0 为错误 MinerWorkMsgTypeWorkerRegistration uint16 = 1 // worker 注册 MinerWorkMsgTypeServerResponse uint16 = 2 // server 响应 MinerWorkMsgTypeMiningBlock uint16 = 3 // 矿池发给矿工的区块挖矿信息 MinerWorkMsgTypeReportMiningResult uint16 = 4 // 挖掘结果上报 )
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)
收取消息 mustlen = 消息必须长度
func MsgSendToTcpConn ¶
发送消息
func SendServerResponse ¶
func SendServerResponse(conn *net.TCPConn, resmsg *MsgServerResponse)
服务端响应
func SendServerResponseByRetCode ¶
服务端响应
Types ¶
type MsgPendingMiningBlockStuff ¶
type MsgPendingMiningBlockStuff struct { BlockHeadMeta interfaces.Block // 区块的 head 和 meta CoinbaseTx *transactions.Transaction_0_Coinbase // coinbase 交易 MrklRelatedTreeListForCoinbaseTxModify []fields.Hash // 默克尔树关联哈希 // contains filtered or unexported fields }
func CreatePendingMiningBlockStuffByBlock ¶
func CreatePendingMiningBlockStuffByBlock(block interfaces.Block) (*MsgPendingMiningBlockStuff, error)
创建 mining stuff
func (MsgPendingMiningBlockStuff) CalculateBlockHashByBothNonce ¶
func (m MsgPendingMiningBlockStuff) CalculateBlockHashByBothNonce(headNonce fields.Bytes4, coinbaseNonce fields.Bytes32, retcopy bool) (*MsgPendingMiningBlockStuff, fields.Hash)
通过设置nonce值计算 区块哈希
func (MsgPendingMiningBlockStuff) CalculateBlockHashByMiningResult ¶
func (m MsgPendingMiningBlockStuff) CalculateBlockHashByMiningResult(result *MsgReportMiningResult, retcopy bool) (*MsgPendingMiningBlockStuff, fields.Hash)
通过设置nonce值计算 区块哈希
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)
反序列化
func (MsgPendingMiningBlockStuff) Serialize ¶
func (m MsgPendingMiningBlockStuff) Serialize() []byte
序列化
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 // 挖掘成功 或者 报告算力 BlockHeight fields.BlockHeight // 挖掘的区块高度 HeadNonce fields.Bytes4 // block head nonce CoinbaseNonce fields.Bytes32 // coinbase nonce }
type MsgServerResponse ¶
type MsgServerResponse struct { RetCode fields.VarUint2 // 响应码: 0. 正确可连接 1.版本不匹配 2. 连接数过多 等等 AcceptHashrateStatistics fields.Bool // 是否接受算力统计 }
func HandleConnectToServer ¶
func HandleConnectToServer(conn *net.TCPConn, rewardaddr *fields.Address) (*MsgServerResponse, error)
连接到服务器
type MsgWorkerRegistration ¶
type MsgWorkerRegistration struct { PoolAndWorkerAgreementVersionNumber fields.VarUint2 // 版本号 WorkerKind fields.VarUint1 // 挖矿端类型 RewardAddress fields.Address // 收取奖励地址 }
func HandleConnectToClient ¶
func HandleConnectToClient(conn *net.TCPConn, isAcceptHashrateStatistics bool) (*MsgWorkerRegistration, error)
连接到客户端
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.