Jelajahi Sumber

上线测试接口整对没有

skyfffire 2 tahun lalu
induk
melakukan
3f57525780
2 mengubah file dengan 11 tambahan dan 5 penghapusan
  1. 5 3
      arbitrage/history.go
  2. 6 2
      arbitrage/log.go

+ 5 - 3
arbitrage/history.go

@@ -12,6 +12,7 @@ type HistoryArbitrage struct {
 	ctx           *cli.Context
 	apiBackend    ethapi.Backend
 	blockChainApi *ethapi.BlockChainAPI
+	ethereumApi   *ethapi.EthereumAPI
 }
 
 func NewHistoryArbitrage(stack *node.Node, ctx *cli.Context, apiBackend ethapi.Backend) *HistoryArbitrage {
@@ -20,6 +21,7 @@ func NewHistoryArbitrage(stack *node.Node, ctx *cli.Context, apiBackend ethapi.B
 		ctx:           ctx,
 		apiBackend:    apiBackend,
 		blockChainApi: ethapi.NewBlockChainAPI(apiBackend),
+		ethereumApi:   ethapi.NewEthereumAPI(apiBackend),
 	}
 }
 
@@ -30,11 +32,11 @@ func (h HistoryArbitrage) Register() {
 
 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())
+		HistoryLog("Bot log",
+			"BlockNumber", h.blockChainApi.BlockNumber().String(),
+			"ChainID: ", h.blockChainApi.ChainId().ToInt())
 
 		time.Sleep(time.Second)
 	}

+ 6 - 2
arbitrage/log.go

@@ -1,7 +1,11 @@
 package arbitrage
 
-import "github.com/ethereum/go-ethereum/log"
+import (
+	"github.com/ethereum/go-ethereum/log"
+)
 
 func HistoryLog(msg string, ctx ...interface{}) {
-	log.Info("~~~~~~~~~~~~~~HistoryLog~~~~~~~~~~~~~~   ", msg, ctx)
+	head := "             [HistoryLog]                "
+
+	log.Info(head, msg, ctx)
 }