Various improvements and changed encoding/decoding format to LLL-NNN-LLC with reduced character set.
All checks were successful
CI / test (push) Successful in 16s
All checks were successful
CI / test (push) Successful in 16s
This commit is contained in:
@@ -13,11 +13,11 @@ import (
|
||||
"git.hoiting.org/micha/triplex/serial"
|
||||
)
|
||||
|
||||
func alreadyUsedByClient(idx uint32) bool {
|
||||
func alreadyUsedByClient(idx uint) bool {
|
||||
return idx%2 == 0
|
||||
}
|
||||
|
||||
func myRandomIndex(max uint32) (uint32, error) {
|
||||
func myRandomIndex(max uint) (uint, error) {
|
||||
if max == 0 {
|
||||
return 0, fmt.Errorf("max must be > 0")
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func myRandomIndex(max uint32) (uint32, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return binary.LittleEndian.Uint32(buf[:]) % max, nil
|
||||
return uint(binary.LittleEndian.Uint32(buf[:])) % max, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -48,10 +48,10 @@ func main() {
|
||||
|
||||
opts := serial.RandomCodeOptions{
|
||||
MaxAttempts: 500,
|
||||
IsInUse: func(idx uint32) bool {
|
||||
IsInUse: func(idx uint) bool {
|
||||
return alreadyUsedByClient(idx)
|
||||
},
|
||||
RandomIndex: func(max uint32) (uint32, error) {
|
||||
RandomIndex: func(max uint) (uint, error) {
|
||||
return myRandomIndex(max)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user