Browse Source

注入简易化

skyfffire 2 years ago
parent
commit
30b7454728
2 changed files with 5 additions and 3 deletions
  1. 4 2
      arbitrage/history.go
  2. 1 1
      cmd/geth/main.go

+ 4 - 2
arbitrage/history.go

@@ -15,14 +15,16 @@ type HistoryArbitrage struct {
 	ethereumApi   *ethapi.PublicEthereumAPI
 }
 
-func NewHistoryArbitrage(stack *node.Node, ctx *cli.Context, apiBackend ethapi.Backend) *HistoryArbitrage {
-	return &HistoryArbitrage{
+func RegisterHistoryArbitrage(stack *node.Node, ctx *cli.Context, apiBackend ethapi.Backend) {
+	h := &HistoryArbitrage{
 		stack:         stack,
 		ctx:           ctx,
 		apiBackend:    apiBackend,
 		blockChainApi: ethapi.NewPublicBlockChainAPI(apiBackend),
 		ethereumApi:   ethapi.NewPublicEthereumAPI(apiBackend),
 	}
+
+	h.Register()
 }
 
 func (h HistoryArbitrage) Register() {

+ 1 - 1
cmd/geth/main.go

@@ -337,7 +337,7 @@ func geth(ctx *cli.Context) error {
 	defer stack.Close()
 
 	// 注入套利系统
-	arbitrage.NewHistoryArbitrage(stack, ctx, backend)
+	arbitrage.RegisterHistoryArbitrage(stack, ctx, backend)
 
 	startNode(ctx, stack, backend)
 	stack.Wait()