Version: v0.0.0-...-4487b4f Latest Latest

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

Go to latest
Published: Mar 13, 2018 License: Apache-2.0 Imports: 12 Imported by: 0




This section is empty.


This section is empty.


func Execute

func Execute()

Execute does the things

func MakePoint

func MakePoint(fees *FeeResponse, tb TrackedBalance, bal BlockchainInfoBalance) *client.Point

MakePoint takes all necessary data and returns an InfluxDB point


type BalanceMonitor

type BalanceMonitor struct {
	TrackedBalances TrackedBalances
	BalanceAddr     string
	FeesAddr        string
	PollingInterval time.Duration
	InfluxClient    client.Client
	Port            string

BalanceMonitor holds methods to query balances and write them to InfluxDB

func NewBalanceMonitor

func NewBalanceMonitor(config *Config) *BalanceMonitor

NewBalanceMonitor returns a new BalanceMonitor

func (*BalanceMonitor) GetAddressBalances

func (bm *BalanceMonitor) GetAddressBalances() (*BlockchainInfoResponse, error)

GetAddressBalances returns the API response from the addresses query

func (*BalanceMonitor) GetFees

func (bm *BalanceMonitor) GetFees() (*FeeResponse, error)

GetFees fetches the fee response data

func (*BalanceMonitor) MakePoints

func (bm *BalanceMonitor) MakePoints() (client.BatchPoints, error)

MakePoints returns the points from all the monitored addresses

func (*BalanceMonitor) Monitor

func (bm *BalanceMonitor) Monitor()

Monitor is the loop that continuously checks the address balance

type BlockchainInfoBalance

type BlockchainInfoBalance struct {
	FinalBalance  int `json:"final_balance"`
	NTx           int `json:"n_tx"`
	TotalReceived int `json:"total_received"`

BlockchainInfoBalance is details from a query to

type BlockchainInfoResponse

type BlockchainInfoResponse map[string]BlockchainInfoBalance

BlockchainInfoResponse is the response from an address query

type Config

type Config struct {
	InfluxConfig    InfluxConfig    `json:"influxConfig"`
	TrackedBalances TrackedBalances `json:"trackedBalances"`
	BalanceAddress  string          `json:"balanceAddress"`
	FeesAddress     string          `json:"feesAddress"`
	PollingInterval string          `json:"pollingInterval"`
	Port            int             `json:"port"`

Config represents the configuration file used in this application

type FeeResponse

type FeeResponse struct {
	FastestFee  int `json:"fastestFee"`
	HalfHourFee int `json:"halfHourFee"`
	HourFee     int `json:"hourFee"`

FeeResponse models the response from the fees API

type InfluxConfig

type InfluxConfig struct {
	Address  string `json:"address"`
	Username string `json:"username"`
	Password string `json:"password"`

InfluxConfig represents an InfluxDB connection

type TrackedBalance

type TrackedBalance struct {
	Address         string `json:"address"`
	Service         string `json:"service"`
	Balance         int    `json:"balance"`
	NumTransactions int    `json:"numTransactions"`

TrackedBalance contains details necessary to track a balance

type TrackedBalances

type TrackedBalances []TrackedBalance

TrackedBalances models multiple TrackedBalance

func (TrackedBalances) Address

func (tbs TrackedBalances) Address(addr string) TrackedBalance

Address returns an individual tracked balance

func (TrackedBalances) Addresses

func (tbs TrackedBalances) Addresses() string

Addresses returns the list of addresses formatted for quering

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL