utils

package
v0.0.0-...-000e973 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Trace - Used to trace code
	Trace *log.Logger
	// Info - Used as information message
	Info *log.Logger
	// Warning - Used when something didn't work as expected but we
	//           are OK with it.
	Warning *log.Logger
	// Error - Something failed.
	Error *log.Logger
)

Functions

func CountryTotal

func CountryTotal() (m map[string]int)

CountryTotal - Returns a map with total number of nodes by country

func FindFileFlag

func FindFileFlag(dir string, file []string) (flag string)

FindFileFlag - Find the flag for each country

func InitLog

func InitLog(traceHandle io.Writer, infoHandle io.Writer,
	warningHandle io.Writer, errorHandle io.Writer)

InitLog - Initialize package log.

func MyWanIp

func MyWanIp() (lat float64, lon float64)

MyWanIp - Gets the local machine WANIP and returns lat and lon.

func NodeInCSV

func NodeInCSV(ipv4 string) (lat float64, lon float64, country string, have bool)

NodeInCSV - Check if the node is onto CSV and avoid call ip-api.com

func ParseNode

func ParseNode(s []byte) (nodeInfo []geolocation.NodeInfo)

ParseNode - Parses a json provide by the bitmarkd node

func RunStandalone

func RunStandalone() (err error)

RunStandalone - Runs the standalone go program to generate maps

func WorldNodes

func WorldNodes(flatmap *sm.Context, globemap *globe.Globe, url string, m *TTLMap) (key string)

WorldNodes - Creates the maps for all nodes

Types

type Nodes

type Nodes struct {
	Address string
	Country string
	Lat     float64
	Lon     float64
	// contains filtered or unexported fields
}

Nodes - This struct receives all info for each node

type TTLMap

type TTLMap struct {
	// contains filtered or unexported fields
}

TTLMap - Map with time to live

func NewMap

func NewMap(maxTTL int) (m *TTLMap)

NewMap - Create a new map type with TTL

func (*TTLMap) Get

func (m *TTLMap) Get(k string) (v string)

Get - Get an item from a map

func (*TTLMap) GetAll

func (m *TTLMap) GetAll() (c map[string]*Nodes)

GetAll - Unsafe way to get all items from a map

func (*TTLMap) Len

func (m *TTLMap) Len() int

Len - Return the length of a map

func (*TTLMap) Put

func (m *TTLMap) Put(k, country string, lat float64, lon float64)

Put - Put a new intem into a map

Jump to

Keyboard shortcuts

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