fix(proxy): classify low difficulty rejects
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
264479d57b
commit
fefae4b3e5
3 changed files with 31 additions and 3 deletions
|
|
@ -109,5 +109,14 @@ func (b *CustomDiffBuckets) bucketLocked(diff uint64) *CustomDiffBucketStats {
|
||||||
|
|
||||||
func isInvalidShareReason(reason string) bool {
|
func isInvalidShareReason(reason string) bool {
|
||||||
reason = strings.ToLower(reason)
|
reason = strings.ToLower(reason)
|
||||||
return strings.Contains(reason, "difficulty") || strings.Contains(reason, "invalid") || strings.Contains(reason, "nonce")
|
if reason == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return strings.Contains(reason, "low diff") ||
|
||||||
|
strings.Contains(reason, "lowdifficulty") ||
|
||||||
|
strings.Contains(reason, "low difficulty") ||
|
||||||
|
strings.Contains(reason, "malformed") ||
|
||||||
|
strings.Contains(reason, "difficulty") ||
|
||||||
|
strings.Contains(reason, "invalid") ||
|
||||||
|
strings.Contains(reason, "nonce")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,15 @@ func TestProxy_CustomDiffStats_Bad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
miner := &Miner{customDiff: 10000}
|
miner := &Miner{customDiff: 10000}
|
||||||
p.events.Dispatch(Event{Type: EventReject, Miner: miner, Error: "Invalid nonce"})
|
p.events.Dispatch(Event{Type: EventReject, Miner: miner, Error: "Low difficulty share"})
|
||||||
|
p.events.Dispatch(Event{Type: EventReject, Miner: miner, Error: "Malformed share"})
|
||||||
|
|
||||||
summary := p.Summary()
|
summary := p.Summary()
|
||||||
bucket, ok := summary.CustomDiffStats[10000]
|
bucket, ok := summary.CustomDiffStats[10000]
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expected custom diff bucket 10000 to be present")
|
t.Fatalf("expected custom diff bucket 10000 to be present")
|
||||||
}
|
}
|
||||||
if bucket.Rejected != 1 || bucket.Invalid != 1 {
|
if bucket.Rejected != 2 || bucket.Invalid != 2 {
|
||||||
t.Fatalf("unexpected bucket totals: %+v", bucket)
|
t.Fatalf("unexpected bucket totals: %+v", bucket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
stats_test.go
Normal file
18
stats_test.go
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
package proxy
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestProxy_Stats_InvalidRejectReasons_Good(t *testing.T) {
|
||||||
|
stats := NewStats()
|
||||||
|
|
||||||
|
stats.OnReject(Event{Error: "Low difficulty share"})
|
||||||
|
stats.OnReject(Event{Error: "Malformed share"})
|
||||||
|
|
||||||
|
summary := stats.Summary()
|
||||||
|
if summary.Rejected != 2 {
|
||||||
|
t.Fatalf("expected two rejected shares, got %d", summary.Rejected)
|
||||||
|
}
|
||||||
|
if summary.Invalid != 2 {
|
||||||
|
t.Fatalf("expected two invalid shares, got %d", summary.Invalid)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue