simplification of Fetchers (#1344)

This commit is contained in:
Anton Evangelatov
2019-06-17 10:01:12 +02:00
committed by GitHub
parent 21adbe2fac
commit 0b724bd4d5
23 changed files with 746 additions and 2246 deletions

View File

@@ -93,20 +93,20 @@ func newTestClient(t string) *testClient {
}
}
func (self *testClient) NeedData(ctx context.Context, hash []byte) func(context.Context) error {
func (self *testClient) NeedData(ctx context.Context, hash []byte) (bool, func(context.Context) error) {
self.receivedHashes[string(hash)] = hash
if bytes.Equal(hash, hash0[:]) {
return func(context.Context) error {
return false, func(context.Context) error {
<-self.wait0
return nil
}
} else if bytes.Equal(hash, hash2[:]) {
return func(context.Context) error {
return false, func(context.Context) error {
<-self.wait2
return nil
}
}
return nil
return false, nil
}
func (self *testClient) Close() {}