Documentation ¶
Index ¶
- Variables
- func SetLogger(logger *logger.Logger)
- type Blockchain
- func (bc *Blockchain) ClientByNetwork() *EthClient
- func (bc *Blockchain) Close()
- func (bc *Blockchain) ContractByID(id string) *Contract
- func (bc *Blockchain) Init() error
- func (bc *Blockchain) MonitorMeta() *MonitorInfo
- func (bc *Blockchain) RunMonitor() error
- func (bc *Blockchain) SetDefault()
- func (bc *Blockchain) Watch(options *WatchOptions, h EventHandler) (Subscription, error)
- type Contract
- type EthClient
- type Event
- type EventHandler
- type Meta
- func (m *Meta) BlockKeyPrefixLowerBound(blk uint64) []byte
- func (m *Meta) BlockKeyPrefixUpperBound(blk uint64) []byte
- func (m *Meta) LogKey(l *types.Log) []byte
- func (m *Meta) MonitorRangeEndKey() []byte
- func (m *Meta) MonitorRangeFromKey() []byte
- func (m *Meta) ParseLogKey(key string) (*Contract, string, error)
- func (m *Meta) String() string
- func (m *Meta) WatcherRangeEndKey(sub string) []byte
- func (m *Meta) WatcherRangeFromKey(sub string) []byte
- type Monitor
- func (m *Monitor) CurrentBlock() uint64
- func (m *Monitor) Endpoint() string
- func (m *Monitor) Init() error
- func (m *Monitor) StartAt() uint64
- func (m *Monitor) Stop()
- func (m *Monitor) Watch(opts *WatchOptions, h EventHandler) (Subscription, error)
- func (m *Monitor) WatchList() []string
- func (m *Monitor) WithEthClient(c MonitorClient) *Monitor
- func (m *Monitor) WithInterval(d time.Duration) *Monitor
- func (m *Monitor) WithPersistence(p TxPersistence) *Monitor
- func (m *Monitor) WithStartBlock(from uint64) *Monitor
- type MonitorClient
- type MonitorInfo
- type Network
- type PebbleKVStore
- type Persist
- func (p *Persist) BatchSet(kvs ...[2][]byte) (err error)
- func (p *Persist) Close() error
- func (p *Persist) DB() *pebble.DB
- func (p *Persist) Delete(k []byte) error
- func (p *Persist) GetUint64(k []byte) (uint64, error)
- func (p *Persist) Init() error
- func (p *Persist) InsertLogs(meta Meta, logs ...*types.Log) error
- func (p *Persist) IsZero() bool
- func (p *Persist) Keys(prefix []byte) ([][]byte, error)
- func (p *Persist) Load(k []byte) ([]byte, error)
- func (p *Persist) LoadAndDelete(k []byte) (v []byte, loaded bool, err error)
- func (p *Persist) LoadJSONValue(k []byte, v any) error
- func (p *Persist) LoadOrStore(k, v []byte) (actual []byte, loaded bool, err error)
- func (p *Persist) LoadTextValue(k []byte, v any) error
- func (p *Persist) MonitorRange(meta Meta) (from uint64, end uint64, err error)
- func (p *Persist) QueryTxByHeightRange(meta Meta, from, to uint64) ([]*result, error)
- func (p *Persist) RemoveWatcher(meta Meta, id string) error
- func (p *Persist) SetUint64(k []byte, v uint64) error
- func (p *Persist) Store(k, v []byte) error
- func (p *Persist) StoreJSONValue(k []byte, v any) error
- func (p *Persist) StoreTextValue(k []byte, v any) error
- func (p *Persist) UpdateMonitorRange(meta Meta, from, end uint64) error
- func (p *Persist) UpdateWatcherRange(meta Meta, id string, from, end uint64) error
- func (p *Persist) WatcherRange(meta Meta, id string) (uint64, uint64, error)
- type Subscription
- type TxPersistence
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var InvalidNetwork = errors.New("invalid Network type")
Functions ¶
Types ¶
type Blockchain ¶
type Blockchain struct { Clients []*EthClient Contracts []*Contract Network Network PersistPath string // contains filtered or unexported fields }
func (*Blockchain) ClientByNetwork ¶
func (bc *Blockchain) ClientByNetwork() *EthClient
func (*Blockchain) Close ¶
func (bc *Blockchain) Close()
func (*Blockchain) ContractByID ¶
func (bc *Blockchain) ContractByID(id string) *Contract
func (*Blockchain) Init ¶
func (bc *Blockchain) Init() error
func (*Blockchain) MonitorMeta ¶ added in v0.1.7
func (bc *Blockchain) MonitorMeta() *MonitorInfo
func (*Blockchain) RunMonitor ¶ added in v0.1.7
func (bc *Blockchain) RunMonitor() error
func (*Blockchain) SetDefault ¶
func (bc *Blockchain) SetDefault()
func (*Blockchain) Watch ¶ added in v0.1.7
func (bc *Blockchain) Watch(options *WatchOptions, h EventHandler) (Subscription, error)
type Contract ¶
type Contract struct { // ID human readable identifier in configuration ID string // Network deployed network Network Network // Address contract address Address common.Address // Events care about Events []*Event // contains filtered or unexported fields }
func (*Contract) ParseTxLog ¶
type EthClient ¶
type EthClient struct { Endpoint string Network Network *ethclient.Client `evn:"-"` // contains filtered or unexported fields }
func (*EthClient) ChainEndpoint ¶
type EventHandler ¶ added in v0.1.2
type EventHandler func(Subscription, *Contract, string, *types.Log)
type Meta ¶
type Meta struct { ID string `json:"id"` Network Network `json:"network"` Contracts []common.Address `json:"contracts"` Topics [][]common.Hash `json:"topics"` // contains filtered or unexported fields }
func (*Meta) BlockKeyPrefixLowerBound ¶ added in v0.1.2
func (*Meta) BlockKeyPrefixUpperBound ¶ added in v0.1.2
func (*Meta) MonitorRangeEndKey ¶ added in v0.1.7
func (*Meta) MonitorRangeFromKey ¶ added in v0.1.7
func (*Meta) ParseLogKey ¶ added in v0.1.7
func (*Meta) WatcherRangeEndKey ¶ added in v0.1.7
func (*Meta) WatcherRangeFromKey ¶ added in v0.1.7
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
func NewMonitor ¶ added in v0.1.7
func (*Monitor) CurrentBlock ¶
func (*Monitor) Watch ¶
func (m *Monitor) Watch(opts *WatchOptions, h EventHandler) (Subscription, error)
func (*Monitor) WithEthClient ¶
func (m *Monitor) WithEthClient(c MonitorClient) *Monitor
func (*Monitor) WithInterval ¶ added in v0.1.2
func (*Monitor) WithPersistence ¶
func (m *Monitor) WithPersistence(p TxPersistence) *Monitor
func (*Monitor) WithStartBlock ¶ added in v0.1.2
type MonitorClient ¶
type MonitorInfo ¶
type MonitorInfo struct { Contracts map[string]struct { Address common.Address `json:"address"` Events map[string]common.Hash `json:"events"` } `json:"contracts"` From uint64 `json:"from"` End uint64 `json:"end"` Watchers []*struct { Sub string `json:"sub"` From uint64 `json:"from"` End uint64 `json:"end"` } `json:"watchers"` }
type Network ¶
type Network int
func ParseNetworkFromString ¶
func (Network) MarshalText ¶
func (*Network) UnmarshalText ¶
type PebbleKVStore ¶
type Persist ¶
type Persist struct { Path string // contains filtered or unexported fields }
func (*Persist) LoadAndDelete ¶
func (*Persist) LoadOrStore ¶
func (*Persist) MonitorRange ¶ added in v0.1.7
func (*Persist) QueryTxByHeightRange ¶
QueryTxByHeightRange query tx logs the block number between from and to [from,to]
func (*Persist) RemoveWatcher ¶ added in v0.1.2
func (*Persist) UpdateMonitorRange ¶ added in v0.1.7
func (*Persist) UpdateWatcherRange ¶ added in v0.1.7
type Subscription ¶
type TxPersistence ¶
type TxPersistence interface { // MonitorRange query persisted monitor range MonitorRange(Meta) (uint64, uint64, error) // UpdateMonitorRange update persisted monitor range UpdateMonitorRange(Meta, uint64, uint64) error // QueryWatcher query watcher state by meta id and subscriber id WatcherRange(Meta, string) (uint64, uint64, error) // UpdateWatcher update watcher state UpdateWatcherRange(Meta, string, uint64, uint64) error // RemoveWatcher remove watcher state RemoveWatcher(Meta, string) error // QueryTxByHeightRange query tx logs by blockchain meta and block number range QueryTxByHeightRange(Meta, uint64, uint64) ([]*result, error) // InsertLogs insert tx logs with blockchain meta InsertLogs(Meta, ...*types.Log) error // Close Close() error }
type WatchOptions ¶
Click to show internal directories.
Click to hide internal directories.