| 97 | } |
| 98 | |
| 99 | func walkBucket(b *Bucket, keypath [][]byte, k, v []byte, seq uint64, fn walkFunc) error { |
| 100 | // Execute callback. |
| 101 | if err := fn(keypath, k, v, seq); err != nil { |
| 102 | return err |
| 103 | } |
| 104 | |
| 105 | // If this is not a bucket then stop. |
| 106 | if v != nil { |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | // Iterate over each child key/value. |
| 111 | keypath = append(keypath, k) |
| 112 | return b.ForEach(func(k, v []byte) error { |
| 113 | if v == nil { |
| 114 | bkt := b.Bucket(k) |
| 115 | return walkBucket(bkt, keypath, k, nil, bkt.Sequence(), fn) |
| 116 | } |
| 117 | return walkBucket(b, keypath, k, v, b.Sequence(), fn) |
| 118 | }) |
| 119 | } |