bundles

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 20 Imported by: 0

README

fio-bundles

This tool handles the automatic refresh of bundles. It queries the registration site database for all fio handles that are marked as "auto-refresh" and then refreshes them if they are low.

It requires access to the registration site database and a FIO API node.

A local cache is used to limit the number of database queries. There is some rudimentary rate limiting on refreshes for an address, requiring a random wait of between 1 and 2 hours.

A watchdog is built in, so if the process stalls it will detect this and restart itself.

Logs are added to the registration database upon completion of a refresh. The UI is not designed for this, but the logs can be viewed when viewing the details for the pub key associated to the address.

Configuration

This is intended to be run as a container, and have the configuration passed in via secret environment variables. The following environment variables are required:

  • NODEOS_URL - the URL of the FIO API node to use
  • DB - the database connection string. Expected format is postgres://user:password@host:port/database
  • WIF - the private key to use for signing transactions
  • PERM - the permission to use for signing transactions, e.g. fio.address@active this option is only needed if the account is using a delegated permission.

Building

This is a standard go project, so can be built with go build or go install. The Dockerfile is provided for convenience and will provide a small container with the binary.

Usage
$ bundles -h
  -d string
    	Required: db connection string. Alternate ENV: DB
  -f string
    	Optional: state cache filename. Alternate ENV: FILE (default "state.dat")
  -k string
    	Required: private key WIF. Alternate ENV: WIF
  -p string
    	Optional: permission ex: actor@active. Alternate ENV: PERM
  -u string
    	Required: nodeos API url. Alternate ENV: NODEOS_URL
  -v	verbose logging

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run()

Run is the main entrypoint. It will setup channels, launch routines for handling the event queue, and has a watchdog that will exit if any goroutine appears stalled.

Types

type Address

type Address struct {
	Hash       string
	Refreshed  time.Time
	Expired    bool
	DbResponse *AddressResponse
}

Address holds information used in the address cache

func NewAddress

func NewAddress(dbr *AddressResponse) *Address

NewAddress creates an Address

func (*Address) CheckRemaining

func (a *Address) CheckRemaining() (needsBundle bool, err error)

CheckRemaining queries the chain for remaining bundles.

func (Address) Stale

func (a Address) Stale() bool

Stale determines if an address should be checked for remaining bundles

type AddressCache

type AddressCache struct {
	MinDbAccount map[int]int // wallet_id and account_id
	Addresses    map[string]*Address
	// contains filtered or unexported fields
}

AddressCache holds the list of addresses discovered, allows tracking when to query for bundle depletion, and tracks the lowest height in the accounts table to query.

type AddressResponse

type AddressResponse struct {
	AccountId int    `json:"account_id"`
	OwnerKey  string `json:"owner_key"`
	Address   string `json:"address"`
	Domain    string `json:"domain"`
}

AddressResponse holds the result of a database query for bundle-eligible addresses

type EventResult

type EventResult struct {
	Id           int
	Status       trxStatus
	Addr         *AddressResponse
	TrxId        string
	Expiration   time.Time
	BlockNum     int
	TxErr        eos.APIError
	LastTrxEvent int
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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