Documentation ¶
Index ¶
- Constants
- func Csum(data []byte, srcip, dstip [4]byte) uint16
- func DecodeStratumHash(hash []byte) (*chainhash.Hash, error)
- func DeserializeJsonMap(jsonMap map[string]interface{}, target interface{}) error
- func GetLoglevelFromEnv() int
- func HashToString(h []byte) string
- func MeasureTcpLatency(remoteHost string, remotePort int) (int64, error)
- func NewClientID() string
- func NewJobID() string
- func ReadElement(r io.Reader, element interface{}) error
- func ReadElements(r io.Reader, elements ...interface{}) error
- func ReadOutPoint(r io.Reader, op *wire.OutPoint) error
- func ReadScript(r io.Reader, fieldName string) ([]byte, error)
- func ReadTxIn(r io.Reader, ti *wire.TxIn) error
- func ReadTxOut(r io.Reader, to *wire.TxOut) error
- func ReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error)
- func ReadVarInt(r io.Reader, pver uint32) (uint64, error)
- func RevHash(hash string) string
- func RevHashBytes(hash []byte) []byte
- func ReverseByteArray(b []byte) []byte
- type BlockHeader
- type HubMessage
- type Int64Time
- type StratumClientIdentity
- type StratumJob
- type StratumServerIdentity
- type TCPHeader
- type TCPOption
- type Uint32Time
Constants ¶
const ( FIN = 1 // 00 0001 SYN = 2 // 00 0010 RST = 4 // 00 0100 PSH = 8 // 00 1000 ACK = 16 // 01 0000 URG = 32 // 10 0000 )
const (
// MaxVarIntPayload is the maximum payload size for a variable length integer.
MaxVarIntPayload = 9
)
Variables ¶
This section is empty.
Functions ¶
func DeserializeJsonMap ¶
func GetLoglevelFromEnv ¶
func GetLoglevelFromEnv() int
func HashToString ¶
func NewClientID ¶
func NewClientID() string
NewClientID returns a new ID for internal references to client connections
func ReadElement ¶
readElement reads the next sequence of bytes from r using little endian depending on the concrete type of element pointed to.
func ReadElements ¶
readElements reads multiple items from r. It is equivalent to multiple calls to readElement.
func ReadOutPoint ¶
ReadOutPoint reads the next sequence of bytes from r as an OutPoint.
func ReadScript ¶
ReadScript reads a variable length byte array that represents a transaction script. It is encoded as a varInt containing the length of the array followed by the bytes themselves. An error is returned if the length is greater than the passed maxAllowed parameter which helps protect against memory exhaustion attacks and forced panics through malformed messages. The fieldName parameter is only used for the error message so it provides more context in the error.
func ReadVarBytes ¶
ReadVarBytes reads a variable length byte array. A byte array is encoded as a varInt containing the length of the array followed by the bytes themselves. An error is returned if the length is greater than the passed maxAllowed parameter which helps protect against memory exhaustion attacks and forced panics through malformed messages. The fieldName parameter is only used for the error message so it provides more context in the error.
func ReadVarInt ¶
ReadVarInt reads a variable length integer from r and returns it as a uint64.
func RevHashBytes ¶
func ReverseByteArray ¶
Types ¶
type BlockHeader ¶
type BlockHeader struct { Bits string `json:"bits" bson:"bits"` Hash string `json:"hash" bson:"hash"` Height int64 `json:"height" bson:"height"` PrevHash string `json:"previousblockhash" bson:"previousblockhash"` MedianTime uint64 `json:"medianTime" bson:"medianTime"` Time uint64 `json:"time" bson:"time"` Coin string `json:"coin" bson:"coin"` TimeDiscovered uint64 `json:"timeDiscovered" bson:"timeDiscovered"` }
type HubMessage ¶
type Int64Time ¶
Int64Time represents a unix timestamp encoded with an int64. It is used as a way to signal the readElement function how to decode a timestamp into a Go time.Time since it is otherwise ambiguous.
type StratumClientIdentity ¶
type StratumJob ¶
type StratumJob struct { ID string Difficulty float64 ExtraNonce1 string ExtraNonce2Size int JobData []interface{} }
func NewStratumJobFromJsonProperty ¶
func NewStratumJobFromJsonProperty(i interface{}) StratumJob
func (StratumJob) AsJobData ¶
func (job StratumJob) AsJobData() []interface{}
func (StratumJob) AsJobDataWithNewTimestamp ¶
func (job StratumJob) AsJobDataWithNewTimestamp() []interface{}
type StratumServerIdentity ¶
type StratumServerIdentity struct {
Algorithm string
}
type TCPHeader ¶
type Uint32Time ¶
Uint32Time represents a unix timestamp encoded with a uint32. It is used as a way to signal the readElement function how to decode a timestamp into a Go time.Time since it is otherwise ambiguous.