-
Notifications
You must be signed in to change notification settings - Fork 10
/
handler.go
645 lines (590 loc) · 19.1 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
package pool
import (
"bufio"
"bytes"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
"math/big"
// "math/big"
"net"
"strconv"
"strings"
"time"
"github.com/HyperspaceApp/Hyperspace/encoding"
"github.com/HyperspaceApp/Hyperspace/modules"
"github.com/HyperspaceApp/Hyperspace/persist"
"github.com/HyperspaceApp/Hyperspace/types"
"github.com/sasha-s/go-deadlock"
)
const (
extraNonce2Size = 4
)
// Handler represents the status (open/closed) of each connection
type Handler struct {
mu deadlock.RWMutex
conn net.Conn
closed chan bool
notify chan bool
p *Pool
log *persist.Logger
s *Session
}
const (
blockTimeout = 5 * time.Second
// This should represent the max number of pending notifications (new blocks found) within blockTimeout seconds
// better to have too many, than not enough (causes a deadlock otherwise)
numPendingNotifies = 20
)
func (h *Handler) parseRequest() (*types.StratumRequest, error) {
var m types.StratumRequest
// fmt.Printf("%s: Setting timeout for %v\n", h.s.printID(), time.Now().Add(blockTimeout))
h.conn.SetReadDeadline(time.Now().Add(blockTimeout))
//dec := json.NewDecoder(h.conn)
buf := bufio.NewReader(h.conn)
select {
case <-h.p.tg.StopChan():
return nil, errors.New("Stopping handler")
case <-h.notify:
m.Method = "mining.notify"
default:
// try reading from the connection
//err = dec.Decode(&m)
str, err := buf.ReadString('\n')
// if we timeout
if nerr, ok := err.(net.Error); ok && nerr.Timeout() {
// h.log.Printf("%s: Harmless timeout occurred\n", h.s.printID())
//h.conn.SetReadDeadline(time.Time{})
// check last job time and if over 25 seconds, send a new job.
// if time.Now().Sub(h.s.lastJobTimestamp) > (time.Second * 25) {
// m.Method = "mining.notify"
// break
// }
if h.s.DetectDisconnected() {
h.log.Println("Non-responsive disconnect detected!")
return nil, errors.New("Non-responsive disconnect detected")
}
// ratio := h.s.CurrentDifficulty() / h.s.HighestDifficulty()
// h.log.Printf("Non-responsive disconnect ratio: %f\n", ratio)
if h.s.checkDiffOnNewShare() {
err = h.sendSetDifficulty(h.s.CurrentDifficulty())
if err != nil {
h.log.Println("Error sending SetDifficulty")
return nil, err
}
err = h.sendStratumNotify(true)
if err != nil {
h.log.Println("Error sending stratum notify")
return nil, err
}
}
return nil, nil
// if we don't timeout but have some other error
} else if err != nil {
if err == io.EOF {
//fmt.Println("End connection")
h.log.Println("End connection")
} else {
h.log.Println("Unusual error")
h.log.Println(err)
}
return nil, err
} else {
// NOTE: we were getting weird cases where the buffer would read a full
// string, then read part of the string again (like the last few chars).
// Somehow it seemed like the socket data wasn't getting purged correctly
// on reading.
// Not seeing it lately, but that's why we have this debugging code,
// and that's why we don't just read straight into the JSON decoder.
// Reading the data into a string buffer lets us debug more easily.
// If we encounter this issue again, we may want to drop down into
// lower-level socket manipulation to try to troubleshoot it.
// h.log.Println(str)
dec := json.NewDecoder(strings.NewReader(str))
err = dec.Decode(&m)
if err != nil {
h.log.Println("Decoding error")
h.log.Println(err)
h.log.Println(str)
//return nil, err
// don't disconnect here, just treat it like a harmless timeout
return nil, nil
}
}
}
// h.log.Printf("%s: Clearing timeout\n", h.s.printID())
return &m, nil
}
func (h *Handler) handleRequest(m *types.StratumRequest) error {
h.s.SetHeartbeat()
var err error
switch m.Method {
case "mining.subscribe":
return h.handleStratumSubscribe(m)
case "mining.authorize":
err = h.handleStratumAuthorize(m)
if err != nil {
h.log.Printf("Failed to authorize client\n")
h.log.Println(err)
return err
}
return h.sendStratumNotify(true)
case "mining.extranonce.subscribe":
return h.handleStratumNonceSubscribe(m)
case "mining.submit":
return h.handleStratumSubmit(m)
case "mining.notify":
// h.log.Printf("mining.notify:New block to mine on\n")
return h.sendStratumNotify(true)
default:
h.log.Debugln("Unknown stratum method: ", m.Method)
}
return nil
}
// Listen listens on a connection for incoming data and acts on it
func (h *Handler) Listen() {
defer func() {
h.closed <- true // send to dispatcher, that connection is closed
h.conn.Close()
if h.s != nil && h.s.CurrentWorker != nil {
// delete a worker record when a session disconnections
h.s.CurrentWorker.deleteWorkerRecord()
// when we shut down the pool we get an error here because the log
// is already closed... TODO
h.s.log.Printf("Closed worker: %d\n", h.s.CurrentWorker.wr.workerID)
}
}()
err := h.p.tg.Add()
if err != nil {
// If this goroutine is not run before shutdown starts, this
// codeblock is reachable.
return
}
defer h.p.tg.Done()
h.log.Println("New connection from " + h.conn.RemoteAddr().String())
h.mu.Lock()
h.s, _ = newSession(h.p, h.conn.RemoteAddr().String())
h.mu.Unlock()
h.log.Println("New session: " + sPrintID(h.s.SessionID))
for {
m, err := h.parseRequest()
h.conn.SetReadDeadline(time.Time{})
// if we timed out
if m == nil && err == nil {
continue
// else if we got a request
} else if m != nil {
err = h.handleRequest(m)
if err != nil {
h.log.Println(err)
return
}
// else if we got an error
} else if err != nil {
h.log.Println(err)
return
}
}
}
func (h *Handler) sendResponse(r types.StratumResponse) error {
b, err := json.Marshal(r)
//fmt.Printf("SERVER: %s\n", b)
if err != nil {
h.log.Debugln("json marshal failed for id: ", r.ID, err)
return err
}
b = append(b, '\n')
_, err = h.conn.Write(b)
if err != nil {
h.log.Debugln("connection write failed for id: ", r.ID, err)
return err
}
return nil
}
func (h *Handler) sendRequest(r types.StratumRequest) error {
b, err := json.Marshal(r)
if err != nil {
h.log.Debugln("json marshal failed for id: ", r.ID, err)
return err
}
b = append(b, '\n')
_, err = h.conn.Write(b)
h.log.Debugln("sending request: ", string(b))
if err != nil {
h.log.Debugln("connection write failed for id: ", r.ID, err)
return err
}
return nil
}
// handleStratumSubscribe message is the first message received and allows the pool to tell the miner
// the difficulty as well as notify, extranonce1 and extranonce2
//
// TODO: Pull the appropriate data from either in memory or persistent store as required
func (h *Handler) handleStratumSubscribe(m *types.StratumRequest) error {
if len(m.Params) > 0 {
clientVersion := m.Params[0].(string)
h.log.Printf("Client subscribe name:%s", clientVersion)
h.s.SetClientVersion(clientVersion)
var diff float64
switch clientVersion {
case "sgminer/4.4.2":
diff = 11500
case "cgminer/4.9.0":
diff = 1024
case "cgminer/4.10.0":
diff = 700
case "gominer":
diff = 0.03
case "NiceHash/1.0.0":
diff = 1024 * 10000 // block nice hash by setup a very high diff
}
if diffString, exists := h.p.InternalSettings().Difficulty[clientVersion]; exists {
var err error
diff, err = strconv.ParseFloat(diffString, 64)
if err != nil {
r := types.StratumResponse{ID: m.ID}
r.Result = false
r.Error = interfaceify([]string{"parse version diff error"})
return err
}
}
if diff != 0 {
h.s.SetHighestDifficulty(diff)
h.s.SetCurrentDifficulty(diff)
h.s.SetDisableVarDiff(true)
}
}
r := types.StratumResponse{ID: m.ID}
r.Method = m.Method
/*
if !h.s.Authorized() {
r.Result = false
r.Error = interfaceify([]string{"Session not authorized - authorize before subscribe"})
return h.sendResponse(r)
}
*/
// diff := "b4b6693b72a50c7116db18d6497cac52"
t, _ := h.p.persist.Target.Difficulty().Uint64()
h.log.Debugf("Block Difficulty: %x\n", t)
tb := make([]byte, 8)
binary.LittleEndian.PutUint64(tb, t)
diff := hex.EncodeToString(tb)
//notify := "ae6812eb4cd7735a302a8a9dd95cf71f"
notify := h.s.printID()
extranonce1 := h.s.printNonce()
extranonce2 := extraNonce2Size
raw := fmt.Sprintf(`[ [ ["mining.set_difficulty", "%s"], ["mining.notify", "%s"]], "%s", %d]`, diff, notify, extranonce1, extranonce2)
r.Result = json.RawMessage(raw)
r.Error = nil
return h.sendResponse(r)
}
// this is thread-safe, when we're looking for and possibly creating a client,
// we need to make sure the action is atomic
func (h *Handler) setupClient(client, worker string) (*Client, error) {
var err error
h.p.mu.Lock()
lock, exists := h.p.clientSetupMutex[client]
if !exists {
lock = &deadlock.Mutex{}
h.p.clientSetupMutex[client] = lock
}
h.p.mu.Unlock()
// start := time.Now()
// log.Println("lock: ", client, " ", worker)
lock.Lock()
defer func() {
lock.Unlock()
// log.Printf("unlock: %s %s %f", client, worker, time.Now().Sub(start).Seconds())
}()
c, err := h.p.FindClientDB(client)
if err == ErrNoUsernameInDatabase {
c, err = newClient(h.p, client)
if err != nil {
//fmt.Println("Failed to create a new Client")
h.p.log.Printf("Failed to create a new Client: %s\n", err)
return nil, err
}
err = h.p.AddClientDB(c)
if err != nil {
h.p.log.Printf("Failed to add client to DB: %s\n", err)
return nil, err
}
} else {
if err != nil {
h.p.log.Printf("Failed to get client from DB: %s\n", err)
return nil, err
}
}
if h.p.Client(client) == nil {
h.p.log.Printf("Adding client in memory: %s\n", client)
h.p.AddClient(c)
}
return c, nil
}
func (h *Handler) setupWorker(c *Client, workerName string) (*Worker, error) {
w, err := newWorker(c, workerName, h.s)
if err != nil {
c.log.Printf("Failed to add worker: %s\n", err)
return nil, err
}
err = c.addWorkerDB(w)
if err != nil {
c.log.Printf("Failed to add worker: %s\n", err)
return nil, err
}
h.s.log = w.log
c.log.Printf("Adding new worker: %s, %d\n", workerName, w.wr.workerID)
w.log.Printf("Adding new worker: %s, %d\n", workerName, w.wr.workerID)
h.log.Debugln("client = " + c.Name() + ", worker = " + workerName)
return w, nil
}
// handleStratumAuthorize allows the pool to tie the miner connection to a particular user
func (h *Handler) handleStratumAuthorize(m *types.StratumRequest) error {
var err error
r := types.StratumResponse{ID: m.ID}
r.Method = "mining.authorize"
r.Result = true
r.Error = nil
clientName := m.Params[0].(string)
workerName := ""
if strings.Contains(clientName, ".") {
s := strings.SplitN(clientName, ".", -1)
clientName = s[0]
workerName = s[1]
}
// load wallet and check validity
var walletTester types.UnlockHash
err = walletTester.LoadString(clientName)
if err != nil {
r.Result = false
r.Error = interfaceify([]string{"Client Name must be valid wallet address"})
h.log.Println("Client Name must be valid wallet address. Client name is: " + clientName)
err = errors.New("Client name must be a valid wallet address")
h.sendResponse(r)
return err
}
c, err := h.setupClient(clientName, workerName)
if err != nil {
r.Result = false
r.Error = interfaceify([]string{err.Error()})
h.sendResponse(r)
return err
}
w, err := h.setupWorker(c, workerName)
if err != nil {
r.Result = false
r.Error = interfaceify([]string{err.Error()})
h.sendResponse(r)
return err
}
// if everything is fine, setup the client and send a response and difficulty
h.s.addClient(c)
h.s.addWorker(w)
h.s.addShift(h.p.newShift(h.s.CurrentWorker))
h.s.SetAuthorized(true)
err = h.sendResponse(r)
if err != nil {
return err
}
err = h.sendSetDifficulty(h.s.CurrentDifficulty())
if err != nil {
return err
}
return nil
}
// handleStratumNonceSubscribe tells the pool that this client can handle the extranonce info
// TODO: Not sure we have to anything if all our clients support this.
func (h *Handler) handleStratumNonceSubscribe(m *types.StratumRequest) error {
h.p.log.Debugln("ID = "+strconv.FormatUint(m.ID, 10)+", Method = "+m.Method+", params = ", m.Params)
// not sure why 3 is right, but ccminer expects it to be 3
r := types.StratumResponse{ID: 3}
r.Result = true
r.Error = nil
return h.sendResponse(r)
}
// request is sent as [name, jobid, extranonce2, nTime, nonce]
func (h *Handler) handleStratumSubmit(m *types.StratumRequest) error {
// fmt.Printf("%s: %s Handle submit\n", time.Now(), h.s.printID())
r := types.StratumResponse{ID: m.ID}
r.Method = "mining.submit"
r.Result = true
r.Error = nil
/*
err := json.Unmarshal(m.Params, &p)
if err != nil {
h.log.Printf("Unable to parse mining.submit params: %v\n", err)
r.Result = false //json.RawMessage(`false`)
r.Error = interfaceify([]string{"20","Parse Error"}) //json.RawMessage(`["20","Parse Error"]`)
}
*/
// name := m.Params[0].(string)
var jobID uint64
fmt.Sscanf(m.Params[1].(string), "%x", &jobID)
extraNonce2 := m.Params[2].(string)
nTime := m.Params[3].(string)
nonce := m.Params[4].(string)
// h.s.log.Printf("Submit jobid:%d nonce: %s, extraNonce2: %s", jobID, nonce, extraNonce2)
needNewJob := false
defer func() {
if needNewJob == true {
h.sendStratumNotify(true)
}
}()
if h.s.CurrentWorker == nil {
// worker failed to authorize
h.log.Printf("Worker failed to authorize - dropping\n")
return errors.New("Worker failed to authorize - dropping")
}
h.s.SetLastShareTimestamp(time.Now())
sessionPoolDifficulty := h.s.CurrentDifficulty()
if h.s.checkDiffOnNewShare() {
h.sendSetDifficulty(h.s.CurrentDifficulty())
needNewJob = true
}
// h.log.Debugln("name = " + name + ", jobID = " + fmt.Sprintf("%X", jobID) + ", extraNonce2 = " + extraNonce2 + ", nTime = " + nTime + ", nonce = " + nonce)
if h.s.log != nil {
// h.s.log.Debugln("name = " + name + ", jobID = " + fmt.Sprintf("%X", jobID) + ", extraNonce2 = " + extraNonce2 + ", nTime = " + nTime + ", nonce = " + nonce)
} else {
h.log.Debugln("session log not ready")
}
var b types.Block
j, err := h.s.getJob(jobID, nonce)
if err != nil {
r.Result = false
r.Error = interfaceify([]string{"23", err.Error()})
h.s.CurrentWorker.IncrementInvalidShares()
return h.sendResponse(r)
}
if j != nil {
encoding.Unmarshal(j.MarshalledBlock, &b)
}
if len(b.MinerPayouts) == 0 {
r.Result = false
r.Error = interfaceify([]string{"22", "Stale - old/unknown job"})
h.s.CurrentWorker.log.Printf("Stale Share rejected - old/unknown job\n")
h.s.CurrentWorker.IncrementInvalidShares()
return h.sendResponse(r)
}
bhNonce, err := hex.DecodeString(nonce)
if len(b.Nonce) != len(bhNonce) {
r.Result = false
r.Error = interfaceify([]string{"24", "wrong nonce length"})
h.s.CurrentWorker.log.Printf("Nonce length rejected\n")
h.s.CurrentWorker.IncrementInvalidShares()
return h.sendResponse(r)
}
for i := range b.Nonce { // there has to be a better way to do this in golang
b.Nonce[i] = bhNonce[i]
}
tb, _ := hex.DecodeString(nTime)
b.Timestamp = types.Timestamp(encoding.DecUint64(tb))
cointxn := h.p.coinB1()
ex1, _ := hex.DecodeString(h.s.printNonce())
ex2, _ := hex.DecodeString(extraNonce2)
cointxn.ArbitraryData[0] = append(cointxn.ArbitraryData[0], ex1...)
cointxn.ArbitraryData[0] = append(cointxn.ArbitraryData[0], ex2...)
b.Transactions = append(b.Transactions, []types.Transaction{cointxn}...)
blockHash := b.ID()
bh := new(big.Int).SetBytes(blockHash[:])
sessionPoolTarget, _ := difficultyToTarget(sessionPoolDifficulty)
// h.s.CurrentWorker.log.Printf("session diff: %f, block version diff: %s",
// sessionPoolDifficulty, printWithSuffix(sessionPoolTarget.Difficulty()))
// need to verify that the submission reaches the pool target
if bytes.Compare(sessionPoolTarget[:], blockHash[:]) < 0 {
r.Result = false
r.Error = interfaceify([]string{"22", "Submitted nonce did not reach pool diff target"}) //json.RawMessage(`["21","Stale - old/unknown job"]`)
h.s.CurrentWorker.log.Printf("Submitted nonce did not reach pool diff target\n")
h.s.CurrentWorker.log.Printf("Submitted id: %064x\n", bh)
h.s.CurrentWorker.log.Printf("Session target: %064x\n", sessionPoolTarget.Int())
h.s.CurrentWorker.IncrementInvalidShares()
return h.sendResponse(r)
}
t := h.p.persist.GetTarget()
// h.s.CurrentWorker.log.Printf("Submit block hash is %064x\n", bh)
// h.s.CurrentWorker.log.Printf("Chain block target is %064x\n", t.Int())
// h.s.CurrentWorker.log.Printf("Difficulty %s/%s\n",
// printWithSuffix(types.IntToTarget(bh).Difficulty()), printWithSuffix(t.Difficulty()))
if bytes.Compare(t[:], blockHash[:]) < 0 {
// h.s.CurrentWorker.log.Printf("Block hash is greater than block target\n")
// h.s.CurrentWorker.log.Printf("Share Accepted\n")
h.s.CurrentWorker.IncrementShares(h.s.CurrentDifficulty(), currencyToAmount(b.MinerPayouts[0].Value))
h.s.CurrentWorker.SetLastShareTime(time.Now())
return h.sendResponse(r)
}
err = h.p.managedSubmitBlock(b)
if err != nil && err != modules.ErrBlockUnsolved {
h.log.Printf("Failed to SubmitBlock(): %v\n", err)
h.log.Printf(sPrintBlock(b))
panic(fmt.Sprintf("Failed to SubmitBlock(): %v\n", err))
/*
r.Result = false //json.RawMessage(`false`)
r.Error = interfaceify([]string{"20", "Stale share"})
h.s.CurrentWorker.IncrementInvalidShares()
return h.sendResponse(r)
*/
}
h.s.CurrentWorker.log.Printf("Share Accepted\n")
h.s.CurrentWorker.IncrementShares(h.s.CurrentDifficulty(), currencyToAmount(b.MinerPayouts[0].Value))
h.s.CurrentWorker.SetLastShareTime(time.Now())
// TODO: why not err == nil ?
if err != modules.ErrBlockUnsolved {
h.s.CurrentWorker.Parent().log.Printf("Yay!!! Solved a block!!\n")
// h.s.CurrentWorker.log.Printf("Yay!!! Solved a block!!\n")
h.s.clearJobs()
err = h.s.CurrentWorker.addFoundBlock(&b)
if err != nil {
h.s.CurrentWorker.log.Printf("Failed to update block in database: %s\n", err)
}
h.p.shiftChan <- true
}
return h.sendResponse(r)
}
func (h *Handler) sendSetDifficulty(d float64) error {
var r types.StratumRequest
r.Method = "mining.set_difficulty"
// assuming this ID is the response to the original subscribe which appears to be a 1
r.ID = 0
params := make([]interface{}, 1)
r.Params = params
r.Params[0] = d
return h.sendRequest(r)
}
func (h *Handler) sendStratumNotify(cleanJobs bool) error {
var r types.StratumRequest
r.Method = "mining.notify"
r.ID = 0 // gominer requires notify to use an id of 0
job, _ := newJob(h.p)
h.s.addJob(job)
jobid := job.printID()
var b types.Block
h.p.persist.mu.Lock()
// make a copy of the block and hold it until the solution is submitted
job.MarshalledBlock = encoding.Marshal(&h.p.sourceBlock)
h.p.persist.mu.Unlock()
encoding.Unmarshal(job.MarshalledBlock, &b)
job.MerkleRoot = b.MerkleRoot()
mbj := b.MerkleBranches()
h.log.Debugf("merkleBranch: %s\n", mbj)
version := ""
nbits := fmt.Sprintf("%08x", BigToCompact(h.p.persist.Target.Int()))
var buf bytes.Buffer
encoding.WriteUint64(&buf, uint64(b.Timestamp))
ntime := hex.EncodeToString(buf.Bytes())
params := make([]interface{}, 9)
r.Params = params
r.Params[0] = jobid
r.Params[1] = b.ParentID.String()
r.Params[2] = h.p.coinB1Txn()
r.Params[3] = h.p.coinB2()
r.Params[4] = mbj
r.Params[5] = version
r.Params[6] = nbits
r.Params[7] = ntime
r.Params[8] = cleanJobs
//h.log.Debugf("send.notify: %s\n", raw)
h.log.Debugf("send.notify: %s\n", r.Params)
return h.sendRequest(r)
}