Documentation ¶
Index ¶
- Variables
- func CleanWallet(in string) (string, error)
- func DefaultLogger() *zap.Logger
- func HandleAuthorize(ctx *StratumContext, event JsonRpcEvent) error
- func HandleSubmit(ctx *StratumContext, event JsonRpcEvent) error
- func HandleSubscribe(ctx *StratumContext, event JsonRpcEvent) error
- func NewMockContext(ctx context.Context, logger *zap.Logger, state any) (*StratumContext, *MockConnection)
- func SendExtranonce(ctx *StratumContext)
- type ContextSummary
- type DisconnectChannel
- type EventHandler
- type JsonRpcEvent
- type JsonRpcResponse
- type LineCallback
- type MockAddr
- type MockConnection
- func (mc *MockConnection) AsyncReadTestDataFromBuffer(handler func([]byte))
- func (mc *MockConnection) AsyncWriteTestDataToReadBuffer(s string)
- func (mc *MockConnection) Close() error
- func (mc *MockConnection) LocalAddr() net.Addr
- func (mc *MockConnection) Read(b []byte) (int, error)
- func (mc *MockConnection) ReadTestDataFromBuffer(handler func([]byte))
- func (mc *MockConnection) RemoteAddr() net.Addr
- func (mc *MockConnection) SetDeadline(t time.Time) error
- func (mc *MockConnection) SetReadDeadline(t time.Time) error
- func (mc *MockConnection) SetWriteDeadline(t time.Time) error
- func (mc *MockConnection) Write(b []byte) (int, error)
- type StateGenerator
- type StratumClientListener
- type StratumContext
- func (sc *StratumContext) Connected() bool
- func (StratumContext) Deadline() (time.Time, bool)
- func (sc *StratumContext) Disconnect()
- func (StratumContext) Done() <-chan struct{}
- func (StratumContext) Err() error
- func (sc *StratumContext) Reply(response JsonRpcResponse) error
- func (sc *StratumContext) ReplyBadShare(id any) error
- func (sc *StratumContext) ReplyDupeShare(id any) error
- func (sc *StratumContext) ReplyLowDiffShare(id any) error
- func (sc *StratumContext) ReplyStaleShare(id any) error
- func (sc *StratumContext) Send(event JsonRpcEvent) error
- func (sc *StratumContext) String() string
- func (sc *StratumContext) Summary() ContextSummary
- func (d StratumContext) Value(key any) any
- type StratumHandlerMap
- type StratumListener
- type StratumListenerConfig
- type StratumMethod
- type StratumStats
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorDisconnected = fmt.Errorf("disconnecting")
Functions ¶
func CleanWallet ¶
func DefaultLogger ¶
func HandleAuthorize ¶
func HandleAuthorize(ctx *StratumContext, event JsonRpcEvent) error
func HandleSubmit ¶
func HandleSubmit(ctx *StratumContext, event JsonRpcEvent) error
func HandleSubscribe ¶
func HandleSubscribe(ctx *StratumContext, event JsonRpcEvent) error
func NewMockContext ¶
func NewMockContext(ctx context.Context, logger *zap.Logger, state any) (*StratumContext, *MockConnection)
func SendExtranonce ¶
func SendExtranonce(ctx *StratumContext)
Types ¶
type ContextSummary ¶
type DisconnectChannel ¶
type DisconnectChannel chan *StratumContext
type EventHandler ¶
type EventHandler func(ctx *StratumContext, event JsonRpcEvent) error
type JsonRpcEvent ¶
type JsonRpcEvent struct { Id any `json:"id"` // id can be nil, a string, or an int 🙄 Version string `json:"jsonrpc"` Method StratumMethod `json:"method"` Params []any `json:"params"` }
func UnmarshalEvent ¶
func UnmarshalEvent(in string) (JsonRpcEvent, error)
type JsonRpcResponse ¶
type JsonRpcResponse struct { Id any `json:"id"` Result any `json:"result"` Error []any `json:"error"` }
func NewResponse ¶
func NewResponse(event JsonRpcEvent, results any, err []any) JsonRpcResponse
func UnmarshalResponse ¶
func UnmarshalResponse(in string) (JsonRpcResponse, error)
type LineCallback ¶
type MockConnection ¶
type MockConnection struct {
// contains filtered or unexported fields
}
func NewMockConnection ¶
func NewMockConnection() *MockConnection
func (*MockConnection) AsyncReadTestDataFromBuffer ¶
func (mc *MockConnection) AsyncReadTestDataFromBuffer(handler func([]byte))
func (*MockConnection) AsyncWriteTestDataToReadBuffer ¶
func (mc *MockConnection) AsyncWriteTestDataToReadBuffer(s string)
func (*MockConnection) Close ¶
func (mc *MockConnection) Close() error
func (*MockConnection) LocalAddr ¶
func (mc *MockConnection) LocalAddr() net.Addr
func (*MockConnection) ReadTestDataFromBuffer ¶
func (mc *MockConnection) ReadTestDataFromBuffer(handler func([]byte))
func (*MockConnection) RemoteAddr ¶
func (mc *MockConnection) RemoteAddr() net.Addr
func (*MockConnection) SetDeadline ¶
func (mc *MockConnection) SetDeadline(t time.Time) error
func (*MockConnection) SetReadDeadline ¶
func (mc *MockConnection) SetReadDeadline(t time.Time) error
func (*MockConnection) SetWriteDeadline ¶
func (mc *MockConnection) SetWriteDeadline(t time.Time) error
type StateGenerator ¶
type StateGenerator func() any
type StratumClientListener ¶
type StratumClientListener interface { OnConnect(ctx *StratumContext) OnDisconnect(ctx *StratumContext) }
type StratumContext ¶
type StratumContext struct { RemoteAddr string WalletAddr string WorkerName string Password string RemoteApp string Id int32 Logger *zap.Logger State any // gross, but go generics aren't mature enough this can be typed 😭 Extranonce string SesUid string // contains filtered or unexported fields }
func (*StratumContext) Connected ¶
func (sc *StratumContext) Connected() bool
func (*StratumContext) Disconnect ¶
func (sc *StratumContext) Disconnect()
func (StratumContext) Done ¶
func (StratumContext) Done() <-chan struct{}
func (StratumContext) Err ¶
func (StratumContext) Err() error
func (*StratumContext) Reply ¶
func (sc *StratumContext) Reply(response JsonRpcResponse) error
func (*StratumContext) ReplyBadShare ¶
func (sc *StratumContext) ReplyBadShare(id any) error
func (*StratumContext) ReplyDupeShare ¶
func (sc *StratumContext) ReplyDupeShare(id any) error
func (*StratumContext) ReplyLowDiffShare ¶
func (sc *StratumContext) ReplyLowDiffShare(id any) error
func (*StratumContext) ReplyStaleShare ¶
func (sc *StratumContext) ReplyStaleShare(id any) error
func (*StratumContext) Send ¶
func (sc *StratumContext) Send(event JsonRpcEvent) error
func (*StratumContext) String ¶
func (sc *StratumContext) String() string
func (*StratumContext) Summary ¶
func (sc *StratumContext) Summary() ContextSummary
func (StratumContext) Value ¶
func (d StratumContext) Value(key any) any
type StratumHandlerMap ¶
type StratumHandlerMap map[string]EventHandler
func DefaultHandlers ¶
func DefaultHandlers() StratumHandlerMap
type StratumListener ¶
type StratumListener struct { StratumListenerConfig // contains filtered or unexported fields }
func NewListener ¶
func NewListener(cfg StratumListenerConfig) *StratumListener
func (*StratumListener) HandleEvent ¶
func (s *StratumListener) HandleEvent(ctx *StratumContext, event JsonRpcEvent) error
type StratumListenerConfig ¶
type StratumListenerConfig struct { Logger *zap.Logger HandlerMap StratumHandlerMap ClientListener StratumClientListener StateGenerator StateGenerator Port string }
func DefaultConfig ¶
func DefaultConfig(logger *zap.Logger) StratumListenerConfig
type StratumMethod ¶
type StratumMethod string
const ( StratumMethodSubscribe StratumMethod = "mining.subscribe" StratumMethodAuthorize StratumMethod = "mining.authorize" StratumMethodSubmit StratumMethod = "mining.submit" )
type StratumStats ¶
type StratumStats struct {
Disconnects int64
}
Click to show internal directories.
Click to hide internal directories.