stratum_jsonrpc2_ws

package module
v0.0.0-...-883dfbf Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 11 Imported by: 1

README

stratum-jsonrpc2.0-ws protocol

This protocol implements the Stratum protocol using JSON-RPC 2.0 over Websockets.

This project is a client implementation of the stratum-jsonrpc2.0-ws protocol.

Protocol Specification

Subscription

Client request:

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_subscribe",
  "params": ["newWork", "username", "password", "miner_agent"]
}

Server response:

Return a subscription id:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0xcd0c3e8af590364c09d0fa6a1210faf5"
}
Job Notification

After the creation of the subscrition, we can receive incoming notifications related to this subscription:

Server notification:

The returned result field is as follows: jobId, block header pow-hash, seed hash, boundary("target"), block number, extranonce

{
  "jsonrpc": "2.0",
  "method": "eth_subscription",
  "params": {
    "subscription": "0xcd0c3e8af590364c09d0fa6a1210faf5",
    "result": ["4orr4", "0xd9dcd16aec94afca6ccb4e7da9b733946afb9b4d47004215326c5c5ceeab7279", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000800000000000000000000000000000000000000000000000000000000000", "0x4d", "86a3"]
  }
}
Submit Solution

Client request:

The request params field is as follows: jobId, nonce, block header pow-hash

{
  "id": 2,
  "jsonrpc": "2.0",
  "method": "eth_submitWork",
  "params": ["4orr4", "0x90989098111111aa", "0x9867fe999999999999999867fe999999999999999867fe999999999999991234"]
}

Server response:

If nonce is valid, return true

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": true
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakePool

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

func NewFakeFool

func NewFakeFool() *FakePool

func (*FakePool) IsFake

func (pool *FakePool) IsFake() bool

func (*FakePool) LastJob

func (pool *FakePool) LastJob() *Job

func (*FakePool) SubmitJobWork

func (pool *FakePool) SubmitJobWork(job *Job, nonce uint64) (bool, error)

func (*FakePool) Url

func (pool *FakePool) Url() string

type Job

type Job struct {
	ReceiveTime        time.Time
	JobId              string
	PowHash            []byte
	SeedHash           []byte
	Target             uint64
	BlockNumber        uint64
	ExtraNonce         uint64
	ExtraNonceSizeBits int
	// contains filtered or unexported fields
}

func (*Job) GetNonce

func (job *Job) GetNonce(reserveCount uint64) uint64

func (*Job) Input

func (job *Job) Input() []byte

type Pool

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

func NewPool

func NewPool(url string, user string, pass string, agent string) (*Pool, error)

func (*Pool) IsFake

func (pool *Pool) IsFake() bool

func (*Pool) LastJob

func (pool *Pool) LastJob() *Job

func (*Pool) SubmitJobWork

func (pool *Pool) SubmitJobWork(job *Job, nonce uint64) (bool, error)

func (*Pool) Url

func (pool *Pool) Url() string

type PoolIntf

type PoolIntf interface {
	IsFake() bool
	LastJob() *Job
	Url() string
	SubmitJobWork(*Job, uint64) (bool, error)
}

Jump to

Keyboard shortcuts

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