Documentation
¶
Index ¶
- Variables
- func RegisterCacher(name string, cacherF OrderCacherF)
- func RegisterNotifier(name string, notifier NotifierF)
- func RegisterSensor(name string, sensors CoreF)
- func RegisterStorage(name string, cacherF OrderStorageF)
- type CoreF
- type Notifier
- type NotifierF
- type NotifierFunc
- type Option
- type Order
- type OrderCacher
- type OrderCacherF
- type OrderStorage
- type OrderStorageF
- type Plugin
- type Sensor
- type Status
- type Watcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrVersion = errors.New("order version error") ErrWatcherExists = errors.New("watcher exists") )
Errors
View Source
var ( StatusCreated = Status("CREATED") StatusPending = Status("PENDING") StatusRunning = Status("RUNNING") StatusSucceed = Status("SUCCEED") StatusFailed = Status("FAILED") StatusCanceled = Status("CANCELED") )
Status .
Functions ¶
Types ¶
type Notifier ¶
type Notifier interface {
// notify order status changed
Notify(receiver *Watcher, order *Order) error
}
Notifier the eth tx event notifier
type NotifierFunc ¶
NotifierFunc .
type Order ¶
type Order struct {
ID string `xorm:"pk"`
TX string `xorm:"unique"`
PendingBlock int64 `xorm:""`
CommitBlock int64 `xorm:""`
ConfirmBlock int64 `xorm:""`
Status Status `xorm:"index"`
CreateTime time.Time `xorm:"created"`
PendingTime time.Time `xorm:""`
CommitTime time.Time `xorm:""`
ConfirmTime time.Time `xorm:""`
From string `xorm:"index"`
To string `xorm:"index"`
Value string `xorm:"default('0x0')"`
Code string `xorm:""`
GasLimits string `xorm:""`
GasPrice string `xorm:""`
}
Order the eth tx order
type OrderCacher ¶
type OrderCacher interface {
Cache([]*Order) // load unconfirmed orders
Mint(tx string, block int64, time time.Time) (*Order, bool) // mint cached order with tx string
Confirm(block int64, time time.Time) (timeout []*Order, confirmed []*Order) // confirm orders
Pending() (*Order, bool) // pending order number
Pend(order *Order)
}
OrderCacher .
type OrderCacherF ¶
type OrderCacherF func(config config.Config) (OrderCacher, error)
OrderCacherF OrderCacher factory
type OrderStorage ¶
type OrderStorage interface {
Save(order *Order) error
Update(order *Order) error
Unconfirmed() ([]*Order, error)
}
OrderStorage .
type OrderStorageF ¶
type OrderStorageF func(config config.Config) (OrderStorage, error)
OrderStorageF OrderStorage factory
type Plugin ¶
type Plugin struct {
slf4go.Logger
NotifierCreator NotifierF
OrderStorageCreator OrderStorageF
OrderCacherCreator OrderCacherF
// contains filtered or unexported fields
}
Plugin sensors plugin object
type Sensor ¶
type Sensor interface {
// create a new watcher with config
New(watcher *Watcher) (id string, err error)
// delete watcher by watcher key
Delete(key string) (err error)
// list the register watcher
List(page orm.Page) ([]*Watcher, int64, error)
}
Sensor The eth tx detect service
type Watcher ¶
type Watcher struct {
ID string `xorm:"pk"` // watcher id
Name string `xorm:"index"` // watcher name
Key string `xorm:"unique"` // watcher unique key provider by notifier
Address string `xorm:"unique(address_erc20)"` // watched address
ERC20 bool `xorm:"unique(address_erc20)"` // true if the target address is a erc20 contract address
}
Watcher the eth event watcher managed by sensors
Click to show internal directories.
Click to hide internal directories.