Add adds new node to the memory index
(hash plumbing.Hash, data *CommitData)
| 81 | |
| 82 | // Add adds new node to the memory index |
| 83 | func (mi *MemoryIndex) Add(hash plumbing.Hash, data *CommitData) { |
| 84 | // The parent indexes are calculated lazily in GetNodeByIndex |
| 85 | // which allows adding nodes out of order as long as all parents |
| 86 | // are eventually resolved |
| 87 | data.ParentIndexes = nil |
| 88 | mi.indexMap[hash] = uint32(len(mi.commitData)) |
| 89 | mi.commitData = append(mi.commitData, commitData{Hash: hash, CommitData: data}) |
| 90 | if data.GenerationV2 == math.MaxUint64 { // if GenerationV2 is not available reset it to zero |
| 91 | data.GenerationV2 = 0 |
| 92 | } |
| 93 | mi.hasGenerationV2 = mi.hasGenerationV2 && data.GenerationV2 != 0 |
| 94 | } |
| 95 | |
| 96 | func (mi *MemoryIndex) HasGenerationV2() bool { |
| 97 | return mi.hasGenerationV2 |
no outgoing calls