Merge pull request #13 from NineRec/patch-1

Update error log for wrong node id.
This commit is contained in:
Bruce 2018-04-11 20:05:44 -05:00 committed by GitHub
commit 68117e6bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,