@@ -19,11 +19,22 @@ limitations under the License.
19
19
package btree
20
20
21
21
import (
22
+ "crypto/rand"
23
+ "io"
22
24
"sort"
23
-
24
- "github.com/satori/go.uuid"
25
25
)
26
26
27
+ func newID () []byte {
28
+ id := make ([]byte , 16 )
29
+ _ , err := io .ReadFull (rand .Reader , id )
30
+ if err != nil {
31
+ // This can't happen unless the system is badly
32
+ // configured, like /dev/urandom isn't readable.
33
+ panic ("reading random: " + err .Error ())
34
+ }
35
+ return id
36
+ }
37
+
27
38
// ID exists because i'm tired of writing []byte
28
39
type ID []byte
29
40
@@ -120,7 +131,7 @@ func (n *Node) copy() *Node {
120
131
copy (cpKeys , n .ChildKeys )
121
132
122
133
return & Node {
123
- ID : uuid . NewV4 (). Bytes (),
134
+ ID : newID (),
124
135
IsLeaf : n .IsLeaf ,
125
136
ChildValues : cpValues ,
126
137
ChildKeys : cpKeys ,
@@ -297,7 +308,7 @@ func (n *Node) deleteKeyAt(i int) {
297
308
func (n * Node ) splitLeafAt (i int ) (interface {}, * Node ) {
298
309
left := newNode ()
299
310
left .IsLeaf = n .IsLeaf
300
- left .ID = uuid . NewV4 (). Bytes ()
311
+ left .ID = newID ()
301
312
302
313
value := n .ChildValues [i ]
303
314
leftValues := make ([]interface {}, i + 1 )
@@ -320,7 +331,7 @@ func (n *Node) splitLeafAt(i int) (interface{}, *Node) {
320
331
func (n * Node ) splitInternalAt (i int ) (interface {}, * Node ) {
321
332
left := newNode ()
322
333
left .IsLeaf = n .IsLeaf
323
- left .ID = uuid . NewV4 (). Bytes ()
334
+ left .ID = newID ()
324
335
value := n .ChildValues [i ]
325
336
leftValues := make ([]interface {}, i )
326
337
copy (leftValues , n .ChildValues [:i ])
@@ -421,7 +432,7 @@ func nodeFromBytes(t *Tr, data []byte) (*Node, error) {
421
432
// IsLeaf is false by default.
422
433
func newNode () * Node {
423
434
return & Node {
424
- ID : uuid . NewV4 (). Bytes (),
435
+ ID : newID (),
425
436
}
426
437
}
427
438
0 commit comments