Skip to content

Commit bc83d78

Browse files
committed
Add Stratum specification
1 parent 04eb24b commit bc83d78

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

spec/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ CodeChain is a programmable blockchain supporting multiple asset types. You can
2222
* [Merkle Trie](Merkle-Trie.md)
2323
* [Digital Signature](Digital-Signature.md)
2424
* [JSON RPC](JSON-RPC.md)
25+
* [Stratum](Stratum.md)
2526

spec/Stratum.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Stratum is a light-weight mining protocol.
2+
3+
# List of methods
4+
5+
* [mining.subscribe](#mining.subscribe)
6+
* [mining.authorize](#mining.authorize)
7+
* [mining.notify](#mining.notify)
8+
* [mining.submit](#mining.submit)
9+
10+
# Specification
11+
12+
## mining.subscribe
13+
14+
Used for subscribing mining jobs.
15+
16+
Params: No parameters
17+
18+
Return Type: No parameters
19+
20+
Request Example
21+
```
22+
{
23+
"jsonrpc": "2.0",
24+
"id": 1,
25+
"method": "mining.subscribe",
26+
"params": []
27+
}
28+
```
29+
30+
Response Example
31+
```
32+
{
33+
"jsonrpc": "2.0",
34+
"id": 1,
35+
"result": [],
36+
"error": null
37+
}
38+
```
39+
40+
## mining.authorize
41+
42+
Used for authorizing miner.
43+
44+
Params:
45+
1. name: `string`
46+
2. password: `string`
47+
48+
Return Type: `bool`
49+
50+
Request Example
51+
```
52+
{
53+
"jsonrpc": "2.0",
54+
"id":2,
55+
"method": "mining.authorize",
56+
"params": ["miner1", "password"]
57+
}
58+
```
59+
60+
Response Example
61+
```
62+
{
63+
"jsonrpc": "2.0",
64+
"id": 2,
65+
"result": true,
66+
"error": null
67+
}
68+
```
69+
70+
## mining.notify
71+
72+
Used for sending notifications with mining jobs
73+
74+
Params: `WorkObject`
75+
76+
Notification Example
77+
```
78+
{
79+
"jsonrpc": "2.0",
80+
"id": 3,
81+
"method": "mining.notify",
82+
"params": {
83+
"0x56642f04d519ae3262c7ba6facf1c5b11450ebaeb7955337cfbc45420d573077",
84+
"100"
85+
},
86+
}
87+
```
88+
89+
## mining.submit
90+
91+
Used for submitting a proof-of-work solution.
92+
93+
Params:
94+
1. powHash: `string`
95+
2. seal: `string[]`
96+
97+
Return Type: `bool`
98+
99+
Request Example
100+
```
101+
{
102+
"jsonrpc": "2.0",
103+
"id": 4,
104+
"method": "mining.submit",
105+
"params": ["0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", ["0x56642f04d519ae3262c7ba6facf1c5b11450ebaeb7955337cfbc45420d573077"]],
106+
}
107+
```
108+
109+
Response Example
110+
```
111+
{
112+
"jsonrpc": "2.0",
113+
"id": 4,
114+
"result": true,
115+
"error": null
116+
}
117+
```
118+
119+
## Exception Handling (DRAFT)
120+
Stratum defines simple exception handling. Example of rejected share looks like:
121+
```
122+
{
123+
"jsonrpc": "2.0",
124+
"id": 5,
125+
"result": null,
126+
"error": (21, "Job not found", null)
127+
}
128+
```
129+
130+
Where the error field is defined as (error_code, human_readable_message, traceback). Traceback may contain additional information for debugging errors.
131+
Proposed error codes for mining service are:
132+
* 20 - Other/Unknown
133+
* 21 - Job not found (=stale)
134+
* 22 - Duplicate share
135+
* 23 - Low target share
136+
* 24 - Unauthorized worker
137+
* 25 - Not subscribed

0 commit comments

Comments
 (0)