simplification of Fetchers (#1344)
This commit is contained in:
committed by
GitHub
parent
21adbe2fac
commit
0b724bd4d5
@@ -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() {}
|
||||
|
Reference in New Issue
Block a user