miningrigrentals

package module
v0.0.0-...-6c4d4a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2016 License: MIT Imports: 15 Imported by: 2

README

MiningRigRentals.com for Go

Installation

# install the library:
go get github.com/bitbandi/go-miningrigrentals-api

// Use in your .go code:
import (
    "github.com/bitbandi/go-miningrigrentals-api"
)

API Documentation

Full godoc output from the latest code in master is available here:

http://godoc.org/github.com/bitbandi/go-miningrigrentals-api

Quickstart

package main

import (
    "github.com/bitbandi/go-miningrigrentals-api"
    "log"
)

func main() {
    client := miningrigrentals.NewClient("YOUR_KEY", "YOUR_SECRET")
	balance, err := client.GetBalance()
    if err != nil {
        log.Fatalln("Unable to query balance: ", err)
    }

    log.Printf("Your confirmed balance: %f btc\n", balance.Confirmed)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNonce

func GetNonce() int64

func GetNonceStr

func GetNonceStr() string

func ParseUint16

func ParseUint16(s string) (uint16, error)

Types

type Balance

type Balance struct {
	Confirmed   float64 `json:"confirmed,string"`
	Unconfirmed float64 `json:"unconfirmed,string"`
}

type Client

type Client struct {
	BaseURL    string
	Secret     string
	Key        string
	HTTPClient *http.Client
}

func New

func New(key, secret string) *Client

func (*Client) GetBalance

func (c *Client) GetBalance() (responses *Balance, err error)

func (*Client) GetRentalDetails

func (c *Client) GetRentalDetails(id int64) (*RentalDetails, error)

func (*Client) GetRigDetails

func (c *Client) GetRigDetails(id int64) (*RigDetails, error)

func (*Client) ListMyRentals

func (c *Client) ListMyRentals() ([]MyRentals, error)

func (*Client) ListMyRigs

func (c *Client) ListMyRigs() ([]MyRigs, error)

func (*Client) ListRigs

func (c *Client) ListRigs(algotype string) ([]RigList, *RigListInfo, error)

func (*Client) Request

func (c *Client) Request(httpmethod string, apimethod string, params map[string]string, result *json.RawMessage) (res *http.Response, err error)

type Error

type Error struct {
	Message string `json:"message"`
}

func (Error) Error

func (e Error) Error() string

type MyRentals

type MyRentals struct {
	Id               uint64 `json:"id,string"`
	RigId            uint64 `json:"rigid,string"`
	Name             string `json:"name"`
	StartTime        Time   `json:"start_time,string"`
	Type             string
	Online           uint8   `json:"online,string"`
	Price            float64 `json:"price,string"`
	AvailableInHours float64 `json:"available_in_hours,string"`
	Status           string
	Advertised       MyRentalsHashRateAdvertised `json:"advertised"`
	Current          MyRentalsHashRateCurrent    `json:"current"`
	Average          MyRentalsHashRateAverage    `json:"average"`
}

type MyRentalsHashRateAdvertised

type MyRentalsHashRateAdvertised struct {
	HashRate     float64 `json:"hashrate,string"`
	HashRateNice string  `json:"hashrate_nice"`
}

type MyRentalsHashRateAverage

type MyRentalsHashRateAverage struct {
	HashRate     float64 `json:"hashrate"`
	HashRateNice string  `json:"hashrate_nice"`
	Percent      float32 `json:"percent,string"`
}

type MyRentalsHashRateCurrent

type MyRentalsHashRateCurrent struct {
	HashRate5m      float64 `json:"hash_5m"`
	HashRate5mNice  string  `json:"hash_5m_nice"`
	HashRate30m     float64 `json:"hash_30m"`
	HashRate30mNice string  `json:"hash_30m_nice"`
	HashRate1h      float64 `json:"hash_1h"`
	HashRate1hNice  string  `json:"hash_1h_nice"`
}

type MyRentalsResponse

type MyRentalsResponse struct {
	Records []MyRentals `json:"records"`
}

type MyRigs

type MyRigs struct {
	Id           uint64 `json:"id,string"`
	Name         string `json:"name"`
	Rpi          string
	Type         string
	Online       uint8   `json:"online,string"`
	Price        float64 `json:"price,string"`
	PriceHour    float64 `json:"price_hr,string"`
	MinHours     uint16  `json:"minhrs,string"`
	MaxHours     uint16  `json:"maxhrs,string"`
	Status       string
	HashRate     uint64 `json:"hashrate,string"`
	HashRateNice string `json:"hashrate_nice"`
}

type MyRigsResponse

type MyRigsResponse struct {
	Records []MyRigs `json:"records"`
}

type RentalDetails

type RentalDetails struct {
	Id        uint64 `json:"id,string"`
	RigId     uint64 `json:"rigid,string"`
	Name      string `json:"name"`
	StartTime Time   `json:"start_time,string"`
	Owner     string
	Renter    string
	Region    string
	Type      string
	HashRate  RentalHashrate `json:"hashrate"`
	Price     float64        `json:"price,string"`
	Length    uint64         `json:"length,string"`
	Left      float64        `json:"left,string"`
	Status    string
}

type RentalHashrate

type RentalHashrate struct {
	Advertised  uint64 `json:"advertised,string"`
	Average     string
	HashRate5m  float64 `json:"5min"`
	HashRate30m float64 `json:"30min"`
	HashRate1h  float64 `json:"60min"`
}

type Response

type Response struct {
	Success bool            `json:"success"`
	Version int64           `json:"version,string"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data"`
}

type RigDetails

type RigDetails struct {
	Id               uint64 `json:"id,string"`
	Name             string `json:"name"`
	RentalId         uint64 `json:"rentalid,string,omitempty"`
	Rpi              string
	Owner            string
	StartTime        Time `json:"start_time,string"`
	Region           string
	Type             string
	Price            float64 `json:"price,string"`
	Status           string
	HashRate         RigHashRate `json:"hashrate"`
	MinHours         uint16
	MaxHours         uint16
	AvailableInHours float64 `json:"available_in_hours,string,omitempty"`
}

func (*RigDetails) UnmarshalJSON

func (a *RigDetails) UnmarshalJSON(b []byte) error

type RigHashRate

type RigHashRate struct {
	Advertised  uint64  `json:"advertised,string"`
	HashRate5m  float64 `json:"5min"`
	HashRate30m float64 `json:"30min"`
	HashRate1h  float64 `json:"60min"`
}

type RigList

type RigList struct {
	Id           uint64 `json:"id,string"`
	Name         string `json:"name"`
	Rpi          string
	Type         string
	Online       uint8   `json:"online,string"`
	Price        float64 `json:"price,string"`
	PriceHour    float64 `json:"price_hr,string"`
	MinHours     uint16  `json:"minhrs,string"`
	MaxHours     uint16  `json:"maxhrs,string"`
	Rating       float64 `json:"rating,string"`
	Status       string
	HashRate     uint64 `json:"hashrate,string"`
	HashRateNice string `json:"hashrate_nice"`
}

type RigListInfo

type RigListInfo struct {
	Start     uint32           `json:"start_num"`
	End       uint32           `json:"end_num"`
	Total     uint32           `json:"total,string"`
	Available RigListInfoStats `json:"available"`
	Rented    RigListInfoStats `json:"rented"`
	Price     RigListInfoPrice `json:"price"`
}

type RigListInfoPrice

type RigListInfoPrice struct {
	Lowest float64 `json:"lowest,string"`
	Last10 float64 `json:"last_10,string"`
	Last   float64 `json:"last,string"`
}

type RigListInfoStats

type RigListInfoStats struct {
	Rigs uint32 `json:"rigs,string"`
	Hash uint64 `json:"hash,string"`
}

type RigListResponse

type RigListResponse struct {
	Records []RigList   `json:"records"`
	Info    RigListInfo `json:"info"`
}

type Time

type Time time.Time

func (*Time) Time

func (t *Time) Time() time.Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL