MCPcopy Create free account
hub / github.com/goinaction/code / Copy

Function Copy

chapter10/listing04/listing04.go:104–119  ·  view source on GitHub ↗

Copy knows how to pull and store data from any System.

(ps PullStorer, batch int)

Source from the content-addressed store, hash-verified

102
103// Copy knows how to pull and store data from any System.
104func Copy(ps PullStorer, batch int) error {
105 data := make([]Data, batch)
106
107 for {
108 i, err := pull(ps, data)
109 if i > 0 {
110 if _, err := store(ps, data[:i]); err != nil {
111 return err
112 }
113 }
114
115 if err != nil {
116 return err
117 }
118 }
119}
120
121// =============================================================================
122

Callers 1

mainFunction · 0.70

Calls 2

pullFunction · 0.70
storeFunction · 0.70

Tested by

no test coverage detected