crawler

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressEvent

type AddressEvent struct {
	EventType EventType
	Address   string
	ExtraData interface{}
	Utxos     []explorer.Utxo
}

func (AddressEvent) Type

func (a AddressEvent) Type() EventType

type AddressObservable

type AddressObservable struct {
	Address     string
	BlindingKey []byte
	ExtraData   interface{}
	// contains filtered or unexported fields
}

func (*AddressObservable) Key added in v0.4.4

func (a *AddressObservable) Key() string

func (*AddressObservable) Observe added in v0.4.4

func (a *AddressObservable) Observe(
	explorerSvc explorer.Service,
	errChan chan error,
	eventChan chan Event,
)

type CloseEvent added in v0.2.0

type CloseEvent struct{}

func (CloseEvent) Type added in v0.2.0

func (q CloseEvent) Type() EventType

type Event

type Event interface {
	Type() EventType
}

Event are emitted through a channel during observation.

type EventType

type EventType int
const (
	CloseSignal EventType = iota
	AddressUnspents
	TransactionConfirmed
	TransactionUnconfirmed
	OutpointsUnspent
	OutpointsSpentAndUnconfirmed
	OutpointsSpentAndConfirmed
)

func (EventType) String

func (et EventType) String() string

type Observable

type Observable interface {
	Observe(
		explorerSvc explorer.Service,
		errChan chan error,
		eventChan chan Event,
	)
	Key() string
}

Observable represent object that can be observe on the blockchain.

func NewAddressObservable added in v0.4.4

func NewAddressObservable(
	address string, blindKey []byte, extraData interface{},
) Observable

func NewOutpointsObservable added in v0.5.3

func NewOutpointsObservable(
	outpoints []Outpoint, extraData interface{},
) Observable

func NewTransactionObservable added in v0.4.4

func NewTransactionObservable(txid string, extraData interface{}) Observable

type ObservableHandler added in v0.5.3

type ObservableHandler struct {
	// contains filtered or unexported fields
}

func NewObservableHandler added in v0.5.3

func NewObservableHandler(
	observable Observable,
	explorerSvc explorer.Service,
	wg *sync.WaitGroup,
	interval time.Duration,
	eventChan chan Event,
	errChan chan error,
) *ObservableHandler

func (*ObservableHandler) Start added in v0.5.3

func (oh *ObservableHandler) Start()

func (ObservableHandler) Stop added in v0.5.3

func (oh ObservableHandler) Stop()

type Opts

type Opts struct {
	ExplorerSvc explorer.Service
	// Crawler interval in milliseconds
	CrawlerInterval time.Duration
	ErrorHandler    func(err error)
}

Opts defines the parameters needed for creating a crawler service with NewService method

type Outpoint added in v0.5.3

type Outpoint interface {
	Hash() string
	Index() uint32
}

type OutpointsEvent added in v0.5.3

type OutpointsEvent struct {
	EventType EventType
	Outpoints []Outpoint
	ExtraData interface{}
	TxID      string
	TxHex     string
	BlockHash string
	BlockTime int
}

func (OutpointsEvent) Type added in v0.5.3

func (o OutpointsEvent) Type() EventType

type OutpointsObservable added in v0.5.3

type OutpointsObservable struct {
	Outpoints []Outpoint
	ExtraData interface{}
	// contains filtered or unexported fields
}

func (*OutpointsObservable) Key added in v0.5.3

func (o *OutpointsObservable) Key() string

func (*OutpointsObservable) Observe added in v0.5.3

func (o *OutpointsObservable) Observe(
	explorerSvc explorer.Service,
	errChan chan error,
	eventChan chan Event,
)

type Service

type Service interface {
	Start()
	Stop()
	AddObservable(observable Observable)
	RemoveObservable(observable Observable)
	GetEventChannel() chan Event
}

Service is the interface for Crawler

func NewService

func NewService(opts Opts) Service

NewService returns an utxoCrawelr that is ready for watch for blockchain activites. Use Start and Stop methods to manage it.

type TransactionEvent

type TransactionEvent struct {
	TxID      string
	TxHex     string
	EventType EventType
	BlockHash string
	BlockTime int
	ExtraData interface{}
}

func (TransactionEvent) Type

func (t TransactionEvent) Type() EventType

type TransactionObservable

type TransactionObservable struct {
	TxID      string
	TxHex     string
	ExtraData interface{}
	// contains filtered or unexported fields
}

func (*TransactionObservable) Key added in v0.4.4

func (t *TransactionObservable) Key() string

func (*TransactionObservable) Observe added in v0.4.4

func (t *TransactionObservable) Observe(
	explorerSvc explorer.Service,
	errChan chan error,
	eventChan chan Event,
)

Jump to

Keyboard shortcuts

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