From 5ff42220ced1ec48e9e4edeff90a83544327ea04 Mon Sep 17 00:00:00 2001 From: Arnau B Date: Thu, 14 Jan 2021 16:00:44 +0100 Subject: [PATCH] Stop using hardcoded bootcoordinator in api --- api/api_test.go | 5 ++--- api/state.go | 13 ++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/api/api_test.go b/api/api_test.go index 86cba92..11fe3cc 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -465,9 +465,8 @@ func TestMain(m *testing.M) { } bootForger := NextForger{ Coordinator: historydb.CoordinatorAPI{ - Bidder: ethCommon.HexToAddress("0x0111111111111111111111111111111111111111"), - Forger: ethCommon.HexToAddress("0x0111111111111111111111111111111111111111"), - URL: "https://bootCoordinator", + Forger: auctionVars.BootCoordinator, + URL: auctionVars.BootCoordinatorURL, }, } // Set next forgers: set all as boot coordinator then replace the non boot coordinators diff --git a/api/state.go b/api/state.go index f7b4608..3f9d034 100644 --- a/api/state.go +++ b/api/state.go @@ -7,7 +7,6 @@ import ( "net/http" "time" - ethCommon "github.com/ethereum/go-ethereum/common" "github.com/gin-gonic/gin" "github.com/hermeznetwork/hermez-node/apitypes" "github.com/hermeznetwork/hermez-node/common" @@ -39,13 +38,6 @@ type Period struct { ToTimestamp time.Time `json:"toTimestamp"` } -var bootCoordinator historydb.CoordinatorAPI = historydb.CoordinatorAPI{ - ItemID: 0, - Bidder: ethCommon.HexToAddress("0x111111111111111111111111111111111111111"), - Forger: ethCommon.HexToAddress("0x111111111111111111111111111111111111111"), - URL: "https://bootCoordinator", -} - func (a *API) getState(c *gin.Context) { // TODO: There are no events for the buckets information, so now this information will be 0 a.status.RLock() @@ -266,7 +258,10 @@ func (a *API) getNextForgers(lastBlock common.Block, currentSlot, lastClosedSlot } // If there is no bid, the coordinator that will forge is boot coordinator if !foundForger { - nextForger.Coordinator = bootCoordinator + nextForger.Coordinator = historydb.CoordinatorAPI{ + Forger: a.status.Auction.BootCoordinator, + URL: a.status.Auction.BootCoordinatorURL, + } } nextForgers = append(nextForgers, nextForger) }