| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package arbitrage
- import (
- "github.com/ethereum/go-ethereum/internal/ethapi"
- "github.com/ethereum/go-ethereum/node"
- "github.com/urfave/cli/v2"
- "time"
- )
- type HistoryArbitrage struct {
- stack *node.Node
- ctx *cli.Context
- apiBackend ethapi.Backend
- blockChainApi *ethapi.BlockChainAPI
- }
- func NewHistoryArbitrage(stack *node.Node, ctx *cli.Context, apiBackend ethapi.Backend) *HistoryArbitrage {
- return &HistoryArbitrage{
- stack: stack,
- ctx: ctx,
- apiBackend: apiBackend,
- blockChainApi: ethapi.NewBlockChainAPI(apiBackend),
- }
- }
- func (h HistoryArbitrage) Register() {
- // 注册成节点生命周期
- h.stack.RegisterLifecycle(h)
- }
- func (h HistoryArbitrage) Start() error {
- HistoryLog("Hi, I am history arbitrage bot.")
- HistoryLog("api: ", h.blockChainApi)
- //time.Sleep(time.Second * 20)
- for {
- HistoryLog("BlockNumber: ", h.blockChainApi.BlockNumber(), "ChainID: ", h.blockChainApi.ChainId())
- time.Sleep(time.Second)
- }
- }
- func (h HistoryArbitrage) Stop() error {
- return nil
- }
|