Hints []string
}
-type ManifestLine struct {
+// Represents a single line from a manifest.
+type ManifestStream struct {
StreamName string
Blocks []string
Files []string
return
}
-func parseManifestLine(s string) (m ManifestLine) {
+func parseManifestStream(s string) (m ManifestStream) {
tokens := strings.Split(s, " ")
m.StreamName = tokens[0]
tokens = tokens[1:]
return
}
-func (m *Manifest) LineIter() <-chan ManifestLine {
- ch := make(chan ManifestLine)
+func (m *Manifest) StreamIter() <-chan ManifestStream {
+ ch := make(chan ManifestStream)
go func(input string) {
// This slice holds the current line and the remainder of the
// manifest. We parse one line at a time, to save effort if we
lines = strings.SplitN(lines[1], "\n", 2)
if len(lines[0]) > 0 {
// Only parse non-blank lines
- ch <- parseManifestLine(lines[0])
+ ch <- parseManifestStream(lines[0])
}
if len(lines) == 1 {
break
// the same block multiple times.
func (m *Manifest) BlockIterWithDuplicates() <-chan BlockLocator {
blockChannel := make(chan BlockLocator)
- go func(lineChannel <-chan ManifestLine) {
- for m := range lineChannel {
+ go func(streamChannel <-chan ManifestStream) {
+ for m := range streamChannel {
for _, block := range m.Blocks {
if b, err := ParseBlockLocator(block); err == nil {
blockChannel <- b
}
}
close(blockChannel)
- }(m.LineIter())
+ }(m.StreamIter())
return blockChannel
}