Documentation ¶
Index ¶
- Constants
- Variables
- func ChallengeBucket(tx *bolt.Tx, address string) (*bolt.Bucket, error)
- func GetCurrentHeight() (int64, error)
- func GetHotspotAddress(name string) (string, error)
- func GetHotspotName(address string) (string, error)
- func GetListOfAddresses(challenges []Challenges) ([]string, error)
- func MergeTwoSeries(ax, ay, bx, by []float64) ([]float64, []float64)
- func NewRestyClient() *resty.Client
- func XValueFormatter(v interface{}) string
- func XValueFormatterUnix(v interface{}) string
- type BoltDB
- func (b *BoltDB) AutoRefreshHotspots(limit int64) error
- func (b *BoltDB) Close()
- func (b *BoltDB) GenerateBeaconsGraph(address string, results []Challenges, settings GraphSettings) error
- func (b *BoltDB) GeneratePeerGraphs(address string, challenges []Challenges, settings GraphSettings) error
- func (b *BoltDB) GenerateWitnessesGraph(address string, results []Challenges, settings GraphSettings) error
- func (b *BoltDB) GetChallenges(address string, first time.Time, last time.Time) ([]Challenges, error)
- func (b *BoltDB) GetDb() *bolt.DB
- func (b *BoltDB) GetHotspot(address string) (Hotspot, error)
- func (b *BoltDB) GetHotspotAddress(name string) (string, error)
- func (b *BoltDB) GetHotspotByUnknown(addressOrName string) (string, error)
- func (b *BoltDB) GetHotspotName(address string) (string, error)
- func (b *BoltDB) GetHotspots() ([]Hotspot, error)
- func (b *BoltDB) GetHotspotsCacheHeight() (int64, error)
- func (b *BoltDB) LoadChallenges(address string, first, last time.Time, holddown time.Duration) error
- func (b *BoltDB) LoadHotspots(last time.Time) error
- func (b *BoltDB) SetAllHotspots(hotspots []Hotspot) error
- func (b *BoltDB) SetHotspots(hotspots []Hotspot) error
- type ChallengeCache
- type ChallengeResponse
- type ChallengeResult
- type Challenges
- type GeocodeType
- type GraphSettings
- type HeightResponse
- type Hotspot
- type HotspotCache
- type HotspotResponse
- type HotspotsResponse
- type PathType
- type RXTX
- type ReceiptType
- type StatusType
- type TooBusyError
- type WitnessResult
- type WitnessType
Constants ¶
const ( HEIGHT = 512 WIDTH = 1024 Y_MIN = -130.0 Y_MAX = -70.0 DOT_SIZE = 3 SNR_MIN = -20.0 SNR_MAX = 16.0 )
const ( /* HOTSPOT_URL = "https://helium-api.stakejoy.com/v1/hotspots/%s" HOTSPOTS_URL = "https://helium-api.stakejoy.com/v1/hotspots" HEIGHT_URL = "https://helium-api.stakejoy.com/v1/blocks/height" CHALLENGE_URL = "https://helium-api.stakejoy.com/v1/hotspots/%s/challenges" */ HOTSPOT_URL = "https://api.helium.io/v1/hotspots/%s" HOTSPOTS_URL = "https://api.helium.io/v1/hotspots" HEIGHT_URL = "https://api.helium.io/v1/blocks/height" CHALLENGE_URL = "https://api.helium.io/v1/hotspots/%s/challenges" RETRY_ATTEMPTS = 10 )
const ( HOTSPOT_CACHE_TIMEOUT = 86400 // one day HOTSPOT_CACHE_FILE = "hotspots.json" )
const TIME_FORMAT = "2006-01-02 15:04:05 MST"
Variables ¶
var CHALLENGES_BUCKET []byte = []byte("challenges")
var DB_VERSION []byte = []byte("v1")
var HOTSPOTS_BUCKET []byte = []byte("hotspots")
"constants" in go are awesome
var HOTSPOTS_CACHE_KEY []byte = []byte("hotspotcache")
var HOTSPOT_CACHE map[string]Hotspot = map[string]Hotspot{}
var HOTSPOT_NAMES_BUCKET []byte = []byte("hotspot_names")
var META_BUCKET []byte = []byte("metadata")
var SnrTable = map[int]int{
16: -90,
14: -90,
13: -90,
15: -90,
12: -90,
11: -90,
10: -90,
9: -95,
8: -105,
7: -108,
6: -113,
5: -115,
4: -115,
3: -115,
2: -117,
1: -120,
0: -125,
-1: -125,
-2: -125,
-3: -125,
-4: -125,
-5: -125,
-6: -124,
-7: -123,
-8: -125,
-9: -125,
-10: -125,
-11: -125,
-12: -125,
-13: -125,
-14: -125,
-15: -124,
-16: -123,
-17: -123,
-18: -123,
-19: -123,
-20: -123,
}
Table is map[SNR] = minimum valid RSSI Stolen from: https://github.com/Carniverous19/helium_analysis_tools.git
var VERSION_KEY []byte = []byte("version")
Functions ¶
func ChallengeBucket ¶ added in v0.9.0
returns the challenge bucket for a hotspot address
func GetCurrentHeight ¶ added in v0.9.0
Gets the current height of the blockchain
func GetHotspotAddress ¶
func GetHotspotName ¶
func GetListOfAddresses ¶
func GetListOfAddresses(challenges []Challenges) ([]string, error)
get a unique list of addresses in all the challenges
func MergeTwoSeries ¶
used to merge the valid & invalid RX/TX data into a single series
func NewRestyClient ¶ added in v0.9.2
func NewRestyClient() *resty.Client
func XValueFormatterUnix ¶
func XValueFormatterUnix(v interface{}) string
Types ¶
type BoltDB ¶ added in v0.9.0
type BoltDB struct {
// contains filtered or unexported fields
}
func (*BoltDB) AutoRefreshHotspots ¶ added in v0.9.0
func (*BoltDB) GenerateBeaconsGraph ¶ added in v0.9.0
func (b *BoltDB) GenerateBeaconsGraph(address string, results []Challenges, settings GraphSettings) error
Creates the PNG for the the beacons sent
func (*BoltDB) GeneratePeerGraphs ¶ added in v0.9.0
func (b *BoltDB) GeneratePeerGraphs(address string, challenges []Challenges, settings GraphSettings) error
Generate all the peer graphs for a given address
func (*BoltDB) GenerateWitnessesGraph ¶ added in v0.9.0
func (b *BoltDB) GenerateWitnessesGraph(address string, results []Challenges, settings GraphSettings) error
Creates the PNG for the the witnesses
func (*BoltDB) GetChallenges ¶ added in v0.9.0
func (b *BoltDB) GetChallenges(address string, first time.Time, last time.Time) ([]Challenges, error)
returns a list of challenges for the given hotspot
func (*BoltDB) GetHotspot ¶ added in v0.9.0
Get the Hotspot metadata for a given address
func (*BoltDB) GetHotspotAddress ¶ added in v0.9.0
Lookup the hotspot address by name
func (*BoltDB) GetHotspotByUnknown ¶ added in v0.9.0
Returns the address of the hotspot given an address or name
func (*BoltDB) GetHotspotName ¶ added in v0.9.0
Lookup the hotspot name by address
func (*BoltDB) GetHotspots ¶ added in v0.9.0
Get all the hotspots in the DB
func (*BoltDB) GetHotspotsCacheHeight ¶ added in v0.9.0
returns the height of the block chain when we cached the hotspots
func (*BoltDB) LoadChallenges ¶ added in v0.9.0
func (b *BoltDB) LoadChallenges(address string, first, last time.Time, holddown time.Duration) error
Load all the challenges as old as first if last <= time.UTC()
func (*BoltDB) LoadHotspots ¶ added in v0.9.0
Loads all the current hotspots into the database, if we are too old
func (*BoltDB) SetAllHotspots ¶ added in v0.9.0
Write a list of hotspots to the database under the address
func (*BoltDB) SetHotspots ¶ added in v0.9.0
Write a list of hotspots to the database under the address and name
type ChallengeCache ¶
type ChallengeCache struct { CacheTime int64 `json:"cache_time"` Address string `json:"address"` StartDate int64 `json:"start_date"` Challenges []Challenges `json:"challenges"` }
type ChallengeResponse ¶
type ChallengeResponse struct { Data []Challenges `json:"data"` Cursor string `json:"cursor"` }
type ChallengeResult ¶
type Challenges ¶
type Challenges struct { Type string `json:"type"` Time int64 `json:"time"` Secret string `json:"secret"` Path *[]PathType `json:"path"` OnionKeyHash string `json:"onion_key_hash"` Height int64 `json:"height"` Hash string `json:"hash"` Fee int `json:"fee"` ChallengerOwner string `json:"challenger_owner"` ChallengerLon float64 `json:"challenger_lon"` ChallengerLat float64 `json:"challenger_lat"` ChallengerLocation string `json:"challenger_location"` Challenger string `json:"challenger"` }
func FetchChallenges ¶
func FetchChallenges(address string, start time.Time) ([]Challenges, error)
Download all the challenges from the API. Returns newest first (LIFO)
func (*Challenges) GetTime ¶
func (c *Challenges) GetTime() (time.Time, error)
Tries to figure out the Time for the given challenge
func (*Challenges) GetTimestamp ¶
func (c *Challenges) GetTimestamp() (int64, error)
Tries to figure out the Timestamp for the given challenge
type GeocodeType ¶
type GeocodeType struct { ShortStreet string `json:"short_street"` ShortState string `json:"short_state"` ShortCountry string `json:"short_country"` ShortCity string `json:"short_city"` Street string `json:"long_street"` State string `json:"long_state"` Country string `json:"long_country"` City string `json:"long_city"` }
type GraphSettings ¶ added in v0.9.0
type HeightResponse ¶ added in v0.9.0
type Hotspot ¶
type Hotspot struct { Address string `json:"address"` Block int64 `json:"block"` BlockAdded int64 `json:"block_added"` Geocode *GeocodeType `json:"geocode"` Lat float64 `json:"lat"` Lng float64 `json:"lng"` Location string `json:"location"` Name string `json:"name"` Nonce int64 `json:"nonce"` Owner string `json:"owner"` RewardScale float64 `json:"reward_scale"` Status *StatusType `json:"status"` }
func FetchHotspots ¶ added in v0.9.0
Download hotspot data from helium.api servers
func GetHotspot ¶
Looks up a hotspot by address in the cache. If not, it queries the API
type HotspotCache ¶
type HotspotResponse ¶
type HotspotResponse struct {
Data Hotspot `json:"data"`
}
type HotspotsResponse ¶
type PathType ¶
type PathType struct { Witnesses *[]WitnessType `json:"witnesses"` Receipt *ReceiptType `json:"receipt"` Geocode *GeocodeType `json:"geocode"` ChallengeeOwner string `json:"challengee_owner"` ChallengeeLon float64 `json:"challengee_lon"` ChallengeeLat float64 `json:"challengee_lat"` ChallengeeLocation string `json:"challengee_location"` Challengee string `json:"challengee"` }
type ReceiptType ¶
type StatusType ¶
type TooBusyError ¶ added in v0.9.2
type WitnessResult ¶
type WitnessResult struct { Timestamp int64 `json:"timestamp"` Address string `json:"address"` Witness string `json:"witness"` Type RXTX `json:"type"` Signal int `json:"signal"` Valid bool `json:"valid"` Km float64 `json:"km"` Mi float64 `json:"mi"` Location string `json:"location"` Snr float64 `json:"snr"` ValidThreshold float64 `json:"valid_threshold"` Hash string `json:"hash"` }