changed leftover files from log15 to zerolog

pull/1279/head
Priya Ganguly 5 years ago
parent 594c940aa5
commit 9c52d313fb
  1. 28
      node/contract.go
  2. 23
      node/node.go
  3. 28
      node/node_explorer.go
  4. 2
      node/node_genesis.go
  5. 50
      node/node_syncing.go
  6. 12
      node/rpc.go
  7. 4
      node/service_setup.go
  8. 18
      node/staking.go

@ -74,12 +74,12 @@ func (node *Node) generateDeployedStakingContractAddress(contractAddress common.
func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue {
abi, err := abi.JSON(strings.NewReader(contracts.StakeLockContractABI))
if err != nil {
utils.GetLogInstance().Error("Failed to generate staking contract's ABI", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to generate staking contract's ABI")
return nil
}
bytesData, err := abi.Pack("listLockedAddresses")
if err != nil {
utils.GetLogInstance().Error("Failed to generate ABI function bytes data", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to generate ABI function bytes data")
return nil
}
@ -89,7 +89,7 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue {
state, err := node.Blockchain().State()
if err != nil {
utils.GetLogInstance().Error("Failed to get blockchain state", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to get blockchain state")
return nil
}
@ -105,13 +105,13 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue {
)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, priKey)
if err != nil {
utils.GetLogInstance().Error("Failed to sign contract call tx", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to sign contract call tx")
return nil
}
output, err := node.ContractCaller.CallContract(signedTx)
if err != nil {
utils.GetLogInstance().Error("Failed to call staking contract", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to call staking contract")
return nil
}
@ -120,7 +120,7 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue {
err = abi.Unpack(ret, "listLockedAddresses", output)
if err != nil {
utils.GetLogInstance().Error("Failed to unpack stake info", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to unpack stake info")
return nil
}
return ret
@ -137,7 +137,7 @@ func (node *Node) getDeployedStakingContract() common.Address {
func (node *Node) GetNonceOfAddress(address common.Address) uint64 {
state, err := node.Blockchain().State()
if err != nil {
utils.GetLogger().Error("Failed to get chain state", "Error", err)
utils.Logger().Error().Err(err).Msg("Failed to get chain state")
return 0
}
return state.GetNonce(address)
@ -147,7 +147,7 @@ func (node *Node) GetNonceOfAddress(address common.Address) uint64 {
func (node *Node) GetBalanceOfAddress(address common.Address) (*big.Int, error) {
state, err := node.Blockchain().State()
if err != nil {
utils.GetLogger().Error("Failed to get chain state", "Error", err)
utils.Logger().Error().Err(err).Msg("Failed to get chain state")
return nil, err
}
return state.GetBalance(address), nil
@ -178,7 +178,7 @@ func (node *Node) CallFaucetContract(address common.Address) common.Hash {
// Temporary code to workaround explorer issue for searching new addresses (https://github.com/harmony-one/harmony/issues/503)
nonce := atomic.AddUint64(&node.ContractDeployerCurrentNonce, 1)
tx, _ := types.SignTx(types.NewTransaction(nonce-1, address, node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, nil), types.HomesteadSigner{}, node.ContractDeployerKey)
utils.GetLogInstance().Info("Sending placeholder token to ", "Address", common2.MustAddressToBech32(address))
utils.Logger().Info().Str("Address", common2.MustAddressToBech32(address))("Sending placeholder token to ")
node.addPendingTransactions(types.Transactions{tx})
// END Temporary code
@ -194,20 +194,20 @@ func (node *Node) callGetFreeToken(address common.Address) common.Hash {
func (node *Node) callGetFreeTokenWithNonce(address common.Address, nonce uint64) common.Hash {
abi, err := abi.JSON(strings.NewReader(contracts.FaucetABI))
if err != nil {
utils.GetLogInstance().Error("Failed to generate faucet contract's ABI", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to generate faucet contract's ABI")
return common.Hash{}
}
bytesData, err := abi.Pack("request", address)
if err != nil {
utils.GetLogInstance().Error("Failed to generate ABI function bytes data", "error", err)
utils.Logger().Error().Err(err).Msg("Failed to generate ABI function bytes data")
return common.Hash{}
}
if len(node.ContractAddresses) == 0 {
utils.GetLogInstance().Error("Failed to find the contract address")
utils.Logger().Error().Err(err).Msg("Failed to find the contract address")
return common.Hash{}
}
tx, _ := types.SignTx(types.NewTransaction(nonce, node.ContractAddresses[0], node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, bytesData), types.HomesteadSigner{}, node.ContractDeployerKey)
utils.GetLogInstance().Info("Sending Free Token to ", "Address", common2.MustAddressToBech32(address))
utils.Logger().Info().Str("Address", common2.MustAddressToBech32(address)).Msg("Sending Free Token to ")
node.addPendingTransactions(types.Transactions{tx})
return tx.Hash()
@ -228,6 +228,6 @@ func (node *Node) AddContractKeyAndAddress(t builtInSC) {
stakingPrivKey := genesis.GenesisBeaconAccountPriKey
node.StakingContractAddress = crypto.CreateAddress(crypto.PubkeyToAddress(stakingPrivKey.PublicKey), uint64(0))
default:
utils.GetLogInstance().Error("AddContractKeyAndAddress", "unknown SC", t)
utils.Logger().Error().Err(err).Str("unknown SC", t)("AddContractKeyAndAddress")
}
}

@ -236,7 +236,7 @@ func (node *Node) addPendingTransactions(newTxs types.Transactions) {
node.pendingTransactions = append(node.pendingTransactions, newTxs...)
node.reducePendingTransactions()
node.pendingTxMutex.Unlock()
utils.GetLogInstance().Info("Got more transactions", "num", len(newTxs), "totalPending", len(node.pendingTransactions))
utils.Logger().Info().Int("num", len(newTxs)).Int("totalPending", len(node.pendingTransactions)).Msg("Got more transactions")
}
}
@ -244,7 +244,7 @@ func (node *Node) addPendingTransactions(newTxs types.Transactions) {
func (node *Node) AddPendingTransaction(newTx *types.Transaction) {
if node.NodeConfig.GetNetworkType() != nodeconfig.Mainnet {
node.addPendingTransactions(types.Transactions{newTx})
utils.GetLogInstance().Debug("Got ONE more transaction", "totalPending", len(node.pendingTransactions))
utils.Logger().Error().Err(err).Int("totalPending", len(node.pendingTransactions)).Msg("Got ONE more transaction")
}
}
@ -259,7 +259,11 @@ func (node *Node) getTransactionsForNewBlock(maxNumTxs int, coinbase common.Addr
node.pendingTransactions = unselected
node.reducePendingTransactions()
utils.GetLogInstance().Debug("Selecting Transactions", "remainPending", len(node.pendingTransactions), "selected", len(selected), "invalidDiscarded", len(invalid))
utils.Logger().Error().Err(err).
Int("remainPending", len(node.pendingTransactions)).
Int("selected", len(selected)).
Int("invalidDiscarded", len(invalid)).
Msg("Selecting Transactions")
node.pendingTxMutex.Unlock()
return selected
}
@ -360,13 +364,12 @@ func New(host p2p.Host, consensusObj *consensus.Consensus, chainDBFactory shardc
var err error
node.TestBankKeys, err = CreateTestBankKeys(TestAccountNumber)
if err != nil {
utils.GetLogInstance().Crit("Error while creating test keys",
"error", err)
utils.Logger().Error().Err(err).Msg("Error while creating test keys")
}
}
}
utils.GetLogInstance().Info("Genesis block hash", "genesis block header", node.Blockchain().GetBlockByNumber(0).Header())
utils.Logger().Info().Str("genesis block header", node.Blockchain().GetBlockByNumber(0).Header()).Msg("Genesis block hash")
// start the goroutine to receive client message
// client messages are sent by clients, like txgen, wallet
@ -481,17 +484,17 @@ func (node *Node) initNodeConfiguration() (service.NodeConfig, chan p2p.Peer) {
var err error
node.shardGroupReceiver, err = node.host.GroupReceiver(node.NodeConfig.GetShardGroupID())
if err != nil {
utils.GetLogInstance().Error("Failed to create shard receiver", "msg", err)
utils.Logger().Error().Err(err).Msg("Failed to create shard receiver")
}
node.globalGroupReceiver, err = node.host.GroupReceiver(p2p.GroupIDBeaconClient)
if err != nil {
utils.GetLogInstance().Error("Failed to create global receiver", "msg", err)
utils.Logger().Error().Err(err).Msg("Failed to create global receiver")
}
node.clientReceiver, err = node.host.GroupReceiver(node.NodeConfig.GetClientGroupID())
if err != nil {
utils.GetLogInstance().Error("Failed to create client receiver", "msg", err)
utils.Logger().Error().Err(err).Msg("Failed to create client receiver")
}
return nodeConfig, chanPeer
}
@ -503,6 +506,6 @@ func (node *Node) AccountManager() *accounts.Manager {
// SetDNSZone sets the DNS zone to use to get peer info for node syncing
func (node *Node) SetDNSZone(zone string) {
utils.GetLogger().Info("using DNS zone to get peers", "zone", zone)
utils.Logger().Info().Str("zone", zone).Msg("using DNS zone to get peers")
node.dnsZone = zone
}

@ -18,32 +18,32 @@ var once sync.Once
// ExplorerMessageHandler passes received message in node_handler to explorer service
func (node *Node) ExplorerMessageHandler(payload []byte) {
if len(payload) == 0 {
utils.GetLogger().Debug("Payload is empty")
utils.Logger().Error().Err(err).Msg("Payload is empty")
return
}
msg := &msg_pb.Message{}
err := protobuf.Unmarshal(payload, msg)
if err != nil {
utils.GetLogger().Error("Failed to unmarshal message payload.", "err", err)
utils.Logger().Error().Err(err).Msg("Failed to unmarshal message payload.")
return
}
if msg.Type == msg_pb.MessageType_COMMITTED {
recvMsg, err := consensus.ParsePbftMessage(msg)
if err != nil {
utils.GetLogInstance().Debug("[Explorer] onCommitted unable to parse msg", "error", err)
utils.Logger().Error().Err(err).Msg("[Explorer] onCommitted unable to parse msg")
return
}
aggSig, mask, err := node.Consensus.ReadSignatureBitmapPayload(recvMsg.Payload, 0)
if err != nil {
utils.GetLogInstance().Debug("[Explorer] readSignatureBitmapPayload failed", "error", err)
utils.Logger().Error().Err(err).Msg("[Explorer] readSignatureBitmapPayload failed")
return
}
// check has 2f+1 signatures
if count := utils.CountOneBits(mask.Bitmap); count < node.Consensus.Quorum() {
utils.GetLogInstance().Debug("[Explorer] not have enough signature", "need", node.Consensus.Quorum(), "have", count)
utils.Logger().Error().Err(err).Str("need", node.Consensus.Quorum()).Str("have", count)("[Explorer] not have enough signature")
return
}
@ -51,14 +51,14 @@ func (node *Node) ExplorerMessageHandler(payload []byte) {
binary.LittleEndian.PutUint64(blockNumHash, recvMsg.BlockNum)
commitPayload := append(blockNumHash, recvMsg.BlockHash[:]...)
if !aggSig.VerifyHash(mask.AggregatePublic, commitPayload) {
utils.GetLogInstance().Debug("[Explorer] Failed to verify the multi signature for commit phase", "msgBlock", recvMsg.BlockNum)
utils.Logger().Error().Err(err).Str("msgBlock", recvMsg.BlockNum).Msg("[Explorer] Failed to verify the multi signature for commit phase")
return
}
block := node.Consensus.PbftLog.GetBlockByHash(recvMsg.BlockHash)
if block == nil {
utils.GetLogInstance().Info("[Explorer] Haven't received the block before the committed msg", "msgBlock", recvMsg.BlockNum)
utils.Logger().Info().Str("msgBlock", recvMsg.BlockNum).Msg("[Explorer] Haven't received the block before the committed msg")
node.Consensus.PbftLog.AddMessage(recvMsg)
return
}
@ -69,7 +69,7 @@ func (node *Node) ExplorerMessageHandler(payload []byte) {
recvMsg, err := consensus.ParsePbftMessage(msg)
if err != nil {
utils.GetLogInstance().Debug("[Explorer] Unable to parse Prepared msg", "error", err)
utils.Logger().Error().Err(err).Msg("[Explorer] Unable to parse Prepared msg")
return
}
block := recvMsg.Block
@ -91,7 +91,7 @@ func (node *Node) ExplorerMessageHandler(payload []byte) {
// AddNewBlockForExplorer add new block for explorer.
func (node *Node) AddNewBlockForExplorer() {
utils.GetLogInstance().Info("[Explorer] Add new block for explorer")
utils.Logger().Info().Msg("[Explorer] Add new block for explorer")
// Search for the next block in PbftLog and commit the block into blockchain for explorer node.
for {
blocks := node.Consensus.PbftLog.GetBlocksByNumber(node.Blockchain().CurrentBlock().NumberU64() + 1)
@ -99,9 +99,9 @@ func (node *Node) AddNewBlockForExplorer() {
break
} else {
if len(blocks) > 1 {
utils.GetLogInstance().Error("[Explorer] We should have not received more than one block with the same block height.")
utils.Logger().Error().Err(err).Msg("[Explorer] We should have not received more than one block with the same block height.")
}
utils.GetLogInstance().Info("Adding new block for explorer node", "blockHeight", blocks[0].NumberU64())
utils.Logger().Info().Uint64("blockHeight", blocks[0].NumberU64()).Msg("Adding new block for explorer node")
if err := node.AddNewBlock(blocks[0]); err == nil {
// Clean up the blocks to avoid OOM.
node.Consensus.PbftLog.DeleteBlockByNumber(blocks[0].NumberU64())
@ -109,7 +109,7 @@ func (node *Node) AddNewBlockForExplorer() {
// TODO: some blocks can be dumped before state syncing finished.
// And they would be dumped again here. Please fix it.
once.Do(func() {
utils.GetLogInstance().Info("[Explorer] Populating explorer data from state synced blocks", "starting height", int64(blocks[0].NumberU64())-1)
utils.Logger().Info().Uint64("starting height", int64(blocks[0].NumberU64())-1).Msg("[Explorer] Populating explorer data from state synced blocks")
go func() {
for blockHeight := int64(blocks[0].NumberU64()) - 1; blockHeight >= 0; blockHeight-- {
explorer.GetStorageInstance(node.SelfPeer.IP, node.SelfPeer.Port, true).Dump(
@ -118,7 +118,7 @@ func (node *Node) AddNewBlockForExplorer() {
}()
})
} else {
utils.GetLogInstance().Error("[Explorer] Error when adding new block for explorer node", "error", err)
utils.Logger().Error().Err(err).Msg("[Explorer] Error when adding new block for explorer node")
}
}
}
@ -130,7 +130,7 @@ func (node *Node) commitBlockForExplorer(block *types.Block) {
return
}
// Dump new block into level db.
utils.GetLogInstance().Info("[Explorer] Committing block into explorer DB", "blockNum", block.NumberU64())
utils.Logger().Info().Uint64("blockNum", block.NumberU64()).Msg("[Explorer] Committing block into explorer DB")
explorer.GetStorageInstance(node.SelfPeer.IP, node.SelfPeer.Port, true).Dump(block, block.NumberU64())
curNum := block.NumberU64()

@ -55,7 +55,7 @@ func (gi *genesisInitializer) InitChainDB(db ethdb.Database, shardID uint32) err
// SetupGenesisBlock sets up a genesis blockchain.
func (node *Node) SetupGenesisBlock(db ethdb.Database, shardID uint32, myShardState types.ShardState) {
utils.GetLogger().Info("setting up a brand new chain database",
utils.Logger().Info().Msg("setting up a brand new chain database",
"shardID", shardID)
if shardID == node.NodeConfig.ShardID {
node.isFirstTime = true

@ -78,7 +78,7 @@ func (node *Node) GetPeersFromDNS() []p2p.Peer {
dns := fmt.Sprintf("s%d.%s", shardID, node.dnsZone)
addrs, err := net.LookupHost(dns)
if err != nil {
utils.GetLogInstance().Debug("[SYNC] GetPeersFromDNS cannot find peers", "error", err)
utils.Logger().Debug().Msg("[SYNC] GetPeersFromDNS cannot find peers")
return nil
}
port := syncing.GetSyncingPort(node.SelfPeer.Port)
@ -114,7 +114,7 @@ func (node *Node) DoBeaconSyncing() {
func (node *Node) DoSyncing(bc *core.BlockChain, worker *worker.Worker, getPeers func() []p2p.Peer, willJoinConsensus bool) {
ticker := time.NewTicker(SyncFrequency * time.Second)
logger := utils.GetLogInstance()
logger := utils.Logger()
getLogger := func() log.Logger { return utils.WithCallerSkip(logger, 1) }
SyncingLoop:
for {
@ -123,15 +123,15 @@ SyncingLoop:
if node.stateSync == nil {
node.stateSync = syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, node.GetSyncID())
logger = logger.New("syncID", node.GetSyncID())
getLogger().Debug("[SYNC] initialized state sync")
Logger().Debug().Msg("[SYNC] initialized state sync")
}
if node.stateSync.GetActivePeerNumber() < MinConnectedPeers {
peers := getPeers()
if err := node.stateSync.CreateSyncConfig(peers, false); err != nil {
getLogger().Debug("[SYNC] create peers error", "error", err)
Logger().Debug().Msg("[SYNC] create peers error")
continue SyncingLoop
}
getLogger().Debug("[SYNC] Get Active Peers", "len", node.stateSync.GetActivePeerNumber())
Logger().Debug().Int("len", node.stateSync.GetActivePeerNumber()).Msg("[SYNC] Get Active Peers")
}
if node.stateSync.IsOutOfSync(bc) {
node.stateMutex.Lock()
@ -192,7 +192,7 @@ func (node *Node) InitSyncingServer() {
// StartSyncingServer starts syncing server.
func (node *Node) StartSyncingServer() {
utils.GetLogInstance().Info("[SYNC] support_syncing: StartSyncingServer")
utils.Logger().Info().Msg("[SYNC] support_syncing: StartSyncingServer")
if node.downloaderServer.GrpcServer == nil {
node.downloaderServer.Start(node.SelfPeer.IP, syncing.GetSyncingPort(node.SelfPeer.Port))
}
@ -204,7 +204,7 @@ func (node *Node) SendNewBlockToUnsync() {
block := <-node.Consensus.VerifiedNewBlock
blockHash, err := rlp.EncodeToBytes(block)
if err != nil {
utils.GetLogInstance().Warn("[SYNC] unable to encode block to hashes")
utils.Logger().Warn().Msg("[SYNC] unable to encode block to hashes")
continue
}
@ -212,7 +212,7 @@ func (node *Node) SendNewBlockToUnsync() {
for peerID, config := range node.peerRegistrationRecord {
elapseTime := time.Now().UnixNano() - config.timestamp
if elapseTime > broadcastTimeout {
utils.GetLogInstance().Warn("[SYNC] SendNewBlockToUnsync to peer timeout", "peerID", peerID)
utils.Logger().Warn().Str("peerID", peerID).Msg("[SYNC] SendNewBlockToUnsync to peer timeout")
node.peerRegistrationRecord[peerID].client.Close()
delete(node.peerRegistrationRecord, peerID)
continue
@ -248,7 +248,14 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
startHeight := startBlock.NumberU64()
endHeight := node.Blockchain().CurrentBlock().NumberU64()
if startHeight >= endHeight {
utils.GetLogInstance().Debug("[SYNC] GetBlockHashes Request: I am not higher than requested node", "myHeight", endHeight, "requestHeight", startHeight, "incomingIP", request.Ip, "incomingPort", request.Port, "incomingPeer", incomingPeer)
utils.Logger().
Debug().
Uint64("myHeight", endHeight).
Uint64("requestHeight", startHeight).
Str("incomingIP", request.Ip).
Str("incomingPort", request.Port).
Str("incomingPeer", incomingPeer).
Msg("[SYNC] GetBlockHashes Request: I am not higher than requested node")
return response, nil
}
@ -281,14 +288,16 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
// this is the out of sync node acts as grpc server side
case downloader_pb.DownloaderRequest_NEWBLOCK:
if node.State != NodeNotInSync {
utils.GetLogInstance().Debug("[SYNC] new block received, but state is", "state", node.State.String())
utils.Logger().Debug().
Str("state", node.State.String()).
Msg("[SYNC] new block received, but state is")
response.Type = downloader_pb.DownloaderResponse_INSYNC
return response, nil
}
var blockObj types.Block
err := rlp.DecodeBytes(request.BlockHash, &blockObj)
if err != nil {
utils.GetLogInstance().Warn("[SYNC] unable to decode received new block")
utils.Logger().Warn().Error().Err(err).Msg("[SYNC] unable to decode received new block")
return response, err
}
node.stateSync.AddNewBlock(request.PeerHash, &blockObj)
@ -301,7 +310,10 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
defer node.stateMutex.Unlock()
if _, ok := node.peerRegistrationRecord[peerID]; ok {
response.Type = downloader_pb.DownloaderResponse_FAIL
utils.GetLogInstance().Warn("[SYNC] peerRegistration record already exists", "ip", ip, "port", port)
utils.Logger().Warn().Err(err).
Interface("ip", ip).
Interface("port", port).
Msg("[SYNC] peerRegistration record already exists")
return response, nil
} else if len(node.peerRegistrationRecord) >= maxBroadcastNodes {
response.Type = downloader_pb.DownloaderResponse_FAIL
@ -312,19 +324,27 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
syncPort := syncing.GetSyncingPort(port)
client := downloader.ClientSetup(ip, syncPort)
if client == nil {
utils.GetLogInstance().Warn("[SYNC] unable to setup client for peerID", "ip", ip, "port", port)
utils.Logger().Warn().Err(err).
Str("ip", ip).
Str("port", port).
Msg("[SYNC] unable to setup client for peerID")
return response, nil
}
config := &syncConfig{timestamp: time.Now().UnixNano(), client: client}
node.peerRegistrationRecord[peerID] = config
utils.GetLogInstance().Debug("[SYNC] register peerID success", "ip", ip, "port", port)
utils.Logger().Debug().
Str("ip", ip).
Str("port", port).
Msg("[SYNC] register peerID success")
response.Type = downloader_pb.DownloaderResponse_SUCCESS
}
case downloader_pb.DownloaderRequest_REGISTERTIMEOUT:
if node.State == NodeNotInSync {
count := node.stateSync.RegisterNodeInfo()
utils.GetLogInstance().Debug("[SYNC] extra node registered", "number", count)
utils.Logger().Debug().
Str("number", count).
Msg("[SYNC] extra node registered")
}
}
return response, nil

@ -83,7 +83,11 @@ func (node *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, c
return err
}
utils.GetLogger().Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ","))
utils.Logger().Info().
Str("url", fmt.Sprintf("http://%s", endpoint)).
Str("cors", strings.Join(cors, ",")).
Str("vhosts", strings.Join(vhosts, ",")).
Msg("HTTP endpoint opened")
// All listeners booted successfully
httpListener = listener
httpHandler = handler
@ -97,7 +101,7 @@ func (node *Node) stopHTTP() {
httpListener.Close()
httpListener = nil
utils.GetLogger().Info("HTTP endpoint closed", "url", fmt.Sprintf("http://%s", httpEndpoint))
utils.Logger().Info().Str("url", fmt.Sprintf("http://%s", httpEndpoint)).Msg("HTTP endpoint closed")
}
if httpHandler != nil {
httpHandler.Stop()
@ -115,7 +119,7 @@ func (node *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsO
if err != nil {
return err
}
utils.GetLogger().Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr()))
utils.Logger().Info().Str("url", fmt.Sprintf("ws://%s", listener.Addr())).Msg("WebSocket endpoint opened")
// All listeners booted successfully
wsListener = listener
wsHandler = handler
@ -129,7 +133,7 @@ func (node *Node) stopWS() {
wsListener.Close()
wsListener = nil
utils.GetLogger().Info("WebSocket endpoint closed", "url", fmt.Sprintf("ws://%s", wsEndpoint))
utils.Logger().Info().Str("url", fmt.Sprintf("ws://%s", wsEndpoint)).Msg("WebSocket endpoint closed")
}
if wsHandler != nil {
wsHandler.Stop()

@ -96,7 +96,7 @@ func (node *Node) ServiceManagerSetup() {
// RunServices runs registered services.
func (node *Node) RunServices() {
if node.serviceManager == nil {
utils.GetLogInstance().Info("Service manager is not set up yet.")
utils.Logger().Info().Msg("Service manager is not set up yet.")
return
}
node.serviceManager.RunServices()
@ -105,7 +105,7 @@ func (node *Node) RunServices() {
// StopServices runs registered services.
func (node *Node) StopServices() {
if node.serviceManager == nil {
utils.GetLogInstance().Info("Service manager is not set up yet.")
utils.Logger().Info().Msg("Service manager is not set up yet.")
return
}
node.serviceManager.StopServicesByRole([]service.Type{})

@ -28,7 +28,7 @@ const (
// UpdateStakingList updates staking list from the given StakeInfo query result.
func (node *Node) UpdateStakingList(stakeInfoReturnValue *structs.StakeInfoReturnValue) {
utils.GetLogInstance().Info("Updating staking list", "contractState", stakeInfoReturnValue)
utils.Logger().Str("contractState", stakeInfoReturnValue).Msg("Updating staking list")
if stakeInfoReturnValue == nil {
return
}
@ -60,13 +60,19 @@ func (node *Node) UpdateStakingList(stakeInfoReturnValue *structs.StakeInfoRetur
}
func (node *Node) printStakingList() {
utils.GetLogInstance().Info("\n")
utils.GetLogInstance().Info("CURRENT STAKING INFO [START] ------------------------------------")
utils.Logger().Info().Msg("\n")
utils.Logger().Info().Msg("CURRENT STAKING INFO [START] ------------------------------------")
for addr, stakeInfo := range node.CurrentStakes {
utils.GetLogInstance().Info("", "Address", addr, "BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:]), "BlockNum", stakeInfo.BlockNum, "lockPeriodCount", stakeInfo.LockPeriodCount, "amount", stakeInfo.Amount)
utils.Logger().Info().
Str("Address", addr).
Str("BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:])).
Uint64("BlockNum", stakeInfo.BlockNum).
Int("lockPeriodCount", stakeInfo.LockPeriodCount).
Int("amount", stakeInfo.Amount).
Msg("")
}
utils.GetLogInstance().Info("CURRENT STAKING INFO [END} ------------------------------------")
utils.GetLogInstance().Info("\n")
utils.Logger().Info().Msg("CURRENT STAKING INFO [END} ------------------------------------")
utils.Logger().Info().Msg("\n")
}
//The first four bytes of the call data for a function call specifies the function to be called.

Loading…
Cancel
Save