feat(core): implement core MEV bot functionality with market scanning and Uniswap V3 pricing
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
55
vendor/github.com/ethereum/go-ethereum/metrics/counter.go
generated
vendored
Normal file
55
vendor/github.com/ethereum/go-ethereum/metrics/counter.go
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// GetOrRegisterCounter returns an existing Counter or constructs and registers
|
||||
// a new Counter.
|
||||
func GetOrRegisterCounter(name string, r Registry) *Counter {
|
||||
return getOrRegister(name, NewCounter, r)
|
||||
}
|
||||
|
||||
// NewCounter constructs a new Counter.
|
||||
func NewCounter() *Counter {
|
||||
return new(Counter)
|
||||
}
|
||||
|
||||
// NewRegisteredCounter constructs and registers a new Counter.
|
||||
func NewRegisteredCounter(name string, r Registry) *Counter {
|
||||
c := NewCounter()
|
||||
if r == nil {
|
||||
r = DefaultRegistry
|
||||
}
|
||||
r.Register(name, c)
|
||||
return c
|
||||
}
|
||||
|
||||
// CounterSnapshot is a read-only copy of a Counter.
|
||||
type CounterSnapshot int64
|
||||
|
||||
// Count returns the count at the time the snapshot was taken.
|
||||
func (c CounterSnapshot) Count() int64 { return int64(c) }
|
||||
|
||||
// Counter hold an int64 value that can be incremented and decremented.
|
||||
type Counter atomic.Int64
|
||||
|
||||
// Clear sets the counter to zero.
|
||||
func (c *Counter) Clear() {
|
||||
(*atomic.Int64)(c).Store(0)
|
||||
}
|
||||
|
||||
// Dec decrements the counter by the given amount.
|
||||
func (c *Counter) Dec(i int64) {
|
||||
(*atomic.Int64)(c).Add(-i)
|
||||
}
|
||||
|
||||
// Inc increments the counter by the given amount.
|
||||
func (c *Counter) Inc(i int64) {
|
||||
(*atomic.Int64)(c).Add(i)
|
||||
}
|
||||
|
||||
// Snapshot returns a read-only copy of the counter.
|
||||
func (c *Counter) Snapshot() CounterSnapshot {
|
||||
return CounterSnapshot((*atomic.Int64)(c).Load())
|
||||
}
|
||||
Reference in New Issue
Block a user