dir : eth/backend.go
thread 수를 설정
type threaded interface {
SetThreads(threads int)
}
if th, ok := s.engine.(threaded); ok {
// ...
// disable miner
if threads == 0 {
threads = -1
}
th.SetThreads(threads)
}
miner가 구동 중이 아니라면 초기화한다.
if !s.IsMining() {
// txpool에 초기 가격을 전달
// ...
price = s.gasPrice
// ...
s.txPool.SetGasPrice(price)
// etherbase 확인
eb, err := s.Etherbase()
clique instance 로드
var cli *clique.Clique
if c, ok := s.engine.(*clique.Clique); ok {
cli = c
} else if cl ,ok := s.engine.(*beacon.Beacon)l ok {
// ...
}
// clique 인스턴스가 존재한다면 (chain이 clique를 차용하고 있다면)
if cli != nil {
// wallet 검색
wallet, err := s.accountManager.Find(...)
// ...
// clique 인스턴스에 etherbase 지갑 정보 추가
cli.Authorize(eb, wallet.SignData)
}
miner 인스턴스 구동
// 채널을 통해 miner에 신호를 보내 worker 인스턴스를 구동
// (newWorker 함수의 마지막 부분 참조)
go s.miner.Start(eb)
}
return nil