/
sha256blockAvx_amd64.go
69 lines (50 loc) · 1.48 KB
/
sha256blockAvx_amd64.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
// +build !noasm
package main
import (
"time"
)
//go:noescape
func blockAvx(h []uint32, message []uint8, reserved0, reserved1, reserved2, reserved3 uint64)
func mineAVX(proc int) {
instanceID := generateInstanceID()
var full = make([]byte, 64)
copy(full[:fullHeaderSize], []byte(address+lastBlock+instanceID))
if len(address+lastBlock+instanceID) != fullHeaderSize {
panic("miner: incorrect header size. report this to 1lann.")
}
threadBlock := lastBlock
na := full[fullHeaderSize : fullHeaderSize+11]
na[0], na[1], na[2], na[3], na[4], na[5], na[6], na[7], na[8], na[9], na[10] =
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'
if full[41] != 0 || full[40] == 0 {
panic("overwrite! report this to 1lann.")
}
full[41] = 128
full[62] = 1
full[63] = 72
h := []uint32{0, 0, 0, 0, 0, 0, 0, 0}
for {
start := time.Now()
for i := 0; i < 5000000; i++ {
incrementNonce(na)
h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7] =
init0, init1, init2, init3, init4, init5, init6, init7
blockAvx(h, full, 0, 0, 0, 0)
if h[0] > 1 {
continue
}
if (h[0]<<16)|(h[1]>>16) > maxWork {
continue
}
submitResult(lastBlock, string(full[22:41]))
}
workerSpeeds[proc] = time.Since(start)
if threadBlock != lastBlock {
threadBlock = lastBlock
copy(full[:fullHeaderSize], []byte(address+lastBlock+instanceID))
if len(address+lastBlock+instanceID) != fullHeaderSize {
panic("miner: incorrect header size. report this to 1lann.")
}
}
}
}