mirror of
https://github.com/kvazar-network/keva-stratum.git
synced 2025-01-26 23:04:42 +00:00
Tidy up struct exports
This commit is contained in:
parent
46137b5923
commit
f3d5c5c718
@ -85,7 +85,7 @@ func (s *StratumServer) collectMinersStats() (float64, float64, int, []interface
|
||||
stats["accepts"] = atomic.LoadUint64(&m.Val.accepts)
|
||||
stats["rejects"] = atomic.LoadUint64(&m.Val.rejects)
|
||||
if !s.config.Frontend.HideIP {
|
||||
stats["ip"] = m.Val.IP
|
||||
stats["ip"] = m.Val.ip
|
||||
}
|
||||
|
||||
if now-lastBeat > (int64(s.timeout/2) / 1000000) {
|
||||
|
@ -79,7 +79,7 @@ func (s *StratumServer) handleSubmitRPC(cs *Session, e *Endpoint, params *Submit
|
||||
|
||||
t := s.currentBlockTemplate()
|
||||
if job.height != t.Height {
|
||||
log.Printf("Stale share for height %d from %s@%s", job.height, miner.Id, miner.IP)
|
||||
log.Printf("Stale share for height %d from %s@%s", job.height, miner.id, miner.ip)
|
||||
atomic.AddUint64(&miner.staleShares, 1)
|
||||
return nil, &ErrorReply{Code: -1, Message: "Block expired"}
|
||||
}
|
||||
|
@ -25,11 +25,10 @@ type Job struct {
|
||||
|
||||
type Miner struct {
|
||||
sync.RWMutex
|
||||
Id string
|
||||
IP string
|
||||
LastBeat int64
|
||||
Endpoint *Endpoint
|
||||
|
||||
id string
|
||||
ip string
|
||||
lastBeat int64
|
||||
endpoint *Endpoint
|
||||
startedAt int64
|
||||
validShares uint64
|
||||
invalidShares uint64
|
||||
@ -52,7 +51,7 @@ func (job *Job) submit(nonce string) bool {
|
||||
|
||||
func NewMiner(id string, ip string) *Miner {
|
||||
shares := make(map[int64]int64)
|
||||
return &Miner{Id: id, IP: ip, shares: shares}
|
||||
return &Miner{id: id, ip: ip, shares: shares}
|
||||
}
|
||||
|
||||
func (cs *Session) getJob(t *BlockTemplate) *JobReplyData {
|
||||
@ -94,11 +93,11 @@ func (cs *Session) findJob(id string) *Job {
|
||||
|
||||
func (m *Miner) heartbeat() {
|
||||
now := util.MakeTimestamp()
|
||||
atomic.StoreInt64(&m.LastBeat, now)
|
||||
atomic.StoreInt64(&m.lastBeat, now)
|
||||
}
|
||||
|
||||
func (m *Miner) getLastBeat() int64 {
|
||||
return atomic.LoadInt64(&m.LastBeat)
|
||||
return atomic.LoadInt64(&m.lastBeat)
|
||||
}
|
||||
|
||||
func (m *Miner) storeShare(diff int64) {
|
||||
@ -154,7 +153,7 @@ func (m *Miner) processShare(s *StratumServer, e *Endpoint, job *Job, t *BlockTe
|
||||
}
|
||||
|
||||
if !s.config.BypassShareValidation && hex.EncodeToString(hashBytes) != result {
|
||||
log.Printf("Bad hash from miner %v@%v", m.Id, m.IP)
|
||||
log.Printf("Bad hash from miner %v@%v", m.id, m.ip)
|
||||
atomic.AddUint64(&m.invalidShares, 1)
|
||||
return false
|
||||
}
|
||||
@ -182,10 +181,10 @@ func (m *Miner) processShare(s *StratumServer, e *Endpoint, job *Job, t *BlockTe
|
||||
atomic.AddUint64(&m.accepts, 1)
|
||||
atomic.AddUint64(&r.Accepts, 1)
|
||||
atomic.StoreInt64(&r.LastSubmissionAt, util.MakeTimestamp())
|
||||
log.Printf("Block %v found at height %v by miner %v@%v", blockFastHash[0:6], t.Height, m.Id, m.IP)
|
||||
log.Printf("Block %v found at height %v by miner %v@%v", blockFastHash[0:6], t.Height, m.id, m.ip)
|
||||
}
|
||||
} else if hashDiff < job.difficulty {
|
||||
log.Printf("Rejected low difficulty share of %v from %v@%v", hashDiff, m.Id, m.IP)
|
||||
log.Printf("Rejected low difficulty share of %v from %v@%v", hashDiff, m.id, m.ip)
|
||||
atomic.AddUint64(&m.invalidShares, 1)
|
||||
return false
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ func (s *StratumServer) isActive(cs *Session) bool {
|
||||
}
|
||||
|
||||
func (s *StratumServer) registerMiner(miner *Miner) {
|
||||
s.miners.Set(miner.Id, miner)
|
||||
s.miners.Set(miner.id, miner)
|
||||
}
|
||||
|
||||
func (s *StratumServer) removeMiner(id string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user