diff --git a/backend/pkg/commons/utils/uuid.go b/backend/pkg/commons/utils/uuid.go index 6932f1c76..5142a1143 100644 --- a/backend/pkg/commons/utils/uuid.go +++ b/backend/pkg/commons/utils/uuid.go @@ -6,6 +6,7 @@ import ( "github.com/bwmarrin/snowflake" "github.com/gobitfly/beaconchain/pkg/commons/log" "github.com/google/uuid" + "golang.org/x/exp/rand" ) // uuid that you can get - gets set to a random value on startup/first read @@ -30,7 +31,8 @@ func GetSnowflake() int64 { return v.(*snowflake.Node).Generate().Int64() } - node, err := snowflake.NewNode(1) + nodeId := rand.Int63() & 0xFF + node, err := snowflake.NewNode(nodeId) if err != nil { log.Fatal(err, "snowflake generator failed to start", 0) return 0 diff --git a/backend/pkg/monitoring/services/base.go b/backend/pkg/monitoring/services/base.go index 9f5c6e3c3..549b4d67f 100644 --- a/backend/pkg/monitoring/services/base.go +++ b/backend/pkg/monitoring/services/base.go @@ -47,6 +47,7 @@ func NewStatusReport(id string, timeout time.Duration, check_interval time.Durat return func(status constants.StatusType, metadata map[string]string) { // acquire snowflake synchronously flake := utils.GetSnowflake() + now := time.Now() go func() { if metadata == nil { metadata = make(map[string]string) @@ -60,9 +61,9 @@ func NewStatusReport(id string, timeout time.Duration, check_interval time.Durat ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - timeouts_at := time.Now().Add(1 * time.Minute) + timeouts_at := now.Add(1 * time.Minute) if timeout != constants.Default { - timeouts_at = time.Now().Add(timeout) + timeouts_at = now.Add(timeout) } expires_at := timeouts_at.Add(5 * time.Minute) if check_interval >= 5*time.Minute {