Documentation ¶
Overview ¶
Package monitor provides access to monitored addresses
Index ¶
- Constants
- func ListMonitors(chain, watchList string, monitorChan chan<- Monitor)
- type Header
- type Monitor
- func (mon *Monitor) Close()
- func (mon *Monitor) Count() int64
- func (mon *Monitor) Delete() (prev bool)
- func (mon *Monitor) IsDeleted() bool
- func (mon *Monitor) IsOpen() bool
- func (mon *Monitor) MoveToProduction() error
- func (mon *Monitor) Path() (path string)
- func (mon *Monitor) ReadAndFilterAppearances(filt *filter.AppearanceFilter, withCount bool) (apps []types.SimpleAppearance, cnt int, err error)
- func (mon *Monitor) ReadAppearanceAt(idx int64, app *index.AppearanceRecord) (err error)
- func (mon *Monitor) ReadMonitorHeader() (err error)
- func (mon *Monitor) Reload(create bool) (int64, error)
- func (mon *Monitor) Remove() (bool, error)
- func (mon *Monitor) RemoveDups() (int64, int64, error)
- func (mon Monitor) String() string
- func (mon *Monitor) TruncateTo(chain string, num uint32) (bool, error)
- func (mon *Monitor) UnDelete() (prev bool)
- func (mon *Monitor) WriteAppearances(apps []index.AppearanceRecord, append bool) (int64, error)
- func (mon *Monitor) WriteAppearancesAppend(lastScanned uint32, apps *[]index.AppearanceRecord) error
- func (mon *Monitor) WriteMonHeader(deleted bool, lastScanned uint32, force bool) (err error)
- type MonitorUpdate
Constants ¶
const (
Ext = ".mon.bin"
)
Variables ¶
This section is empty.
Functions ¶
func ListMonitors ¶
ListMonitors puts a list of Monitors into the monitorChannel. The list of monitors is built from a file called addresses.tsv in the current folder or, if not present, from existing monitors
Types ¶
type Header ¶
type Header struct { Magic uint16 `json:"-"` Unused bool `json:"-"` Deleted bool `json:"deleted,omitempty"` LastScanned uint32 `json:"lastScanned,omitempty"` }
Header is the header of the Monitor file. Note that it's the same width as an index.AppearanceRecord therefor one should not change its size
type Monitor ¶
type Monitor struct { Address base.Address `json:"address"` Staged bool `json:"-"` Chain string `json:"-"` ReadFp *os.File `json:"-"` Header }
Monitor carries information about a Monitor file and its header
func NewMonitor ¶
NewMonitor returns a Monitor (but has not yet read in the AppearanceRecords). If 'create' is sent, create the Monitor if it does not already exist
func NewMonitorStaged ¶
NewMonitorStaged returns a Monitor whose path is in the 'staging' folder
func (*Monitor) Close ¶
func (mon *Monitor) Close()
Close closes an open Monitor if it's open, does nothing otherwise
func (*Monitor) Delete ¶
Delete marks the file's delete flag, but does not physically remove the file
func (*Monitor) MoveToProduction ¶
MoveToProduction moves a previously staged monitor to the monitors folder.
func (*Monitor) ReadAndFilterAppearances ¶
func (mon *Monitor) ReadAndFilterAppearances(filt *filter.AppearanceFilter, withCount bool) (apps []types.SimpleAppearance, cnt int, err error)
func (*Monitor) ReadAppearanceAt ¶
func (mon *Monitor) ReadAppearanceAt(idx int64, app *index.AppearanceRecord) (err error)
ReadAppearanceAt returns the appearance at the one-based index. The file remains open.
func (*Monitor) ReadMonitorHeader ¶
ReadMonitorHeader reads the monitor's header and returns without closing the file
func (*Monitor) Reload ¶
Reload loads information about the monitor such as the file's size and record count
func (*Monitor) Remove ¶
Remove removes a previously deleted file, does nothing if the file is not deleted
func (*Monitor) WriteAppearances ¶
WriteAppearances writes appearances to a Monitor
func (*Monitor) WriteAppearancesAppend ¶
func (mon *Monitor) WriteAppearancesAppend(lastScanned uint32, apps *[]index.AppearanceRecord) error
WriteAppearancesAppend appends appearances to the end of the file, updates the header with lastScanned (if later) and returns the number of records written. Note that we should be writing to a temporary file.
type MonitorUpdate ¶
type MonitorUpdate struct { MaxTasks int MonitorMap map[base.Address]*Monitor Chain string PublisherAddr base.Address TestMode bool Silent bool FirstBlock uint64 Addrs []string }
MonitorUpdate stores the original 'chifra list' command line options plus
func NewUpdater ¶
func NewUpdater(chain string, testMode, silent bool, addrs []string) MonitorUpdate
func (*MonitorUpdate) FreshenMonitors ¶
func (updater *MonitorUpdate) FreshenMonitors(monitorArray *[]Monitor) (bool, error)