| 78 | type encoderStateFn func(*advRefsEncoder) encoderStateFn |
| 79 | |
| 80 | func encodePrefix(e *advRefsEncoder) encoderStateFn { |
| 81 | for _, p := range e.data.Prefix { |
| 82 | if bytes.Equal(p, pktline.Flush) { |
| 83 | if e.err = e.pe.Flush(); e.err != nil { |
| 84 | return nil |
| 85 | } |
| 86 | continue |
| 87 | } |
| 88 | if e.err = e.pe.Encodef("%s\n", string(p)); e.err != nil { |
| 89 | return nil |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return encodeFirstLine |
| 94 | } |
| 95 | |
| 96 | // Adds the first pkt-line payload: head hash, head ref and capabilities. |
| 97 | // If HEAD ref is not found, the first reference ordered in increasing order will be used. |