netexplorer

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package netexplorer implements the exploration of block transactions for monitored addresses and adding/removing monitored addresses.

Index

Constants

View Source
const (
	WORK int = 0
	STOP int = 1
)

Status possible values, control whether a NextExplorer is working or is/has to stop.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetExplorer

type NetExplorer struct {
	Block uint64 `json:"block" bson:"block"` // last block parsed

	Bh  []string `json:"bh" bson:"bh"`   // contains the last blocks hashes (from Block-1 to Block-maxBlocks)
	Bhi int      `json:"bhi" bson:"bhi"` // index to last block's hash in Bh

	Map map[string]interface{} `json:"map" bson:"map"` // Map of addresses/transactions to the required information
	// contains filtered or unexported fields
}

NetExplorer contains the fields and data structures required to manage the exploring of a network or blockchain.

func New

func New(net string, max int, l []store.ListenedAddresses, db store.DB) (*NetExplorer, error)

New tries to load from DB a previously saved status of the net explorer or creates a new one with default values (start monitoring at block 1) if not present in DB. A slice of length=1 (only for one network) of addresses to monitor can be passed in 'l' and returns a NetExplorer object.

func (*NetExplorer) Add

func (n *NetExplorer) Add(obj string, value interface{})

Add adds an object and its value to the monitoring map.

func (*NetExplorer) Chained

func (n *NetExplorer) Chained(hash string) bool

Chained checks if the supplied hash is the last block's hash and so blocks are chained.

func (*NetExplorer) Del

func (n *NetExplorer) Del(obj string) (value interface{}, ok bool)

Del deletes a monitored object from the map returning its value. 'ok' is returned as false if the object was not being monitored.

func (*NetExplorer) FromStore

func (n *NetExplorer) FromStore(s store.NetExplorer)

FromStore loads the NetExplorer with the values read from store.

func (*NetExplorer) ScanTxs

func (n *NetExplorer) ScanTxs(txs []types.Trans) (r []types.Trans, err error)

ScanTxs detects if the To or From addresses are being monitored within the NetExplorer and if so, includes the transaction in the returned slice.

func (*NetExplorer) Start

func (n *NetExplorer) Start()

Start sets status to WORK.

func (*NetExplorer) Status

func (n *NetExplorer) Status() int

Status returns the current NetExplorer status.

func (*NetExplorer) Stop

func (n *NetExplorer) Stop()

Stop sets status to STOP.

func (*NetExplorer) ToStore

func (n *NetExplorer) ToStore() store.NetExplorer

ToStore returns a store.NetExplorer struct to be saved to store.

func (*NetExplorer) UpdateChain

func (n *NetExplorer) UpdateChain(hash string, maxBlocks int)

UpdateChain updates NetExplorer fields with new block hash.

Jump to

Keyboard shortcuts

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