GetNextMaintenanceTime gRPC Method
Parameters
This method does not accept any parameters
Returns
num
integer
Timestamp (in milliseconds) of the next scheduled maintenance time
Request
package main import ( "context" "crypto/tls" "fmt" "github.com/fbsobreira/gotron-sdk/pkg/client" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "log" "time" ) // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC} // token will be : abcde123456789 var token = "YOUR_TOKEN" var endpoint = "YOUR_ENDPOINT:50051" type auth struct { token string } func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{ "x-token": a.token, }, nil } func (a *auth) RequireTransportSecurity() bool { return false } func main() { opts := []grpc.DialOption{ grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), grpc.WithPerRPCCredentials(&auth{token}), } conn := client.NewGrpcClient(endpoint) if err := conn.Start(opts...); err != nil { panic(err) } defer conn.Conn.Close() fmt.Println("Fetching next maintenance time information...") maintenanceTimeInfo, err := conn.GetNextMaintenanceTime() if err != nil { log.Fatalf("Error getting next maintenance time: %v\n", err) } nextMaintenanceTime := maintenanceTimeInfo.GetNum() if nextMaintenanceTime > 0 { // TRON timestamps are in milliseconds maintenanceDate := time.Unix(nextMaintenanceTime/1000, 0) fmt.Println("\nNext Maintenance Time Information:") fmt.Printf("Timestamp: %d\n", nextMaintenanceTime) fmt.Printf("Date and Time: %s\n", maintenanceDate.Format(time.RFC1123)) // Calculate time until maintenance now := time.Now() timeUntil := maintenanceDate.Sub(now) if timeUntil > 0 { days := int(timeUntil.Hours() / 24) hours := int(timeUntil.Hours()) % 24 minutes := int(timeUntil.Minutes()) % 60 fmt.Printf("Time until maintenance: %d days, %d hours, %d minutes\n", days, hours, minutes) } else { fmt.Println("Maintenance time has already passed. The next maintenance time may not be updated yet.") } } else { fmt.Println("No maintenance time information available.") } fmt.Println("\nNote: TRON network conducts regular maintenance to implement updates and improvements.") }
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free