Skip to content

Commit

Permalink
Update log messages and improve error handling
Browse files Browse the repository at this point in the history
Updated log messages in 'rpc/server.go' and 'junction/initVRF.go' to reflect current operation status. Added math functions in 'junction/createStation.go' to divide user balance. Moreover, error handling added during the JSON parsing in 'da/avail/avail.go' and during conversion of string to float in 'junction/createStation.go'. Moreover, unnecessary print statement in 'node/node.go' has been removed.

Co-authored-by: noooblien <[email protected]>
Co-authored-by: aakash4dev <[email protected]>
Co-authored-by: Kritarth1107 <[email protected]>
Co-authored-by: Deadlium <[email protected]>
  • Loading branch information
4 people committed May 31, 2024
1 parent 20bc27c commit c9cf940
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions junction/createStation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"encoding/json"
"fmt"
"github.com/pelletier/go-toml"
"math"
"strconv"

//"github.com/BurntSushi/toml"
"github.com/airchains-network/decentralized-sequencer/config"
Expand Down Expand Up @@ -73,9 +75,16 @@ func CreateStation(extraArg junctionTypes.StationArg, stationId string, stationI
logs.Log.Error("Not enough balance on " + newTempAddr + " to create station")
return false
}
amountStr := fmt.Sprintf("%damf", amount)
logs.Log.Info("Currently user have " + amountStr)
amountDiv, err := strconv.ParseFloat(strconv.FormatInt(amount, 10), 64)
if err != nil {
fmt.Println(err)
return false
}

dividedAmount := amountDiv / math.Pow(10, 6)
dividedAmountStr := strconv.FormatFloat(dividedAmount, 'f', 6, 64)

logs.Log.Info("Currently user have " + dividedAmountStr + "AMF")
// Voting powers: almost equal.
var tracksVotingPower []uint64
totalPower := uint64(100)
Expand Down
2 changes: 2 additions & 0 deletions junction/initVRF.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ func InitVRF() (success bool, addr string) {
currentPodState.VRFInitiationTxHash = txRes.TxHash
// update pod state: update tx hash
shared.SetPodState(currentPodState)
log.Info().Str("module", "junction").Str("hash", txRes.TxHash).Msg("Vrf Initiation Tx Hash")

log.Info().Str("module", "junction").Msg(txRes.TxHash)
return true, newTempAddr

}
Expand Down
1 change: 0 additions & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func Start() {
select {
case <-ticker.C:
if p2p.PeerConnectionStatus(p2p.Node) {
fmt.Println("All peers connected")
beginDBIndexingOperations(&wg1)
return
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func StartRPC(wg *sync.WaitGroup) {
server.Log.WithField("error", err).Fatal("Failed to start server")
}
server.Log.Info("Server Started Successfully on Port 2024")
log.Info().Str("module", "rpc").Msg("Pod Submitted Successfully")
log.Info().Str("module", "rpc").Msg("RPC Server Stared at Port 2024 Successfully")

stopChan := make(chan os.Signal, 1)
signal.Notify(stopChan, syscall.SIGTERM)
Expand Down

0 comments on commit c9cf940

Please sign in to comment.