Merge pull request #13 from NineRec/patch-1
Update error log for wrong node id.
This commit is contained in:
commit
68117e6bbe
@ -89,10 +89,6 @@ type ID int64
|
|||||||
// IDs
|
// IDs
|
||||||
func NewNode(node int64) (*Node, error) {
|
func NewNode(node int64) (*Node, error) {
|
||||||
|
|
||||||
if node < 0 || node > nodeMax {
|
|
||||||
return nil, errors.New("Node number must be between 0 and 1023")
|
|
||||||
}
|
|
||||||
|
|
||||||
// re-calc in case custom NodeBits or StepBits were set
|
// re-calc in case custom NodeBits or StepBits were set
|
||||||
nodeMax = -1 ^ (-1 << NodeBits)
|
nodeMax = -1 ^ (-1 << NodeBits)
|
||||||
nodeMask = nodeMax << StepBits
|
nodeMask = nodeMax << StepBits
|
||||||
@ -100,6 +96,10 @@ func NewNode(node int64) (*Node, error) {
|
|||||||
timeShift = NodeBits + StepBits
|
timeShift = NodeBits + StepBits
|
||||||
nodeShift = StepBits
|
nodeShift = StepBits
|
||||||
|
|
||||||
|
if node < 0 || node > nodeMax {
|
||||||
|
return nil, errors.New("Node number must be between 0 and " + strconv.FormatInt(nodeMax, 10))
|
||||||
|
}
|
||||||
|
|
||||||
return &Node{
|
return &Node{
|
||||||
time: 0,
|
time: 0,
|
||||||
node: node,
|
node: node,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user