From dc6723c59456ef7f0cd8fcbc0c76fcd83d7121ea Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Fri, 10 Jun 2022 19:45:57 -0400 Subject: [PATCH] update generated code --- gen/proto/proto_edelweiss.go | 299 ++++++++++++++++++++--------------- 1 file changed, 169 insertions(+), 130 deletions(-) diff --git a/gen/proto/proto_edelweiss.go b/gen/proto/proto_edelweiss.go index 891ec0d..e4490a7 100644 --- a/gen/proto/proto_edelweiss.go +++ b/gen/proto/proto_edelweiss.go @@ -3,24 +3,23 @@ package proto import ( - pd8 "bytes" - pd6 "context" - pd11 "errors" + pd10 "bytes" + pd5 "context" + pd12 "errors" pd3 "fmt" - pd7 "io" - pd15 "io/ioutil" - pd4 "net/http" - pd5 "net/url" - pd14 "sync" - - pd17 "github.com/ipfs/go-cid" - pd12 "github.com/ipfs/go-log" - pd13 "github.com/ipld/edelweiss/services" + pd16 "github.com/ipfs/go-cid" + pd4 "github.com/ipfs/go-log" + pd14 "github.com/ipld/edelweiss/services" pd2 "github.com/ipld/edelweiss/values" - pd10 "github.com/ipld/go-ipld-prime" + pd8 "github.com/ipld/go-ipld-prime" pd9 "github.com/ipld/go-ipld-prime/codec/dagjson" pd1 "github.com/ipld/go-ipld-prime/datamodel" - pd16 "github.com/ipld/go-ipld-prime/linking/cid" + pd17 "github.com/ipld/go-ipld-prime/linking/cid" + pd6 "io" + pd15 "io/ioutil" + pd7 "net/http" + pd11 "net/url" + pd13 "sync" ) // -- protocol type DelegatedRouting_IdentifyArg -- @@ -1014,24 +1013,24 @@ func (x AnonInductive5) Prototype() pd1.NodePrototype { return nil } -var logger_client_DelegatedRouting = pd12.Logger("service/client/delegatedrouting") +var logger_client_DelegatedRouting = pd4.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { - Identify(ctx pd6.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) + Identify(ctx pd5.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) - FindProviders(ctx pd6.Context, req *FindProvidersRequest) ([]*FindProvidersResponse, error) + FindProviders(ctx pd5.Context, req *FindProvidersRequest) ([]*FindProvidersResponse, error) - GetIPNS(ctx pd6.Context, req *GetIPNSRequest) ([]*GetIPNSResponse, error) + GetIPNS(ctx pd5.Context, req *GetIPNSRequest) ([]*GetIPNSResponse, error) - PutIPNS(ctx pd6.Context, req *PutIPNSRequest) ([]*PutIPNSResponse, error) + PutIPNS(ctx pd5.Context, req *PutIPNSRequest) ([]*PutIPNSResponse, error) - Identify_Async(ctx pd6.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + Identify_Async(ctx pd5.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) - FindProviders_Async(ctx pd6.Context, req *FindProvidersRequest) (<-chan DelegatedRouting_FindProviders_AsyncResult, error) + FindProviders_Async(ctx pd5.Context, req *FindProvidersRequest) (<-chan DelegatedRouting_FindProviders_AsyncResult, error) - GetIPNS_Async(ctx pd6.Context, req *GetIPNSRequest) (<-chan DelegatedRouting_GetIPNS_AsyncResult, error) + GetIPNS_Async(ctx pd5.Context, req *GetIPNSRequest) (<-chan DelegatedRouting_GetIPNS_AsyncResult, error) - PutIPNS_Async(ctx pd6.Context, req *PutIPNSRequest) (<-chan DelegatedRouting_PutIPNS_AsyncResult, error) + PutIPNS_Async(ctx pd5.Context, req *PutIPNSRequest) (<-chan DelegatedRouting_PutIPNS_AsyncResult, error) } type DelegatedRouting_Identify_AsyncResult struct { @@ -1057,13 +1056,13 @@ type DelegatedRouting_PutIPNS_AsyncResult struct { type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd4.Client - endpoint *pd5.URL - ulk pd14.Mutex + httpClient *pd7.Client + endpoint *pd11.URL + ulk pd13.Mutex unsupported map[string]bool // cache of methods not supported by server } -func DelegatedRouting_Client_WithHTTPClient(hc *pd4.Client) DelegatedRouting_ClientOption { +func DelegatedRouting_Client_WithHTTPClient(hc *pd7.Client) DelegatedRouting_ClientOption { return func(c *client_DelegatedRouting) error { c.httpClient = hc return nil @@ -1071,11 +1070,11 @@ func DelegatedRouting_Client_WithHTTPClient(hc *pd4.Client) DelegatedRouting_Cli } func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_ClientOption) (*client_DelegatedRouting, error) { - u, err := pd5.Parse(endpoint) + u, err := pd11.Parse(endpoint) if err != nil { return nil, err } - c := &client_DelegatedRouting{endpoint: u, httpClient: pd4.DefaultClient, unsupported: make(map[string]bool)} + c := &client_DelegatedRouting{endpoint: u, httpClient: pd7.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1084,8 +1083,8 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } -func (c *client_DelegatedRouting) Identify(ctx pd6.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { - ctx, cancel := pd6.WithCancel(ctx) +func (c *client_DelegatedRouting) Identify(ctx pd5.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { + ctx, cancel := pd5.WithCancel(ctx) defer cancel() ch, err := c.Identify_Async(ctx, req) if err != nil { @@ -1113,27 +1112,27 @@ func (c *client_DelegatedRouting) Identify(ctx pd6.Context, req *DelegatedRoutin } } -func (c *client_DelegatedRouting) Identify_Async(ctx pd6.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { +func (c *client_DelegatedRouting) Identify_Async(ctx pd5.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["Identify"] c.ulk.Unlock() if notSupported { - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } envelope := &AnonInductive4{ Identify: req, } - buf, err := pd10.Encode(envelope, pd9.Encode) + buf, err := pd8.Encode(envelope, pd9.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd8.NewReader(buf)) + httpReq, err := pd7.NewRequestWithContext(ctx, "POST", u.String(), pd10.NewReader(buf)) if err != nil { return nil, err } @@ -1155,7 +1154,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd6.Context, req *Delegated c.ulk.Lock() c.unsupported["Identify"] = true c.ulk.Unlock() - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1163,7 +1162,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd6.Context, req *Delegated resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1178,29 +1177,39 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd6.Context, req *Delegated return ch, nil } -func process_DelegatedRouting_Identify_AsyncResult(ctx pd6.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd7.ReadCloser) { +func process_DelegatedRouting_Identify_AsyncResult(ctx pd5.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd6.ReadCloser) { defer close(ch) defer r.Close() + opt := pd9.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out DelegatedRouting_Identify_AsyncResult - n, err := pd10.DecodeStreaming(r, pd9.Decode) - if pd11.Is(err, pd7.EOF) || pd11.Is(err, pd7.ErrUnexpectedEOF) { + n, err := pd8.DecodeStreaming(r, opt.Decode) + if pd12.Is(err, pd6.EOF) || pd12.Is(err, pd6.ErrUnexpectedEOF) { return } if err != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error + out = DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error - } else if env.Identify != nil { - out = DelegatedRouting_Identify_AsyncResult{Resp: env.Identify} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { - continue + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrService{Cause: pd12.New(string(env.Error.Code))}} // service-level error + } else if env.Identify != nil { + out = DelegatedRouting_Identify_AsyncResult{Resp: env.Identify} + } else { + continue + } } } @@ -1212,8 +1221,8 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd6.Context, ch chan<- De } } -func (c *client_DelegatedRouting) FindProviders(ctx pd6.Context, req *FindProvidersRequest) ([]*FindProvidersResponse, error) { - ctx, cancel := pd6.WithCancel(ctx) +func (c *client_DelegatedRouting) FindProviders(ctx pd5.Context, req *FindProvidersRequest) ([]*FindProvidersResponse, error) { + ctx, cancel := pd5.WithCancel(ctx) defer cancel() ch, err := c.FindProviders_Async(ctx, req) if err != nil { @@ -1241,27 +1250,27 @@ func (c *client_DelegatedRouting) FindProviders(ctx pd6.Context, req *FindProvid } } -func (c *client_DelegatedRouting) FindProviders_Async(ctx pd6.Context, req *FindProvidersRequest) (<-chan DelegatedRouting_FindProviders_AsyncResult, error) { +func (c *client_DelegatedRouting) FindProviders_Async(ctx pd5.Context, req *FindProvidersRequest) (<-chan DelegatedRouting_FindProviders_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["FindProviders"] c.ulk.Unlock() if notSupported { - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } envelope := &AnonInductive4{ FindProviders: req, } - buf, err := pd10.Encode(envelope, pd9.Encode) + buf, err := pd8.Encode(envelope, pd9.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd8.NewReader(buf)) + httpReq, err := pd7.NewRequestWithContext(ctx, "POST", u.String(), pd10.NewReader(buf)) if err != nil { return nil, err } @@ -1283,7 +1292,7 @@ func (c *client_DelegatedRouting) FindProviders_Async(ctx pd6.Context, req *Find c.ulk.Lock() c.unsupported["FindProviders"] = true c.ulk.Unlock() - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1291,7 +1300,7 @@ func (c *client_DelegatedRouting) FindProviders_Async(ctx pd6.Context, req *Find resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1306,29 +1315,39 @@ func (c *client_DelegatedRouting) FindProviders_Async(ctx pd6.Context, req *Find return ch, nil } -func process_DelegatedRouting_FindProviders_AsyncResult(ctx pd6.Context, ch chan<- DelegatedRouting_FindProviders_AsyncResult, r pd7.ReadCloser) { +func process_DelegatedRouting_FindProviders_AsyncResult(ctx pd5.Context, ch chan<- DelegatedRouting_FindProviders_AsyncResult, r pd6.ReadCloser) { defer close(ch) defer r.Close() + opt := pd9.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out DelegatedRouting_FindProviders_AsyncResult - n, err := pd10.DecodeStreaming(r, pd9.Decode) - if pd11.Is(err, pd7.EOF) || pd11.Is(err, pd7.ErrUnexpectedEOF) { + n, err := pd8.DecodeStreaming(r, opt.Decode) + if pd12.Is(err, pd6.EOF) || pd12.Is(err, pd6.ErrUnexpectedEOF) { return } if err != nil { - out = DelegatedRouting_FindProviders_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error + out = DelegatedRouting_FindProviders_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = DelegatedRouting_FindProviders_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = DelegatedRouting_FindProviders_AsyncResult{Err: pd13.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error - } else if env.FindProviders != nil { - out = DelegatedRouting_FindProviders_AsyncResult{Resp: env.FindProviders} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = DelegatedRouting_FindProviders_AsyncResult{Err: pd14.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { - continue + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = DelegatedRouting_FindProviders_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_FindProviders_AsyncResult{Err: pd14.ErrService{Cause: pd12.New(string(env.Error.Code))}} // service-level error + } else if env.FindProviders != nil { + out = DelegatedRouting_FindProviders_AsyncResult{Resp: env.FindProviders} + } else { + continue + } } } @@ -1340,8 +1359,8 @@ func process_DelegatedRouting_FindProviders_AsyncResult(ctx pd6.Context, ch chan } } -func (c *client_DelegatedRouting) GetIPNS(ctx pd6.Context, req *GetIPNSRequest) ([]*GetIPNSResponse, error) { - ctx, cancel := pd6.WithCancel(ctx) +func (c *client_DelegatedRouting) GetIPNS(ctx pd5.Context, req *GetIPNSRequest) ([]*GetIPNSResponse, error) { + ctx, cancel := pd5.WithCancel(ctx) defer cancel() ch, err := c.GetIPNS_Async(ctx, req) if err != nil { @@ -1369,27 +1388,27 @@ func (c *client_DelegatedRouting) GetIPNS(ctx pd6.Context, req *GetIPNSRequest) } } -func (c *client_DelegatedRouting) GetIPNS_Async(ctx pd6.Context, req *GetIPNSRequest) (<-chan DelegatedRouting_GetIPNS_AsyncResult, error) { +func (c *client_DelegatedRouting) GetIPNS_Async(ctx pd5.Context, req *GetIPNSRequest) (<-chan DelegatedRouting_GetIPNS_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["GetIPNS"] c.ulk.Unlock() if notSupported { - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } envelope := &AnonInductive4{ GetIPNS: req, } - buf, err := pd10.Encode(envelope, pd9.Encode) + buf, err := pd8.Encode(envelope, pd9.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd8.NewReader(buf)) + httpReq, err := pd7.NewRequestWithContext(ctx, "POST", u.String(), pd10.NewReader(buf)) if err != nil { return nil, err } @@ -1411,7 +1430,7 @@ func (c *client_DelegatedRouting) GetIPNS_Async(ctx pd6.Context, req *GetIPNSReq c.ulk.Lock() c.unsupported["GetIPNS"] = true c.ulk.Unlock() - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1419,7 +1438,7 @@ func (c *client_DelegatedRouting) GetIPNS_Async(ctx pd6.Context, req *GetIPNSReq resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1434,29 +1453,39 @@ func (c *client_DelegatedRouting) GetIPNS_Async(ctx pd6.Context, req *GetIPNSReq return ch, nil } -func process_DelegatedRouting_GetIPNS_AsyncResult(ctx pd6.Context, ch chan<- DelegatedRouting_GetIPNS_AsyncResult, r pd7.ReadCloser) { +func process_DelegatedRouting_GetIPNS_AsyncResult(ctx pd5.Context, ch chan<- DelegatedRouting_GetIPNS_AsyncResult, r pd6.ReadCloser) { defer close(ch) defer r.Close() + opt := pd9.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out DelegatedRouting_GetIPNS_AsyncResult - n, err := pd10.DecodeStreaming(r, pd9.Decode) - if pd11.Is(err, pd7.EOF) || pd11.Is(err, pd7.ErrUnexpectedEOF) { + n, err := pd8.DecodeStreaming(r, opt.Decode) + if pd12.Is(err, pd6.EOF) || pd12.Is(err, pd6.ErrUnexpectedEOF) { return } if err != nil { - out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error + out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd13.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error - } else if env.GetIPNS != nil { - out = DelegatedRouting_GetIPNS_AsyncResult{Resp: env.GetIPNS} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd14.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { - continue + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_GetIPNS_AsyncResult{Err: pd14.ErrService{Cause: pd12.New(string(env.Error.Code))}} // service-level error + } else if env.GetIPNS != nil { + out = DelegatedRouting_GetIPNS_AsyncResult{Resp: env.GetIPNS} + } else { + continue + } } } @@ -1468,8 +1497,8 @@ func process_DelegatedRouting_GetIPNS_AsyncResult(ctx pd6.Context, ch chan<- Del } } -func (c *client_DelegatedRouting) PutIPNS(ctx pd6.Context, req *PutIPNSRequest) ([]*PutIPNSResponse, error) { - ctx, cancel := pd6.WithCancel(ctx) +func (c *client_DelegatedRouting) PutIPNS(ctx pd5.Context, req *PutIPNSRequest) ([]*PutIPNSResponse, error) { + ctx, cancel := pd5.WithCancel(ctx) defer cancel() ch, err := c.PutIPNS_Async(ctx, req) if err != nil { @@ -1497,27 +1526,27 @@ func (c *client_DelegatedRouting) PutIPNS(ctx pd6.Context, req *PutIPNSRequest) } } -func (c *client_DelegatedRouting) PutIPNS_Async(ctx pd6.Context, req *PutIPNSRequest) (<-chan DelegatedRouting_PutIPNS_AsyncResult, error) { +func (c *client_DelegatedRouting) PutIPNS_Async(ctx pd5.Context, req *PutIPNSRequest) (<-chan DelegatedRouting_PutIPNS_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["PutIPNS"] c.ulk.Unlock() if notSupported { - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } envelope := &AnonInductive4{ PutIPNS: req, } - buf, err := pd10.Encode(envelope, pd9.Encode) + buf, err := pd8.Encode(envelope, pd9.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd8.NewReader(buf)) + httpReq, err := pd7.NewRequestWithContext(ctx, "POST", u.String(), pd10.NewReader(buf)) if err != nil { return nil, err } @@ -1539,7 +1568,7 @@ func (c *client_DelegatedRouting) PutIPNS_Async(ctx pd6.Context, req *PutIPNSReq c.ulk.Lock() c.unsupported["PutIPNS"] = true c.ulk.Unlock() - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1547,7 +1576,7 @@ func (c *client_DelegatedRouting) PutIPNS_Async(ctx pd6.Context, req *PutIPNSReq resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1562,29 +1591,39 @@ func (c *client_DelegatedRouting) PutIPNS_Async(ctx pd6.Context, req *PutIPNSReq return ch, nil } -func process_DelegatedRouting_PutIPNS_AsyncResult(ctx pd6.Context, ch chan<- DelegatedRouting_PutIPNS_AsyncResult, r pd7.ReadCloser) { +func process_DelegatedRouting_PutIPNS_AsyncResult(ctx pd5.Context, ch chan<- DelegatedRouting_PutIPNS_AsyncResult, r pd6.ReadCloser) { defer close(ch) defer r.Close() + opt := pd9.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out DelegatedRouting_PutIPNS_AsyncResult - n, err := pd10.DecodeStreaming(r, pd9.Decode) - if pd11.Is(err, pd7.EOF) || pd11.Is(err, pd7.ErrUnexpectedEOF) { + n, err := pd8.DecodeStreaming(r, opt.Decode) + if pd12.Is(err, pd6.EOF) || pd12.Is(err, pd6.ErrUnexpectedEOF) { return } if err != nil { - out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error + out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd13.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error - } else if env.PutIPNS != nil { - out = DelegatedRouting_PutIPNS_AsyncResult{Resp: env.PutIPNS} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd14.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { - continue + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_PutIPNS_AsyncResult{Err: pd14.ErrService{Cause: pd12.New(string(env.Error.Code))}} // service-level error + } else if env.PutIPNS != nil { + out = DelegatedRouting_PutIPNS_AsyncResult{Resp: env.PutIPNS} + } else { + continue + } } } @@ -1596,16 +1635,16 @@ func process_DelegatedRouting_PutIPNS_AsyncResult(ctx pd6.Context, ch chan<- Del } } -var logger_server_DelegatedRouting = pd12.Logger("service/server/delegatedrouting") +var logger_server_DelegatedRouting = pd4.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { - FindProviders(ctx pd6.Context, req *FindProvidersRequest) (<-chan *DelegatedRouting_FindProviders_AsyncResult, error) - GetIPNS(ctx pd6.Context, req *GetIPNSRequest) (<-chan *DelegatedRouting_GetIPNS_AsyncResult, error) - PutIPNS(ctx pd6.Context, req *PutIPNSRequest) (<-chan *DelegatedRouting_PutIPNS_AsyncResult, error) + FindProviders(ctx pd5.Context, req *FindProvidersRequest) (<-chan *DelegatedRouting_FindProviders_AsyncResult, error) + GetIPNS(ctx pd5.Context, req *GetIPNSRequest) (<-chan *DelegatedRouting_GetIPNS_AsyncResult, error) + PutIPNS(ctx pd5.Context, req *PutIPNSRequest) (<-chan *DelegatedRouting_PutIPNS_AsyncResult, error) } -func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { - return func(writer pd4.ResponseWriter, request *pd4.Request) { +func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd7.HandlerFunc { + return func(writer pd7.ResponseWriter, request *pd7.Request) { // parse request msg, err := pd15.ReadAll(request.Body) if err != nil { @@ -1613,7 +1652,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { writer.WriteHeader(400) return } - n, err := pd10.Decode(msg, pd9.Decode) + n, err := pd8.Decode(msg, pd9.Decode) if err != nil { logger_server_DelegatedRouting.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1634,7 +1673,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { switch { case env.FindProviders != nil: - ch, err := s.FindProviders(pd6.Background(), env.FindProviders) + ch, err := s.FindProviders(pd5.Background(), env.FindProviders) if err != nil { logger_server_DelegatedRouting.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1648,8 +1687,8 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } else { env = &AnonInductive5{FindProviders: resp.Resp} } - var buf pd8.Buffer - if err = pd10.EncodeStreaming(&buf, env, pd9.Encode); err != nil { + var buf pd10.Buffer + if err = pd8.EncodeStreaming(&buf, env, pd9.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode response (%v)", err) continue } @@ -1658,7 +1697,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } case env.GetIPNS != nil: - ch, err := s.GetIPNS(pd6.Background(), env.GetIPNS) + ch, err := s.GetIPNS(pd5.Background(), env.GetIPNS) if err != nil { logger_server_DelegatedRouting.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1672,8 +1711,8 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } else { env = &AnonInductive5{GetIPNS: resp.Resp} } - var buf pd8.Buffer - if err = pd10.EncodeStreaming(&buf, env, pd9.Encode); err != nil { + var buf pd10.Buffer + if err = pd8.EncodeStreaming(&buf, env, pd9.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode response (%v)", err) continue } @@ -1682,7 +1721,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } case env.PutIPNS != nil: - ch, err := s.PutIPNS(pd6.Background(), env.PutIPNS) + ch, err := s.PutIPNS(pd5.Background(), env.PutIPNS) if err != nil { logger_server_DelegatedRouting.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1696,8 +1735,8 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } else { env = &AnonInductive5{PutIPNS: resp.Resp} } - var buf pd8.Buffer - if err = pd10.EncodeStreaming(&buf, env, pd9.Encode); err != nil { + var buf pd10.Buffer + if err = pd8.EncodeStreaming(&buf, env, pd9.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode response (%v)", err) continue } @@ -1716,8 +1755,8 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { }, }, } - var buf pd8.Buffer - if err = pd10.EncodeStreaming(&buf, env, pd9.Encode); err != nil { + var buf pd10.Buffer + if err = pd8.EncodeStreaming(&buf, env, pd9.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return @@ -2841,7 +2880,7 @@ func (x PutIPNSResponse) Prototype() pd1.NodePrototype { // -- protocol type LinkToAny -- -type LinkToAny pd17.Cid +type LinkToAny pd16.Cid func (v *LinkToAny) Parse(n pd1.Node) error { if n.Kind() != pd1.Kind_Link { @@ -2849,7 +2888,7 @@ func (v *LinkToAny) Parse(n pd1.Node) error { } else { ipldLink, _ := n.AsLink() // TODO: Is there a more general way to convert ipld.Link interface into a concrete user object? - cidLink, ok := ipldLink.(pd16.Link) + cidLink, ok := ipldLink.(pd17.Link) if !ok { return pd3.Errorf("only cid links are supported") } else { @@ -2924,7 +2963,7 @@ func (LinkToAny) AsBytes() ([]byte, error) { } func (v LinkToAny) AsLink() (pd1.Link, error) { - return pd16.Link{Cid: pd17.Cid(v)}, nil + return pd17.Link{Cid: pd16.Cid(v)}, nil } func (LinkToAny) Prototype() pd1.NodePrototype {