Documentation
¶
Overview ¶
Package monitor provides access to monitored addresses
Index ¶
- Constants
- func AsSliceOfItemMaps[T types.MappedType](mon *Monitor, filter *types.AppearanceFilter, reversed bool) ([]map[types.Appearance]*T, int, error)
- func ListExistingMonitors(chain string, monitorChan chan<- Monitor)
- func ListWatchedMonitors(chain, watchList string, monitorChan chan<- Monitor)
- func PathToMonitorFile(chain string, address base.Address) string
- type Header
- type Monitor
- func (mon *Monitor) Close()
- func (mon *Monitor) Count() int64
- func (mon *Monitor) Decache(conn *rpc.Connection, showProgress bool) (string, error)
- func (mon *Monitor) Delete() (prev bool)
- func (mon *Monitor) GetRemoveWarning() string
- 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 *types.AppearanceFilter, withCount bool) (apps []types.Appearance, cnt int, err error)
- func (mon *Monitor) ReadAppearanceAt(idx int64, app *types.AppRecord) (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) RemoveMonitor() string
- func (mon *Monitor) RemoveStatements(l int, showProgress bool) 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 []types.AppRecord, append bool) (int64, error)
- func (mon *Monitor) WriteAppearancesAppend(lastScanned uint32, apps *[]types.AppRecord) 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 AsSliceOfItemMaps ¶
func AsSliceOfItemMaps[T types.MappedType](mon *Monitor, filter *types.AppearanceFilter, reversed bool) ([]map[types.Appearance]*T, int, error)
AsSliceOfItemMaps reads appearances from the monitor and returns them as batched maps ready for transaction processing
func ListExistingMonitors ¶
ListExistingMonitors 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
func ListWatchedMonitors ¶
ListWatchedMonitors puts a list of Monitors into the monitorChannel. The list of monitors is built from a file called addresses.tsv in the current folder
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 types.AppRecord 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) GetRemoveWarning ¶
func (*Monitor) MoveToProduction ¶
MoveToProduction moves a previously staged monitor to the monitors folder.
func (*Monitor) ReadAndFilterAppearances ¶
func (mon *Monitor) ReadAndFilterAppearances(filt *types.AppearanceFilter, withCount bool) (apps []types.Appearance, cnt int, err error)
func (*Monitor) ReadAppearanceAt ¶
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) RemoveMonitor ¶
func (*Monitor) RemoveStatements ¶
func (*Monitor) WriteAppearances ¶
WriteAppearances writes appearances to a Monitor
func (*Monitor) WriteAppearancesAppend ¶
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
SkipFreshen bool
FirstBlock base.Blknum
Addrs []string
}
MonitorUpdate stores the original 'chifra list' command line options plus
func NewUpdater ¶
func NewUpdater(chain string, testMode, skipFreshen bool, addrs []string) MonitorUpdate
func (*MonitorUpdate) FreshenMonitors ¶
func (updater *MonitorUpdate) FreshenMonitors(monitorArray *[]Monitor) (bool, error)