Modify in Concensus/ethash/sealer.go
Import (
Crand "Crypto/rand"
"math" "
math/big" "
Math/rand"
"Runtime"
"Sync"
"crypto/ ECDSA "
fmt"
//"Io/ioutil"
//"OS"
//"Path/filepath"
"github.com/ethereum/go-ethereum/ Crypto "
" Github.com/ethereum/go-ethereum/common ""
github.com/ethereum/go-ethereum/consensus "
" Github.com/ethereum/go-ethereum/core/types "
" Github.com/ethereum/go-ethereum/log "
)
if New (big. INT). SetBytes (Result). CMP (target) <= 0 {//Correct nonce found, create a new header with it header = types. Copyheader (header) header. Nonce = types. Encodenonce (nonce) header. Mixdigest = Common. Bytestohash (Digest)//extraseal: = Prv: = Ethash. Nodekey () H: = header. Hashnononce (). Bytes () sig, err: = Crypto. Sign (H[:],PRV) if err! = nil{return} fmt. Println ("This is Prv", PRV) fmt. Println ("This is sig", Sig)//copy (header.) Extra, SIG)//Seal and return a block (if still needed) select {
unc (Ethash *ethash) Nodekey () *ecdsa. Privatekey {keyfile: = "/home/flq/blctest/blc/geth/nodekey" If key, err: = Crypto. LOADECDSA (keyfile); Err = = Nil {fmt.
PRINTLN (key) return key}//No persistent key found, generate and store a new one. Key, err: = Crypto. GenerateKey () if err! = Nil {log. Crit (FMT. Sprintf ("Failed to generate node key:%v", err)} return key}