diff --git a/src/git.xdrm.io/schastsp/lib/timeid/timeid.go b/src/git.xdrm.io/schastsp/lib/timeid/timeid.go index b3f0521..d82d506 100644 --- a/src/git.xdrm.io/schastsp/lib/timeid/timeid.go +++ b/src/git.xdrm.io/schastsp/lib/timeid/timeid.go @@ -10,11 +10,11 @@ import ( * * @wsize Window Size in seconds * -* @return id Current time id -* @return parity Current time parity +* @return id Current time id +* @return parity Current time parity * ---------------------------------------------------------*/ -func Generate(wsize float64) (uint, uint){ +func Generate(wsize float64) (uint32, uint32){ /* (1) If wsize is 0 (div by zero possible error) */ if wsize == 0 { return 0, 0 } @@ -23,7 +23,7 @@ func Generate(wsize float64) (uint, uint){ timestamp := float64( time.Now().Unix() ); /* (3) Calculate the time id */ - var id = uint( timestamp / wsize ); + var id = uint32( timestamp / wsize ); /* (4) Calculate parity */ var parity = id % 2; @@ -35,17 +35,17 @@ func Generate(wsize float64) (uint, uint){ /* (2) Try to guess a previous time id from its parity * * @wsize Window Size in seconds -* @parity Received parity +* @parity Received parity * -* @return id The guessed time id +* @return id The guessed time id * ---------------------------------------------------------*/ -func Guess(wsize float64, parity uint) uint{ +func Guess(wsize float64, parity uint32) uint32{ /* (1) Get current time id */ var idNow, parityNow = Generate(wsize); /* (2) Update ID with tidNow parity difference */ - return idNow - uint(math.Abs( float64(parityNow) - float64(parity) )); + return idNow - uint32(math.Abs( float64(parityNow) - float64(parity) )); } \ No newline at end of file diff --git a/src/git.xdrm.io/schastsp/lib/timeid/timeid_test.go b/src/git.xdrm.io/schastsp/lib/timeid/timeid_test.go index 705a82e..651b14f 100644 --- a/src/git.xdrm.io/schastsp/lib/timeid/timeid_test.go +++ b/src/git.xdrm.io/schastsp/lib/timeid/timeid_test.go @@ -14,7 +14,7 @@ func TestGuessing(t *testing.T){ time.Sleep( time.Duration(windowSize) * time.Second); - var guessedId uint = Guess(windowSize, parity); + var guessedId = Guess(windowSize, parity); if id != guessedId { t.Errorf("Wrong guessed id, expected '%d' ; got '%d'", id, guessedId);