From d34b6b5bb97b4c8118567919248164e173eed758 Mon Sep 17 00:00:00 2001 From: Petar Maymounkov Date: Fri, 17 Jun 2022 10:16:37 -0700 Subject: [PATCH] support multiple responses from an HTTP RPC method invocation (#44) Support reading and writing multiple responses from a method invocation. --- blueprints/base/services.go | 1 + blueprints/base/values.go | 15 +- .../services/dagjson-over-http/client.go | 29 +- .../services/dagjson-over-http/server.go | 4 + .../gen-routing-api/proto/proto_edelweiss.go | 1448 +++++++++-------- .../api/proto/proto_edelweiss.go | 1012 ++++++------ go.mod | 12 +- go.sum | 40 +- test/harness.go | 2 +- test/service_test.go | 55 +- 10 files changed, 1357 insertions(+), 1261 deletions(-) diff --git a/blueprints/base/services.go b/blueprints/base/services.go index 283bbcd..a56f6ef 100644 --- a/blueprints/base/services.go +++ b/blueprints/base/services.go @@ -16,6 +16,7 @@ var ( HTTPHandlerFunc = cg.GoTypeRef{PkgPath: "net/http", TypeName: "HandlerFunc"} HTTPRequest = cg.GoTypeRef{PkgPath: "net/http", TypeName: "Request"} HTTPResponseWriter = cg.GoTypeRef{PkgPath: "net/http", TypeName: "ResponseWriter"} + HTTPFlusher = cg.GoTypeRef{PkgPath: "net/http", TypeName: "Flusher"} URL = cg.GoTypeRef{PkgPath: "net/url", TypeName: "URL"} URLParse = cg.GoRef{PkgPath: "net/url", Name: "Parse"} URLValues = cg.GoRef{PkgPath: "net/url", Name: "Values"} diff --git a/blueprints/base/values.go b/blueprints/base/values.go index ff6c216..4688f02 100644 --- a/blueprints/base/values.go +++ b/blueprints/base/values.go @@ -33,13 +33,14 @@ var ( IPLDLinkType = &cg.GoTypeRef{PkgPath: IPLDDatamodelPkg, TypeName: "Link"} IPLDNodePrototypeType = &cg.GoTypeRef{PkgPath: IPLDDatamodelPkg, TypeName: "NodePrototype"} - IPLDDeepEqual = &cg.GoRef{PkgPath: IPLDPkg, Name: "DeepEqual"} - IPLDEncode = &cg.GoRef{PkgPath: IPLDPkg, Name: "Encode"} - IPLDEncodeStreaming = &cg.GoRef{PkgPath: IPLDPkg, Name: "EncodeStreaming"} - IPLDDecode = &cg.GoRef{PkgPath: IPLDPkg, Name: "Decode"} - IPLDDecodeStreaming = &cg.GoRef{PkgPath: IPLDPkg, Name: "DecodeStreaming"} - DAGJSONEncode = cg.GoRef{PkgPath: "github.com/ipld/go-ipld-prime/codec/dagjson", Name: "Encode"} - DAGJSONDecode = cg.GoRef{PkgPath: "github.com/ipld/go-ipld-prime/codec/dagjson", Name: "Decode"} + IPLDDeepEqual = &cg.GoRef{PkgPath: IPLDPkg, Name: "DeepEqual"} + IPLDEncode = &cg.GoRef{PkgPath: IPLDPkg, Name: "Encode"} + IPLDEncodeStreaming = &cg.GoRef{PkgPath: IPLDPkg, Name: "EncodeStreaming"} + IPLDDecode = &cg.GoRef{PkgPath: IPLDPkg, Name: "Decode"} + IPLDDecodeStreaming = &cg.GoRef{PkgPath: IPLDPkg, Name: "DecodeStreaming"} + DAGJSONEncode = cg.GoRef{PkgPath: "github.com/ipld/go-ipld-prime/codec/dagjson", Name: "Encode"} + DAGJSONDecode = cg.GoRef{PkgPath: "github.com/ipld/go-ipld-prime/codec/dagjson", Name: "Decode"} + DAGJSONDecodeOptions = cg.GoTypeRef{PkgPath: "github.com/ipld/go-ipld-prime/codec/dagjson", TypeName: "DecodeOptions"} ) var ( diff --git a/blueprints/services/dagjson-over-http/client.go b/blueprints/services/dagjson-over-http/client.go index 876ed0a..df4c379 100644 --- a/blueprints/services/dagjson-over-http/client.go +++ b/blueprints/services/dagjson-over-http/client.go @@ -58,6 +58,7 @@ func (x GoClientImpl) GoDef() cg.Blueprint { "IOReadCloser": base.IOReadCloser, "IPLDEncode": base.IPLDEncode, "IPLDDecodeStreaming": base.IPLDDecodeStreaming, + "DAGJSONDecodeOptions": base.DAGJSONDecodeOptions, "Errorf": base.Errorf, "URLValues": base.URLValues, "HTTPNewRequestWithContext": base.HTTPNewRequestWithContext, @@ -278,10 +279,15 @@ func (c *{{.Type}}) {{.AsyncMethodDecl}} { func {{.ProcessReturnAsync}}(ctx {{.Context}}, ch chan<- {{.MethodReturnAsync}}, r {{.IOReadCloser}}) { defer close(ch) defer r.Close() + opt := {{.DAGJSONDecodeOptions}}{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out {{.MethodReturnAsync}} - n, err := {{.IPLDDecodeStreaming}}(r, {{.DAGJSONDecode}}) + n, err := {{.IPLDDecodeStreaming}}(r, opt.Decode) if {{.ErrorsIs}}(err, {{.IOEOF}}) || {{.ErrorsIs}}(err, {{.IOErrUnexpectedEOF}}) { return } @@ -289,15 +295,20 @@ func {{.ProcessReturnAsync}}(ctx {{.Context}}, ch chan<- {{.MethodReturnAsync}}, if err != nil { out = {{.MethodReturnAsync}}{Err: {{.ErrProto}}{Cause: err}} // IPLD decode error } else { - env := &{{.ReturnEnvelope}}{} - if err = env.Parse(n); err != nil { - out = {{.MethodReturnAsync}}{Err: {{.ErrProto}}{Cause: err}} // schema decode error - } else if env.Error != nil { - out = {{.MethodReturnAsync}}{Err: {{.ErrService}}{Cause: {{.ErrorsNew}}(string(env.Error.Code))}} // service-level error - } else if env.{{.MethodName}} != nil { - out = {{.MethodReturnAsync}}{Resp: env.{{.MethodName}}} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = {{.MethodReturnAsync}}{Err: {{.ErrProto}}{Cause: {{.Errorf}}("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { - continue + env := &{{.ReturnEnvelope}}{} + if err = env.Parse(n); err != nil { + out = {{.MethodReturnAsync}}{Err: {{.ErrProto}}{Cause: err}} // schema decode error + } else if env.Error != nil { + out = {{.MethodReturnAsync}}{Err: {{.ErrService}}{Cause: {{.ErrorsNew}}(string(env.Error.Code))}} // service-level error + } else if env.{{.MethodName}} != nil { + out = {{.MethodReturnAsync}}{Resp: env.{{.MethodName}}} + } else { + continue + } } } diff --git a/blueprints/services/dagjson-over-http/server.go b/blueprints/services/dagjson-over-http/server.go index df1f88e..9c92cf3 100644 --- a/blueprints/services/dagjson-over-http/server.go +++ b/blueprints/services/dagjson-over-http/server.go @@ -58,6 +58,7 @@ func (x GoServerImpl) GoDef() cg.Blueprint { "DAGJSONEncode": base.DAGJSONEncode, "EdelweissString": base.EdelweissString, "BytesBuffer": base.BytesBuffer, + "HTTPFlusher": base.HTTPFlusher, } methodDecls = append(methodDecls, cg.T{ Data: bmDecl, @@ -88,6 +89,9 @@ func (x GoServerImpl) GoDef() cg.Blueprint { } buf.WriteByte("\n"[0]) writer.Write(buf.Bytes()) + if f, ok := writer.({{.HTTPFlusher}}); ok { + f.Flush() + } } `, }) diff --git a/examples/gen-routing-api/proto/proto_edelweiss.go b/examples/gen-routing-api/proto/proto_edelweiss.go index d87222f..a0defad 100644 --- a/examples/gen-routing-api/proto/proto_edelweiss.go +++ b/examples/gen-routing-api/proto/proto_edelweiss.go @@ -3,22 +3,22 @@ package proto import ( - pd12 "bytes" - pd8 "context" - pd11 "errors" - pd2 "fmt" - pd9 "io" + pd8 "bytes" + pd4 "context" + pd10 "errors" + pd3 "fmt" + pd7 "io" pd15 "io/ioutil" - pd4 "net/http" - pd10 "net/url" - pd5 "sync" + pd11 "net/http" + pd5 "net/url" + pd13 "sync" pd14 "github.com/ipfs/go-log" - pd7 "github.com/ipld/edelweiss/services" - pd3 "github.com/ipld/edelweiss/values" - pd6 "github.com/ipld/go-ipld-prime" - pd13 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd1 "github.com/ipld/go-ipld-prime/datamodel" + pd12 "github.com/ipld/edelweiss/services" + pd1 "github.com/ipld/edelweiss/values" + pd9 "github.com/ipld/go-ipld-prime" + pd6 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd2 "github.com/ipld/go-ipld-prime/datamodel" ) // -- protocol type DelegatedRouting_IdentifyArg -- @@ -26,22 +26,22 @@ import ( type DelegatedRouting_IdentifyArg struct { } -func (x DelegatedRouting_IdentifyArg) Node() pd1.Node { +func (x DelegatedRouting_IdentifyArg) Node() pd2.Node { return x } -func (x *DelegatedRouting_IdentifyArg) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *DelegatedRouting_IdentifyArg) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { @@ -51,7 +51,7 @@ func (x *DelegatedRouting_IdentifyArg) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -63,66 +63,66 @@ type DelegatedRouting_IdentifyArg_MapIterator struct { s *DelegatedRouting_IdentifyArg } -func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_IdentifyArg_MapIterator) Done() bool { return x.i+1 >= 0 } -func (x DelegatedRouting_IdentifyArg) Kind() pd1.Kind { - return pd1.Kind_Map +func (x DelegatedRouting_IdentifyArg) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x DelegatedRouting_IdentifyArg) LookupByString(key string) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupByString(key string) (pd2.Node, error) { switch key { } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) LookupByIndex(idx int64) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) MapIterator() pd1.MapIterator { +func (x DelegatedRouting_IdentifyArg) MapIterator() pd2.MapIterator { return &DelegatedRouting_IdentifyArg_MapIterator{-1, &x} } -func (x DelegatedRouting_IdentifyArg) ListIterator() pd1.ListIterator { +func (x DelegatedRouting_IdentifyArg) ListIterator() pd2.ListIterator { return nil } @@ -139,54 +139,54 @@ func (x DelegatedRouting_IdentifyArg) IsNull() bool { } func (x DelegatedRouting_IdentifyArg) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x DelegatedRouting_IdentifyArg) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x DelegatedRouting_IdentifyArg) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x DelegatedRouting_IdentifyArg) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x DelegatedRouting_IdentifyArg) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x DelegatedRouting_IdentifyArg) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) Prototype() pd1.NodePrototype { +func (x DelegatedRouting_IdentifyArg) Prototype() pd2.NodePrototype { return nil } // -- protocol type AnonList1 -- -type AnonList1 []pd3.String +type AnonList1 []pd1.String -func (v AnonList1) Node() pd1.Node { +func (v AnonList1) Node() pd2.Node { return v } -func (v *AnonList1) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList1) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd3.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList1, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd3.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -195,39 +195,39 @@ func (v *AnonList1) Parse(n pd1.Node) error { } } -func (AnonList1) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList1) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList1) LookupByString(string) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList1) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList1) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList1) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList1) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList1) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd3.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList1) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList1) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList1) MapIterator() pd1.MapIterator { +func (AnonList1) MapIterator() pd2.MapIterator { return nil } -func (v AnonList1) ListIterator() pd1.ListIterator { +func (v AnonList1) ListIterator() pd2.ListIterator { return &AnonList1_ListIterator{v, 0} } @@ -244,30 +244,30 @@ func (AnonList1) IsNull() bool { } func (v AnonList1) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (AnonList1) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList1) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList1) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (AnonList1) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (AnonList1) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (AnonList1) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList1) Prototype() pd1.NodePrototype { +func (AnonList1) Prototype() pd2.NodePrototype { return nil // not needed } @@ -276,9 +276,9 @@ type AnonList1_ListIterator struct { at int64 } -func (iter *AnonList1_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList1_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd3.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -296,16 +296,16 @@ type DelegatedRouting_IdentifyResult struct { Methods AnonList1 } -func (x DelegatedRouting_IdentifyResult) Node() pd1.Node { +func (x DelegatedRouting_IdentifyResult) Node() pd2.Node { return x } -func (x *DelegatedRouting_IdentifyResult) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *DelegatedRouting_IdentifyResult) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Methods": x.Methods.Parse, } for !iter.Done() { @@ -313,13 +313,13 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "Methods": if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") + return pd3.Errorf("field %s already parsed", "Methods") } if err := x.Methods.Parse(vn); err != nil { return err @@ -331,7 +331,7 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -343,74 +343,74 @@ type DelegatedRouting_IdentifyResult_MapIterator struct { s *DelegatedRouting_IdentifyResult } -func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("Methods"), x.s.Methods.Node(), nil + return pd1.String("Methods"), x.s.Methods.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_IdentifyResult_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x DelegatedRouting_IdentifyResult) Kind() pd1.Kind { - return pd1.Kind_Map +func (x DelegatedRouting_IdentifyResult) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd2.Node, error) { switch key { case "Methods": return x.Methods.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Methods.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Methods": return x.Methods.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) MapIterator() pd1.MapIterator { +func (x DelegatedRouting_IdentifyResult) MapIterator() pd2.MapIterator { return &DelegatedRouting_IdentifyResult_MapIterator{-1, &x} } -func (x DelegatedRouting_IdentifyResult) ListIterator() pd1.ListIterator { +func (x DelegatedRouting_IdentifyResult) ListIterator() pd2.ListIterator { return nil } @@ -427,49 +427,49 @@ func (x DelegatedRouting_IdentifyResult) IsNull() bool { } func (x DelegatedRouting_IdentifyResult) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x DelegatedRouting_IdentifyResult) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x DelegatedRouting_IdentifyResult) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x DelegatedRouting_IdentifyResult) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x DelegatedRouting_IdentifyResult) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x DelegatedRouting_IdentifyResult) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) Prototype() pd1.NodePrototype { +func (x DelegatedRouting_IdentifyResult) Prototype() pd2.NodePrototype { return nil } // -- protocol type DelegatedRouting_Error -- type DelegatedRouting_Error struct { - Code pd3.String + Code pd1.String } -func (x DelegatedRouting_Error) Node() pd1.Node { +func (x DelegatedRouting_Error) Node() pd2.Node { return x } -func (x *DelegatedRouting_Error) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *DelegatedRouting_Error) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Code": x.Code.Parse, } for !iter.Done() { @@ -477,13 +477,13 @@ func (x *DelegatedRouting_Error) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "Code": if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") + return pd3.Errorf("field %s already parsed", "Code") } if err := x.Code.Parse(vn); err != nil { return err @@ -495,7 +495,7 @@ func (x *DelegatedRouting_Error) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -507,74 +507,74 @@ type DelegatedRouting_Error_MapIterator struct { s *DelegatedRouting_Error } -func (x *DelegatedRouting_Error_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *DelegatedRouting_Error_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("Code"), x.s.Code.Node(), nil + return pd1.String("Code"), x.s.Code.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_Error_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x DelegatedRouting_Error) Kind() pd1.Kind { - return pd1.Kind_Map +func (x DelegatedRouting_Error) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x DelegatedRouting_Error) LookupByString(key string) (pd1.Node, error) { +func (x DelegatedRouting_Error) LookupByString(key string) (pd2.Node, error) { switch key { case "Code": return x.Code.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x DelegatedRouting_Error) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd1.Node, error) { +func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Code.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x DelegatedRouting_Error) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Code": return x.Code.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) MapIterator() pd1.MapIterator { +func (x DelegatedRouting_Error) MapIterator() pd2.MapIterator { return &DelegatedRouting_Error_MapIterator{-1, &x} } -func (x DelegatedRouting_Error) ListIterator() pd1.ListIterator { +func (x DelegatedRouting_Error) ListIterator() pd2.ListIterator { return nil } @@ -591,30 +591,30 @@ func (x DelegatedRouting_Error) IsNull() bool { } func (x DelegatedRouting_Error) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x DelegatedRouting_Error) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x DelegatedRouting_Error) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x DelegatedRouting_Error) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x DelegatedRouting_Error) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x DelegatedRouting_Error) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) Prototype() pd1.NodePrototype { +func (x DelegatedRouting_Error) Prototype() pd2.NodePrototype { return nil } @@ -625,10 +625,10 @@ type AnonInductive4 struct { GetP2PProvide *GetP2PProvideRequest } -func (x *AnonInductive4) Parse(n pd1.Node) error { +func (x *AnonInductive4) Parse(n pd2.Node) error { *x = AnonInductive4{} - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -637,7 +637,7 @@ func (x *AnonInductive4) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd2.Errorf("inductive map key is not a string") + return pd3.Errorf("inductive map key is not a string") } switch k { case "IdentifyRequest": @@ -657,7 +657,7 @@ func (x *AnonInductive4) Parse(n pd1.Node) error { } - return pd2.Errorf("inductive map has no applicable keys") + return pd3.Errorf("inductive map has no applicable keys") } @@ -666,19 +666,19 @@ type AnonInductive4_MapIterator struct { s *AnonInductive4 } -func (x *AnonInductive4_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *AnonInductive4_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.Identify != nil: - return pd3.String("IdentifyRequest"), x.s.Identify.Node(), nil + return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil case x.s.GetP2PProvide != nil: - return pd3.String("GetP2PProvideRequest"), x.s.GetP2PProvide.Node(), nil + return pd1.String("GetP2PProvideRequest"), x.s.GetP2PProvide.Node(), nil default: - return nil, nil, pd2.Errorf("no inductive cases are set") + return nil, nil, pd3.Errorf("no inductive cases are set") } } } @@ -687,15 +687,15 @@ func (x *AnonInductive4_MapIterator) Done() bool { return x.done } -func (x AnonInductive4) Node() pd1.Node { +func (x AnonInductive4) Node() pd2.Node { return x } -func (x AnonInductive4) Kind() pd1.Kind { - return pd1.Kind_Map +func (x AnonInductive4) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x AnonInductive4) LookupByString(key string) (pd1.Node, error) { +func (x AnonInductive4) LookupByString(key string) (pd2.Node, error) { switch { case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil @@ -703,12 +703,12 @@ func (x AnonInductive4) LookupByString(key string) (pd1.Node, error) { return x.GetP2PProvide.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd3.ErrNA +func (x AnonInductive4) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -717,11 +717,11 @@ func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x AnonInductive4) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd3.ErrNA +func (x AnonInductive4) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x AnonInductive4) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x AnonInductive4) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "IdentifyRequest": return x.Identify.Node(), nil @@ -729,14 +729,14 @@ func (x AnonInductive4) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.GetP2PProvide.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) MapIterator() pd1.MapIterator { +func (x AnonInductive4) MapIterator() pd2.MapIterator { return &AnonInductive4_MapIterator{false, &x} } -func (x AnonInductive4) ListIterator() pd1.ListIterator { +func (x AnonInductive4) ListIterator() pd2.ListIterator { return nil } @@ -753,30 +753,30 @@ func (x AnonInductive4) IsNull() bool { } func (x AnonInductive4) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x AnonInductive4) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive4) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive4) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x AnonInductive4) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x AnonInductive4) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x AnonInductive4) Prototype() pd1.NodePrototype { +func (x AnonInductive4) Prototype() pd2.NodePrototype { return nil } @@ -788,10 +788,10 @@ type AnonInductive5 struct { Error *DelegatedRouting_Error } -func (x *AnonInductive5) Parse(n pd1.Node) error { +func (x *AnonInductive5) Parse(n pd2.Node) error { *x = AnonInductive5{} - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -800,7 +800,7 @@ func (x *AnonInductive5) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd2.Errorf("inductive map key is not a string") + return pd3.Errorf("inductive map key is not a string") } switch k { case "IdentifyResponse": @@ -827,7 +827,7 @@ func (x *AnonInductive5) Parse(n pd1.Node) error { } - return pd2.Errorf("inductive map has no applicable keys") + return pd3.Errorf("inductive map has no applicable keys") } @@ -836,21 +836,21 @@ type AnonInductive5_MapIterator struct { s *AnonInductive5 } -func (x *AnonInductive5_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *AnonInductive5_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.Identify != nil: - return pd3.String("IdentifyResponse"), x.s.Identify.Node(), nil + return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil case x.s.GetP2PProvide != nil: - return pd3.String("GetP2PProvideResponse"), x.s.GetP2PProvide.Node(), nil + return pd1.String("GetP2PProvideResponse"), x.s.GetP2PProvide.Node(), nil case x.s.Error != nil: - return pd3.String("Error"), x.s.Error.Node(), nil + return pd1.String("Error"), x.s.Error.Node(), nil default: - return nil, nil, pd2.Errorf("no inductive cases are set") + return nil, nil, pd3.Errorf("no inductive cases are set") } } } @@ -859,15 +859,15 @@ func (x *AnonInductive5_MapIterator) Done() bool { return x.done } -func (x AnonInductive5) Node() pd1.Node { +func (x AnonInductive5) Node() pd2.Node { return x } -func (x AnonInductive5) Kind() pd1.Kind { - return pd1.Kind_Map +func (x AnonInductive5) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x AnonInductive5) LookupByString(key string) (pd1.Node, error) { +func (x AnonInductive5) LookupByString(key string) (pd2.Node, error) { switch { case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil @@ -877,12 +877,12 @@ func (x AnonInductive5) LookupByString(key string) (pd1.Node, error) { return x.Error.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd3.ErrNA +func (x AnonInductive5) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -891,11 +891,11 @@ func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x AnonInductive5) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd3.ErrNA +func (x AnonInductive5) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x AnonInductive5) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x AnonInductive5) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "IdentifyResponse": return x.Identify.Node(), nil @@ -905,14 +905,14 @@ func (x AnonInductive5) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Error.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) MapIterator() pd1.MapIterator { +func (x AnonInductive5) MapIterator() pd2.MapIterator { return &AnonInductive5_MapIterator{false, &x} } -func (x AnonInductive5) ListIterator() pd1.ListIterator { +func (x AnonInductive5) ListIterator() pd2.ListIterator { return nil } @@ -929,43 +929,43 @@ func (x AnonInductive5) IsNull() bool { } func (x AnonInductive5) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x AnonInductive5) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive5) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive5) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x AnonInductive5) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x AnonInductive5) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x AnonInductive5) Prototype() pd1.NodePrototype { +func (x AnonInductive5) Prototype() pd2.NodePrototype { return nil } var logger_client_DelegatedRouting = pd14.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { - Identify(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) + Identify(ctx pd4.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) - GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) + GetP2PProvide(ctx pd4.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) - Identify_Async(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + Identify_Async(ctx pd4.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) - GetP2PProvide_Async(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) + GetP2PProvide_Async(ctx pd4.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) } type DelegatedRouting_Identify_AsyncResult struct { @@ -981,13 +981,13 @@ type DelegatedRouting_GetP2PProvide_AsyncResult struct { type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd4.Client - endpoint *pd10.URL - ulk pd5.Mutex + httpClient *pd11.Client + endpoint *pd5.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 *pd11.Client) DelegatedRouting_ClientOption { return func(c *client_DelegatedRouting) error { c.httpClient = hc return nil @@ -995,11 +995,11 @@ func DelegatedRouting_Client_WithHTTPClient(hc *pd4.Client) DelegatedRouting_Cli } func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_ClientOption) (*client_DelegatedRouting, error) { - u, err := pd10.Parse(endpoint) + u, err := pd5.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: pd11.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1008,8 +1008,8 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } -func (c *client_DelegatedRouting) Identify(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { - ctx, cancel := pd8.WithCancel(ctx) +func (c *client_DelegatedRouting) Identify(ctx pd4.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { + ctx, cancel := pd4.WithCancel(ctx) defer cancel() ch, err := c.Identify_Async(ctx, req) if err != nil { @@ -1037,27 +1037,27 @@ func (c *client_DelegatedRouting) Identify(ctx pd8.Context, req *DelegatedRoutin } } -func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { +func (c *client_DelegatedRouting) Identify_Async(ctx pd4.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, pd7.ErrSchema + return nil, pd12.ErrSchema } envelope := &AnonInductive4{ Identify: req, } - buf, err := pd6.Encode(envelope, pd13.Encode) + buf, err := pd9.Encode(envelope, pd6.Encode) if err != nil { - return nil, pd2.Errorf("unexpected serialization error (%v)", err) + return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd12.NewReader(buf)) + httpReq, err := pd11.NewRequestWithContext(ctx, "POST", u.String(), pd8.NewReader(buf)) if err != nil { return nil, err } @@ -1069,7 +1069,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated resp, err := c.httpClient.Do(httpReq) if err != nil { - return nil, pd2.Errorf("sending HTTP request (%v)", err) + return nil, pd3.Errorf("sending HTTP request (%v)", err) } // HTTP codes 400 and 404 correspond to unrecognized method or request schema @@ -1079,7 +1079,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated c.ulk.Lock() c.unsupported["Identify"] = true c.ulk.Unlock() - return nil, pd7.ErrSchema + return nil, pd12.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1087,12 +1087,12 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd7.ErrService{Cause: pd2.Errorf("%s", errValues[0])} + err = pd12.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { - err = pd2.Errorf("service rejected the call, no cause provided") + err = pd3.Errorf("service rejected the call, no cause provided") } } else { - err = pd2.Errorf("service rejected the call") + err = pd3.Errorf("service rejected the call") } return nil, err } @@ -1102,29 +1102,39 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated return ch, nil } -func process_DelegatedRouting_Identify_AsyncResult(ctx pd8.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd9.ReadCloser) { +func process_DelegatedRouting_Identify_AsyncResult(ctx pd4.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd7.ReadCloser) { defer close(ch) defer r.Close() + opt := pd6.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out DelegatedRouting_Identify_AsyncResult - n, err := pd6.DecodeStreaming(r, pd13.Decode) - if pd11.Is(err, pd9.EOF) || pd11.Is(err, pd9.ErrUnexpectedEOF) { + n, err := pd9.DecodeStreaming(r, opt.Decode) + if pd10.Is(err, pd7.EOF) || pd10.Is(err, pd7.ErrUnexpectedEOF) { return } if err != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd7.ErrProto{Cause: err}} // IPLD decode error + out = DelegatedRouting_Identify_AsyncResult{Err: pd12.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd7.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd7.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: pd12.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: pd12.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_Identify_AsyncResult{Err: pd12.ErrService{Cause: pd10.New(string(env.Error.Code))}} // service-level error + } else if env.Identify != nil { + out = DelegatedRouting_Identify_AsyncResult{Resp: env.Identify} + } else { + continue + } } } @@ -1136,8 +1146,8 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd8.Context, ch chan<- De } } -func (c *client_DelegatedRouting) GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { - ctx, cancel := pd8.WithCancel(ctx) +func (c *client_DelegatedRouting) GetP2PProvide(ctx pd4.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { + ctx, cancel := pd4.WithCancel(ctx) defer cancel() ch, err := c.GetP2PProvide_Async(ctx, req) if err != nil { @@ -1165,27 +1175,27 @@ func (c *client_DelegatedRouting) GetP2PProvide(ctx pd8.Context, req *GetP2PProv } } -func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) { +func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd4.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["GetP2PProvide"] c.ulk.Unlock() if notSupported { - return nil, pd7.ErrSchema + return nil, pd12.ErrSchema } envelope := &AnonInductive4{ GetP2PProvide: req, } - buf, err := pd6.Encode(envelope, pd13.Encode) + buf, err := pd9.Encode(envelope, pd6.Encode) if err != nil { - return nil, pd2.Errorf("unexpected serialization error (%v)", err) + return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd12.NewReader(buf)) + httpReq, err := pd11.NewRequestWithContext(ctx, "POST", u.String(), pd8.NewReader(buf)) if err != nil { return nil, err } @@ -1197,7 +1207,7 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP resp, err := c.httpClient.Do(httpReq) if err != nil { - return nil, pd2.Errorf("sending HTTP request (%v)", err) + return nil, pd3.Errorf("sending HTTP request (%v)", err) } // HTTP codes 400 and 404 correspond to unrecognized method or request schema @@ -1207,7 +1217,7 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP c.ulk.Lock() c.unsupported["GetP2PProvide"] = true c.ulk.Unlock() - return nil, pd7.ErrSchema + return nil, pd12.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1215,12 +1225,12 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd7.ErrService{Cause: pd2.Errorf("%s", errValues[0])} + err = pd12.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { - err = pd2.Errorf("service rejected the call, no cause provided") + err = pd3.Errorf("service rejected the call, no cause provided") } } else { - err = pd2.Errorf("service rejected the call") + err = pd3.Errorf("service rejected the call") } return nil, err } @@ -1230,29 +1240,39 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP return ch, nil } -func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd8.Context, ch chan<- DelegatedRouting_GetP2PProvide_AsyncResult, r pd9.ReadCloser) { +func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd4.Context, ch chan<- DelegatedRouting_GetP2PProvide_AsyncResult, r pd7.ReadCloser) { defer close(ch) defer r.Close() + opt := pd6.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out DelegatedRouting_GetP2PProvide_AsyncResult - n, err := pd6.DecodeStreaming(r, pd13.Decode) - if pd11.Is(err, pd9.EOF) || pd11.Is(err, pd9.ErrUnexpectedEOF) { + n, err := pd9.DecodeStreaming(r, opt.Decode) + if pd10.Is(err, pd7.EOF) || pd10.Is(err, pd7.ErrUnexpectedEOF) { return } if err != nil { - out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd7.ErrProto{Cause: err}} // IPLD decode error + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd12.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd7.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd7.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error - } else if env.GetP2PProvide != nil { - out = DelegatedRouting_GetP2PProvide_AsyncResult{Resp: env.GetP2PProvide} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd12.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_GetP2PProvide_AsyncResult{Err: pd12.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd12.ErrService{Cause: pd10.New(string(env.Error.Code))}} // service-level error + } else if env.GetP2PProvide != nil { + out = DelegatedRouting_GetP2PProvide_AsyncResult{Resp: env.GetP2PProvide} + } else { + continue + } } } @@ -1267,11 +1287,11 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd8.Context, ch chan var logger_server_DelegatedRouting = pd14.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { - GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) + GetP2PProvide(ctx pd4.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) } -func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { - return func(writer pd4.ResponseWriter, request *pd4.Request) { +func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd11.HandlerFunc { + return func(writer pd11.ResponseWriter, request *pd11.Request) { // parse request msg, err := pd15.ReadAll(request.Body) if err != nil { @@ -1279,7 +1299,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { writer.WriteHeader(400) return } - n, err := pd6.Decode(msg, pd13.Decode) + n, err := pd9.Decode(msg, pd6.Decode) if err != nil { logger_server_DelegatedRouting.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1300,7 +1320,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { switch { case env.GetP2PProvide != nil: - ch, err := s.GetP2PProvide(pd8.Background(), env.GetP2PProvide) + ch, err := s.GetP2PProvide(pd4.Background(), env.GetP2PProvide) if err != nil { logger_server_DelegatedRouting.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1310,12 +1330,12 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { for resp := range ch { var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &DelegatedRouting_Error{Code: pd3.String(resp.Err.Error())}} + env = &AnonInductive5{Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())}} } else { env = &AnonInductive5{GetP2PProvide: resp.Resp} } - var buf pd12.Buffer - if err = pd6.EncodeStreaming(&buf, env, pd13.Encode); err != nil { + var buf pd8.Buffer + if err = pd9.EncodeStreaming(&buf, env, pd6.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode response (%v)", err) continue } @@ -1327,13 +1347,13 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { var env *AnonInductive5 env = &AnonInductive5{ Identify: &DelegatedRouting_IdentifyResult{ - Methods: []pd3.String{ + Methods: []pd1.String{ "GetP2PProvide", }, }, } - var buf pd12.Buffer - if err = pd6.EncodeStreaming(&buf, env, pd13.Encode); err != nil { + var buf pd8.Buffer + if err = pd9.EncodeStreaming(&buf, env, pd6.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return @@ -1352,23 +1372,23 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { type AnonList7 []Multihash -func (v AnonList7) Node() pd1.Node { +func (v AnonList7) Node() pd2.Node { return v } -func (v *AnonList7) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList7) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd3.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList7, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd3.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -1377,39 +1397,39 @@ func (v *AnonList7) Parse(n pd1.Node) error { } } -func (AnonList7) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList7) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList7) LookupByString(string) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList7) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList7) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList7) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList7) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList7) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd3.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList7) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList7) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList7) MapIterator() pd1.MapIterator { +func (AnonList7) MapIterator() pd2.MapIterator { return nil } -func (v AnonList7) ListIterator() pd1.ListIterator { +func (v AnonList7) ListIterator() pd2.ListIterator { return &AnonList7_ListIterator{v, 0} } @@ -1426,30 +1446,30 @@ func (AnonList7) IsNull() bool { } func (v AnonList7) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (AnonList7) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList7) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList7) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (AnonList7) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (AnonList7) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (AnonList7) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList7) Prototype() pd1.NodePrototype { +func (AnonList7) Prototype() pd2.NodePrototype { return nil // not needed } @@ -1458,9 +1478,9 @@ type AnonList7_ListIterator struct { at int64 } -func (iter *AnonList7_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList7_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd3.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -1478,16 +1498,16 @@ type GetP2PProvideRequest struct { Keys AnonList7 } -func (x GetP2PProvideRequest) Node() pd1.Node { +func (x GetP2PProvideRequest) Node() pd2.Node { return x } -func (x *GetP2PProvideRequest) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *GetP2PProvideRequest) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Keys": x.Keys.Parse, } for !iter.Done() { @@ -1495,13 +1515,13 @@ func (x *GetP2PProvideRequest) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "Keys": if _, notParsed := fieldMap["Keys"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Keys") + return pd3.Errorf("field %s already parsed", "Keys") } if err := x.Keys.Parse(vn); err != nil { return err @@ -1513,7 +1533,7 @@ func (x *GetP2PProvideRequest) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -1525,74 +1545,74 @@ type GetP2PProvideRequest_MapIterator struct { s *GetP2PProvideRequest } -func (x *GetP2PProvideRequest_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GetP2PProvideRequest_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("Keys"), x.s.Keys.Node(), nil + return pd1.String("Keys"), x.s.Keys.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *GetP2PProvideRequest_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x GetP2PProvideRequest) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GetP2PProvideRequest) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x GetP2PProvideRequest) LookupByString(key string) (pd1.Node, error) { +func (x GetP2PProvideRequest) LookupByString(key string) (pd2.Node, error) { switch key { case "Keys": return x.Keys.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GetP2PProvideRequest) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Keys.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GetP2PProvideRequest) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Keys": return x.Keys.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) MapIterator() pd1.MapIterator { +func (x GetP2PProvideRequest) MapIterator() pd2.MapIterator { return &GetP2PProvideRequest_MapIterator{-1, &x} } -func (x GetP2PProvideRequest) ListIterator() pd1.ListIterator { +func (x GetP2PProvideRequest) ListIterator() pd2.ListIterator { return nil } @@ -1609,30 +1629,30 @@ func (x GetP2PProvideRequest) IsNull() bool { } func (x GetP2PProvideRequest) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x GetP2PProvideRequest) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x GetP2PProvideRequest) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x GetP2PProvideRequest) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x GetP2PProvideRequest) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x GetP2PProvideRequest) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) Prototype() pd1.NodePrototype { +func (x GetP2PProvideRequest) Prototype() pd2.NodePrototype { return nil } @@ -1640,23 +1660,23 @@ func (x GetP2PProvideRequest) Prototype() pd1.NodePrototype { type AnonList9 []ProvidersByKey -func (v AnonList9) Node() pd1.Node { +func (v AnonList9) Node() pd2.Node { return v } -func (v *AnonList9) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList9) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd3.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList9, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd3.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -1665,39 +1685,39 @@ func (v *AnonList9) Parse(n pd1.Node) error { } } -func (AnonList9) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList9) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList9) LookupByString(string) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList9) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList9) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList9) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList9) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList9) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd3.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList9) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList9) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList9) MapIterator() pd1.MapIterator { +func (AnonList9) MapIterator() pd2.MapIterator { return nil } -func (v AnonList9) ListIterator() pd1.ListIterator { +func (v AnonList9) ListIterator() pd2.ListIterator { return &AnonList9_ListIterator{v, 0} } @@ -1714,30 +1734,30 @@ func (AnonList9) IsNull() bool { } func (v AnonList9) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (AnonList9) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList9) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList9) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (AnonList9) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (AnonList9) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (AnonList9) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList9) Prototype() pd1.NodePrototype { +func (AnonList9) Prototype() pd2.NodePrototype { return nil // not needed } @@ -1746,9 +1766,9 @@ type AnonList9_ListIterator struct { at int64 } -func (iter *AnonList9_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList9_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd3.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -1766,16 +1786,16 @@ type GetP2PProvideResponse struct { ProvidersByKey AnonList9 } -func (x GetP2PProvideResponse) Node() pd1.Node { +func (x GetP2PProvideResponse) Node() pd2.Node { return x } -func (x *GetP2PProvideResponse) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *GetP2PProvideResponse) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "ProvidersByKey": x.ProvidersByKey.Parse, } for !iter.Done() { @@ -1783,13 +1803,13 @@ func (x *GetP2PProvideResponse) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "ProvidersByKey": if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ProvidersByKey") + return pd3.Errorf("field %s already parsed", "ProvidersByKey") } if err := x.ProvidersByKey.Parse(vn); err != nil { return err @@ -1801,7 +1821,7 @@ func (x *GetP2PProvideResponse) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -1813,74 +1833,74 @@ type GetP2PProvideResponse_MapIterator struct { s *GetP2PProvideResponse } -func (x *GetP2PProvideResponse_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GetP2PProvideResponse_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil + return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *GetP2PProvideResponse_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x GetP2PProvideResponse) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GetP2PProvideResponse) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x GetP2PProvideResponse) LookupByString(key string) (pd1.Node, error) { +func (x GetP2PProvideResponse) LookupByString(key string) (pd2.Node, error) { switch key { case "ProvidersByKey": return x.ProvidersByKey.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GetP2PProvideResponse) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.ProvidersByKey.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GetP2PProvideResponse) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "ProvidersByKey": return x.ProvidersByKey.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) MapIterator() pd1.MapIterator { +func (x GetP2PProvideResponse) MapIterator() pd2.MapIterator { return &GetP2PProvideResponse_MapIterator{-1, &x} } -func (x GetP2PProvideResponse) ListIterator() pd1.ListIterator { +func (x GetP2PProvideResponse) ListIterator() pd2.ListIterator { return nil } @@ -1897,30 +1917,30 @@ func (x GetP2PProvideResponse) IsNull() bool { } func (x GetP2PProvideResponse) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x GetP2PProvideResponse) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x GetP2PProvideResponse) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x GetP2PProvideResponse) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x GetP2PProvideResponse) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x GetP2PProvideResponse) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) Prototype() pd1.NodePrototype { +func (x GetP2PProvideResponse) Prototype() pd2.NodePrototype { return nil } @@ -1931,16 +1951,16 @@ type ProvidersByKey struct { Provider Provider } -func (x ProvidersByKey) Node() pd1.Node { +func (x ProvidersByKey) Node() pd2.Node { return x } -func (x *ProvidersByKey) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *ProvidersByKey) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Key": x.Key.Parse, "Provider": x.Provider.Parse, } @@ -1949,13 +1969,13 @@ func (x *ProvidersByKey) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "Key": if _, notParsed := fieldMap["Key"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Key") + return pd3.Errorf("field %s already parsed", "Key") } if err := x.Key.Parse(vn); err != nil { return err @@ -1963,7 +1983,7 @@ func (x *ProvidersByKey) Parse(n pd1.Node) error { delete(fieldMap, "Key") case "Provider": if _, notParsed := fieldMap["Provider"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Provider") + return pd3.Errorf("field %s already parsed", "Provider") } if err := x.Provider.Parse(vn); err != nil { return err @@ -1975,7 +1995,7 @@ func (x *ProvidersByKey) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -1987,27 +2007,27 @@ type ProvidersByKey_MapIterator struct { s *ProvidersByKey } -func (x *ProvidersByKey_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *ProvidersByKey_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("Key"), x.s.Key.Node(), nil + return pd1.String("Key"), x.s.Key.Node(), nil case 1: - return pd3.String("Provider"), x.s.Provider.Node(), nil + return pd1.String("Provider"), x.s.Provider.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *ProvidersByKey_MapIterator) Done() bool { return x.i+1 >= 2 } -func (x ProvidersByKey) Kind() pd1.Kind { - return pd1.Kind_Map +func (x ProvidersByKey) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x ProvidersByKey) LookupByString(key string) (pd1.Node, error) { +func (x ProvidersByKey) LookupByString(key string) (pd2.Node, error) { switch key { case "Key": return x.Key.Node(), nil @@ -2015,28 +2035,28 @@ func (x ProvidersByKey) LookupByString(key string) (pd1.Node, error) { return x.Provider.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x ProvidersByKey) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x ProvidersByKey) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x ProvidersByKey) LookupByIndex(idx int64) (pd1.Node, error) { +func (x ProvidersByKey) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Key.Node(), nil @@ -2044,10 +2064,10 @@ func (x ProvidersByKey) LookupByIndex(idx int64) (pd1.Node, error) { return x.Provider.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x ProvidersByKey) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x ProvidersByKey) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Key": return x.Key.Node(), nil @@ -2055,14 +2075,14 @@ func (x ProvidersByKey) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Provider.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x ProvidersByKey) MapIterator() pd1.MapIterator { +func (x ProvidersByKey) MapIterator() pd2.MapIterator { return &ProvidersByKey_MapIterator{-1, &x} } -func (x ProvidersByKey) ListIterator() pd1.ListIterator { +func (x ProvidersByKey) ListIterator() pd2.ListIterator { return nil } @@ -2079,49 +2099,49 @@ func (x ProvidersByKey) IsNull() bool { } func (x ProvidersByKey) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x ProvidersByKey) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x ProvidersByKey) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x ProvidersByKey) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x ProvidersByKey) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x ProvidersByKey) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x ProvidersByKey) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x ProvidersByKey) Prototype() pd1.NodePrototype { +func (x ProvidersByKey) Prototype() pd2.NodePrototype { return nil } // -- protocol type Multihash -- type Multihash struct { - Bytes pd3.Bytes + Bytes pd1.Bytes } -func (x Multihash) Node() pd1.Node { +func (x Multihash) Node() pd2.Node { return x } -func (x *Multihash) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *Multihash) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Bytes": x.Bytes.Parse, } for !iter.Done() { @@ -2129,13 +2149,13 @@ func (x *Multihash) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "Bytes": if _, notParsed := fieldMap["Bytes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Bytes") + return pd3.Errorf("field %s already parsed", "Bytes") } if err := x.Bytes.Parse(vn); err != nil { return err @@ -2147,7 +2167,7 @@ func (x *Multihash) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -2159,74 +2179,74 @@ type Multihash_MapIterator struct { s *Multihash } -func (x *Multihash_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *Multihash_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("Bytes"), x.s.Bytes.Node(), nil + return pd1.String("Bytes"), x.s.Bytes.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *Multihash_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x Multihash) Kind() pd1.Kind { - return pd1.Kind_Map +func (x Multihash) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x Multihash) LookupByString(key string) (pd1.Node, error) { +func (x Multihash) LookupByString(key string) (pd2.Node, error) { switch key { case "Bytes": return x.Bytes.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Multihash) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x Multihash) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Multihash) LookupByIndex(idx int64) (pd1.Node, error) { +func (x Multihash) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Bytes.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Multihash) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x Multihash) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Bytes": return x.Bytes.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Multihash) MapIterator() pd1.MapIterator { +func (x Multihash) MapIterator() pd2.MapIterator { return &Multihash_MapIterator{-1, &x} } -func (x Multihash) ListIterator() pd1.ListIterator { +func (x Multihash) ListIterator() pd2.ListIterator { return nil } @@ -2243,30 +2263,30 @@ func (x Multihash) IsNull() bool { } func (x Multihash) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x Multihash) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Multihash) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Multihash) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x Multihash) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Multihash) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x Multihash) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x Multihash) Prototype() pd1.NodePrototype { +func (x Multihash) Prototype() pd2.NodePrototype { return nil } @@ -2274,23 +2294,23 @@ func (x Multihash) Prototype() pd1.NodePrototype { type AnonList13 []Node -func (v AnonList13) Node() pd1.Node { +func (v AnonList13) Node() pd2.Node { return v } -func (v *AnonList13) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList13) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd3.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList13, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd3.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -2299,39 +2319,39 @@ func (v *AnonList13) Parse(n pd1.Node) error { } } -func (AnonList13) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList13) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList13) LookupByString(string) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList13) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList13) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList13) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList13) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList13) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd3.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList13) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList13) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList13) MapIterator() pd1.MapIterator { +func (AnonList13) MapIterator() pd2.MapIterator { return nil } -func (v AnonList13) ListIterator() pd1.ListIterator { +func (v AnonList13) ListIterator() pd2.ListIterator { return &AnonList13_ListIterator{v, 0} } @@ -2348,30 +2368,30 @@ func (AnonList13) IsNull() bool { } func (v AnonList13) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (AnonList13) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList13) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList13) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (AnonList13) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (AnonList13) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (AnonList13) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList13) Prototype() pd1.NodePrototype { +func (AnonList13) Prototype() pd2.NodePrototype { return nil // not needed } @@ -2380,9 +2400,9 @@ type AnonList13_ListIterator struct { at int64 } -func (iter *AnonList13_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList13_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd3.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -2398,23 +2418,23 @@ func (iter *AnonList13_ListIterator) Done() bool { type AnonList14 []TransferProto -func (v AnonList14) Node() pd1.Node { +func (v AnonList14) Node() pd2.Node { return v } -func (v *AnonList14) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList14) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd3.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList14, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd3.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -2423,39 +2443,39 @@ func (v *AnonList14) Parse(n pd1.Node) error { } } -func (AnonList14) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList14) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList14) LookupByString(string) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList14) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList14) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList14) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList14) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList14) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd3.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList14) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList14) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList14) MapIterator() pd1.MapIterator { +func (AnonList14) MapIterator() pd2.MapIterator { return nil } -func (v AnonList14) ListIterator() pd1.ListIterator { +func (v AnonList14) ListIterator() pd2.ListIterator { return &AnonList14_ListIterator{v, 0} } @@ -2472,30 +2492,30 @@ func (AnonList14) IsNull() bool { } func (v AnonList14) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (AnonList14) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList14) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList14) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (AnonList14) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (AnonList14) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (AnonList14) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList14) Prototype() pd1.NodePrototype { +func (AnonList14) Prototype() pd2.NodePrototype { return nil // not needed } @@ -2504,9 +2524,9 @@ type AnonList14_ListIterator struct { at int64 } -func (iter *AnonList14_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList14_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd3.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -2525,16 +2545,16 @@ type Provider struct { Proto AnonList14 } -func (x Provider) Node() pd1.Node { +func (x Provider) Node() pd2.Node { return x } -func (x *Provider) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *Provider) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Nodes": x.Nodes.Parse, "Proto": x.Proto.Parse, } @@ -2543,13 +2563,13 @@ func (x *Provider) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "Nodes": if _, notParsed := fieldMap["Nodes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Nodes") + return pd3.Errorf("field %s already parsed", "Nodes") } if err := x.Nodes.Parse(vn); err != nil { return err @@ -2557,7 +2577,7 @@ func (x *Provider) Parse(n pd1.Node) error { delete(fieldMap, "Nodes") case "Proto": if _, notParsed := fieldMap["Proto"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Proto") + return pd3.Errorf("field %s already parsed", "Proto") } if err := x.Proto.Parse(vn); err != nil { return err @@ -2569,7 +2589,7 @@ func (x *Provider) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -2581,27 +2601,27 @@ type Provider_MapIterator struct { s *Provider } -func (x *Provider_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *Provider_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("Nodes"), x.s.Nodes.Node(), nil + return pd1.String("Nodes"), x.s.Nodes.Node(), nil case 1: - return pd3.String("Proto"), x.s.Proto.Node(), nil + return pd1.String("Proto"), x.s.Proto.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *Provider_MapIterator) Done() bool { return x.i+1 >= 2 } -func (x Provider) Kind() pd1.Kind { - return pd1.Kind_Map +func (x Provider) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x Provider) LookupByString(key string) (pd1.Node, error) { +func (x Provider) LookupByString(key string) (pd2.Node, error) { switch key { case "Nodes": return x.Nodes.Node(), nil @@ -2609,28 +2629,28 @@ func (x Provider) LookupByString(key string) (pd1.Node, error) { return x.Proto.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Provider) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x Provider) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Provider) LookupByIndex(idx int64) (pd1.Node, error) { +func (x Provider) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Nodes.Node(), nil @@ -2638,10 +2658,10 @@ func (x Provider) LookupByIndex(idx int64) (pd1.Node, error) { return x.Proto.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Provider) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x Provider) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Nodes": return x.Nodes.Node(), nil @@ -2649,14 +2669,14 @@ func (x Provider) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Proto.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Provider) MapIterator() pd1.MapIterator { +func (x Provider) MapIterator() pd2.MapIterator { return &Provider_MapIterator{-1, &x} } -func (x Provider) ListIterator() pd1.ListIterator { +func (x Provider) ListIterator() pd2.ListIterator { return nil } @@ -2673,30 +2693,30 @@ func (x Provider) IsNull() bool { } func (x Provider) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x Provider) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Provider) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Provider) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x Provider) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Provider) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x Provider) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x Provider) Prototype() pd1.NodePrototype { +func (x Provider) Prototype() pd2.NodePrototype { return nil } @@ -2706,10 +2726,10 @@ type Node struct { Peer *Peer } -func (x *Node) Parse(n pd1.Node) error { +func (x *Node) Parse(n pd2.Node) error { *x = Node{} - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -2718,7 +2738,7 @@ func (x *Node) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd2.Errorf("inductive map key is not a string") + return pd3.Errorf("inductive map key is not a string") } switch k { case "Peer": @@ -2731,7 +2751,7 @@ func (x *Node) Parse(n pd1.Node) error { } - return pd2.Errorf("inductive map has no applicable keys") + return pd3.Errorf("inductive map has no applicable keys") } @@ -2740,17 +2760,17 @@ type Node_MapIterator struct { s *Node } -func (x *Node_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *Node_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.Peer != nil: - return pd3.String("Peer"), x.s.Peer.Node(), nil + return pd1.String("Peer"), x.s.Peer.Node(), nil default: - return nil, nil, pd2.Errorf("no inductive cases are set") + return nil, nil, pd3.Errorf("no inductive cases are set") } } } @@ -2759,26 +2779,26 @@ func (x *Node_MapIterator) Done() bool { return x.done } -func (x Node) Node() pd1.Node { +func (x Node) Node() pd2.Node { return x } -func (x Node) Kind() pd1.Kind { - return pd1.Kind_Map +func (x Node) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x Node) LookupByString(key string) (pd1.Node, error) { +func (x Node) LookupByString(key string) (pd2.Node, error) { switch { case x.Peer != nil && key == "Peer": return x.Peer.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Node) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd3.ErrNA +func (x Node) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -2787,24 +2807,24 @@ func (x Node) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x Node) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd3.ErrNA +func (x Node) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x Node) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x Node) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "Peer": return x.Peer.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Node) MapIterator() pd1.MapIterator { +func (x Node) MapIterator() pd2.MapIterator { return &Node_MapIterator{false, &x} } -func (x Node) ListIterator() pd1.ListIterator { +func (x Node) ListIterator() pd2.ListIterator { return nil } @@ -2821,54 +2841,54 @@ func (x Node) IsNull() bool { } func (x Node) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x Node) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Node) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Node) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x Node) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Node) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x Node) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x Node) Prototype() pd1.NodePrototype { +func (x Node) Prototype() pd2.NodePrototype { return nil } // -- protocol type AnonList17 -- -type AnonList17 []pd3.Bytes +type AnonList17 []pd1.Bytes -func (v AnonList17) Node() pd1.Node { +func (v AnonList17) Node() pd2.Node { return v } -func (v *AnonList17) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList17) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd3.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList17, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd3.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -2877,39 +2897,39 @@ func (v *AnonList17) Parse(n pd1.Node) error { } } -func (AnonList17) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList17) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList17) LookupByString(string) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList17) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList17) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd3.ErrNA +func (AnonList17) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList17) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList17) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd3.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList17) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList17) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList17) MapIterator() pd1.MapIterator { +func (AnonList17) MapIterator() pd2.MapIterator { return nil } -func (v AnonList17) ListIterator() pd1.ListIterator { +func (v AnonList17) ListIterator() pd2.ListIterator { return &AnonList17_ListIterator{v, 0} } @@ -2926,30 +2946,30 @@ func (AnonList17) IsNull() bool { } func (v AnonList17) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (AnonList17) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList17) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (AnonList17) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (AnonList17) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (AnonList17) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (AnonList17) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList17) Prototype() pd1.NodePrototype { +func (AnonList17) Prototype() pd2.NodePrototype { return nil // not needed } @@ -2958,9 +2978,9 @@ type AnonList17_ListIterator struct { at int64 } -func (iter *AnonList17_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList17_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd3.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -2975,20 +2995,20 @@ func (iter *AnonList17_ListIterator) Done() bool { // -- protocol type Peer -- type Peer struct { - ID pd3.Bytes + ID pd1.Bytes Multiaddresses AnonList17 } -func (x Peer) Node() pd1.Node { +func (x Peer) Node() pd2.Node { return x } -func (x *Peer) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *Peer) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "ID": x.ID.Parse, "Multiaddresses": x.Multiaddresses.Parse, } @@ -2997,13 +3017,13 @@ func (x *Peer) Parse(n pd1.Node) error { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { case "ID": if _, notParsed := fieldMap["ID"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ID") + return pd3.Errorf("field %s already parsed", "ID") } if err := x.ID.Parse(vn); err != nil { return err @@ -3011,7 +3031,7 @@ func (x *Peer) Parse(n pd1.Node) error { delete(fieldMap, "ID") case "Multiaddresses": if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Multiaddresses") + return pd3.Errorf("field %s already parsed", "Multiaddresses") } if err := x.Multiaddresses.Parse(vn); err != nil { return err @@ -3023,7 +3043,7 @@ func (x *Peer) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -3035,27 +3055,27 @@ type Peer_MapIterator struct { s *Peer } -func (x *Peer_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *Peer_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd3.String("ID"), x.s.ID.Node(), nil + return pd1.String("ID"), x.s.ID.Node(), nil case 1: - return pd3.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil + return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *Peer_MapIterator) Done() bool { return x.i+1 >= 2 } -func (x Peer) Kind() pd1.Kind { - return pd1.Kind_Map +func (x Peer) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x Peer) LookupByString(key string) (pd1.Node, error) { +func (x Peer) LookupByString(key string) (pd2.Node, error) { switch key { case "ID": return x.ID.Node(), nil @@ -3063,28 +3083,28 @@ func (x Peer) LookupByString(key string) (pd1.Node, error) { return x.Multiaddresses.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Peer) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x Peer) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Peer) LookupByIndex(idx int64) (pd1.Node, error) { +func (x Peer) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.ID.Node(), nil @@ -3092,10 +3112,10 @@ func (x Peer) LookupByIndex(idx int64) (pd1.Node, error) { return x.Multiaddresses.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Peer) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x Peer) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "ID": return x.ID.Node(), nil @@ -3103,14 +3123,14 @@ func (x Peer) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Multiaddresses.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Peer) MapIterator() pd1.MapIterator { +func (x Peer) MapIterator() pd2.MapIterator { return &Peer_MapIterator{-1, &x} } -func (x Peer) ListIterator() pd1.ListIterator { +func (x Peer) ListIterator() pd2.ListIterator { return nil } @@ -3127,30 +3147,30 @@ func (x Peer) IsNull() bool { } func (x Peer) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x Peer) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Peer) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x Peer) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x Peer) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x Peer) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x Peer) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x Peer) Prototype() pd1.NodePrototype { +func (x Peer) Prototype() pd2.NodePrototype { return nil } @@ -3160,10 +3180,10 @@ type TransferProto struct { Bitswap *BitswapTransfer } -func (x *TransferProto) Parse(n pd1.Node) error { +func (x *TransferProto) Parse(n pd2.Node) error { *x = TransferProto{} - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -3172,7 +3192,7 @@ func (x *TransferProto) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd2.Errorf("inductive map key is not a string") + return pd3.Errorf("inductive map key is not a string") } switch k { case "Bitswap": @@ -3185,7 +3205,7 @@ func (x *TransferProto) Parse(n pd1.Node) error { } - return pd2.Errorf("inductive map has no applicable keys") + return pd3.Errorf("inductive map has no applicable keys") } @@ -3194,17 +3214,17 @@ type TransferProto_MapIterator struct { s *TransferProto } -func (x *TransferProto_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *TransferProto_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.Bitswap != nil: - return pd3.String("Bitswap"), x.s.Bitswap.Node(), nil + return pd1.String("Bitswap"), x.s.Bitswap.Node(), nil default: - return nil, nil, pd2.Errorf("no inductive cases are set") + return nil, nil, pd3.Errorf("no inductive cases are set") } } } @@ -3213,26 +3233,26 @@ func (x *TransferProto_MapIterator) Done() bool { return x.done } -func (x TransferProto) Node() pd1.Node { +func (x TransferProto) Node() pd2.Node { return x } -func (x TransferProto) Kind() pd1.Kind { - return pd1.Kind_Map +func (x TransferProto) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x TransferProto) LookupByString(key string) (pd1.Node, error) { +func (x TransferProto) LookupByString(key string) (pd2.Node, error) { switch { case x.Bitswap != nil && key == "Bitswap": return x.Bitswap.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x TransferProto) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd3.ErrNA +func (x TransferProto) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -3241,24 +3261,24 @@ func (x TransferProto) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x TransferProto) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd3.ErrNA +func (x TransferProto) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x TransferProto) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x TransferProto) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "Bitswap": return x.Bitswap.Node(), nil } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x TransferProto) MapIterator() pd1.MapIterator { +func (x TransferProto) MapIterator() pd2.MapIterator { return &TransferProto_MapIterator{false, &x} } -func (x TransferProto) ListIterator() pd1.ListIterator { +func (x TransferProto) ListIterator() pd2.ListIterator { return nil } @@ -3275,30 +3295,30 @@ func (x TransferProto) IsNull() bool { } func (x TransferProto) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x TransferProto) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x TransferProto) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x TransferProto) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x TransferProto) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x TransferProto) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x TransferProto) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x TransferProto) Prototype() pd1.NodePrototype { +func (x TransferProto) Prototype() pd2.NodePrototype { return nil } @@ -3307,22 +3327,22 @@ func (x TransferProto) Prototype() pd1.NodePrototype { type BitswapTransfer struct { } -func (x BitswapTransfer) Node() pd1.Node { +func (x BitswapTransfer) Node() pd2.Node { return x } -func (x *BitswapTransfer) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd3.ErrNA +func (x *BitswapTransfer) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd3.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd2.Errorf("structure map key is not a string") + return pd3.Errorf("structure map key is not a string") } else { _ = vn switch k { @@ -3332,7 +3352,7 @@ func (x *BitswapTransfer) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -3344,66 +3364,66 @@ type BitswapTransfer_MapIterator struct { s *BitswapTransfer } -func (x *BitswapTransfer_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *BitswapTransfer_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { } - return nil, nil, pd3.ErrNA + return nil, nil, pd1.ErrNA } func (x *BitswapTransfer_MapIterator) Done() bool { return x.i+1 >= 0 } -func (x BitswapTransfer) Kind() pd1.Kind { - return pd1.Kind_Map +func (x BitswapTransfer) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x BitswapTransfer) LookupByString(key string) (pd1.Node, error) { +func (x BitswapTransfer) LookupByString(key string) (pd2.Node, error) { switch key { } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x BitswapTransfer) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x BitswapTransfer) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x BitswapTransfer) LookupByIndex(idx int64) (pd1.Node, error) { +func (x BitswapTransfer) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x BitswapTransfer) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x BitswapTransfer) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { } - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x BitswapTransfer) MapIterator() pd1.MapIterator { +func (x BitswapTransfer) MapIterator() pd2.MapIterator { return &BitswapTransfer_MapIterator{-1, &x} } -func (x BitswapTransfer) ListIterator() pd1.ListIterator { +func (x BitswapTransfer) ListIterator() pd2.ListIterator { return nil } @@ -3420,29 +3440,29 @@ func (x BitswapTransfer) IsNull() bool { } func (x BitswapTransfer) AsBool() (bool, error) { - return false, pd3.ErrNA + return false, pd1.ErrNA } func (x BitswapTransfer) AsInt() (int64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x BitswapTransfer) AsFloat() (float64, error) { - return 0, pd3.ErrNA + return 0, pd1.ErrNA } func (x BitswapTransfer) AsString() (string, error) { - return "", pd3.ErrNA + return "", pd1.ErrNA } func (x BitswapTransfer) AsBytes() ([]byte, error) { - return nil, pd3.ErrNA + return nil, pd1.ErrNA } -func (x BitswapTransfer) AsLink() (pd1.Link, error) { - return nil, pd3.ErrNA +func (x BitswapTransfer) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x BitswapTransfer) Prototype() pd1.NodePrototype { +func (x BitswapTransfer) Prototype() pd2.NodePrototype { return nil } diff --git a/examples/greeting-service/api/proto/proto_edelweiss.go b/examples/greeting-service/api/proto/proto_edelweiss.go index 7d508be..447f4f0 100644 --- a/examples/greeting-service/api/proto/proto_edelweiss.go +++ b/examples/greeting-service/api/proto/proto_edelweiss.go @@ -4,21 +4,21 @@ package proto import ( pd11 "bytes" - pd6 "context" - pd9 "errors" + pd5 "context" + pd7 "errors" pd3 "fmt" pd8 "io" pd15 "io/ioutil" - pd5 "net/http" + pd9 "net/http" pd10 "net/url" - pd12 "sync" - - pd13 "github.com/ipfs/go-log" - pd14 "github.com/ipld/edelweiss/services" - pd1 "github.com/ipld/edelweiss/values" - pd4 "github.com/ipld/go-ipld-prime" - pd7 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd2 "github.com/ipld/go-ipld-prime/datamodel" + pd14 "sync" + + pd12 "github.com/ipfs/go-log" + pd13 "github.com/ipld/edelweiss/services" + pd2 "github.com/ipld/edelweiss/values" + pd6 "github.com/ipld/go-ipld-prime" + pd4 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd1 "github.com/ipld/go-ipld-prime/datamodel" ) // -- protocol type GreetingService_IdentifyArg -- @@ -26,16 +26,16 @@ import ( type GreetingService_IdentifyArg struct { } -func (x GreetingService_IdentifyArg) Node() pd2.Node { +func (x GreetingService_IdentifyArg) Node() pd1.Node { return x } -func (x *GreetingService_IdentifyArg) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA +func (x *GreetingService_IdentifyArg) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{} + fieldMap := map[string]pd2.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -51,7 +51,7 @@ func (x *GreetingService_IdentifyArg) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd1.Null); err != nil { return err } } @@ -63,66 +63,66 @@ type GreetingService_IdentifyArg_MapIterator struct { s *GreetingService_IdentifyArg } -func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { x.i++ switch x.i { } - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } func (x *GreetingService_IdentifyArg_MapIterator) Done() bool { return x.i+1 >= 0 } -func (x GreetingService_IdentifyArg) Kind() pd2.Kind { - return pd2.Kind_Map +func (x GreetingService_IdentifyArg) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x GreetingService_IdentifyArg) LookupByString(key string) (pd2.Node, error) { +func (x GreetingService_IdentifyArg) LookupByString(key string) (pd1.Node, error) { switch key { } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyArg) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x GreetingService_IdentifyArg) LookupByNode(key pd1.Node) (pd1.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd1.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd1.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyArg) LookupByIndex(idx int64) (pd2.Node, error) { +func (x GreetingService_IdentifyArg) LookupByIndex(idx int64) (pd1.Node, error) { switch idx { } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyArg) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x GreetingService_IdentifyArg) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyArg) MapIterator() pd2.MapIterator { +func (x GreetingService_IdentifyArg) MapIterator() pd1.MapIterator { return &GreetingService_IdentifyArg_MapIterator{-1, &x} } -func (x GreetingService_IdentifyArg) ListIterator() pd2.ListIterator { +func (x GreetingService_IdentifyArg) ListIterator() pd1.ListIterator { return nil } @@ -139,54 +139,54 @@ func (x GreetingService_IdentifyArg) IsNull() bool { } func (x GreetingService_IdentifyArg) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x GreetingService_IdentifyArg) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x GreetingService_IdentifyArg) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x GreetingService_IdentifyArg) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x GreetingService_IdentifyArg) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyArg) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x GreetingService_IdentifyArg) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyArg) Prototype() pd2.NodePrototype { +func (x GreetingService_IdentifyArg) Prototype() pd1.NodePrototype { return nil } // -- protocol type AnonList1 -- -type AnonList1 []pd1.String +type AnonList1 []pd2.String -func (v AnonList1) Node() pd2.Node { +func (v AnonList1) Node() pd1.Node { return v } -func (v *AnonList1) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList1) Parse(n pd1.Node) error { + if n.Kind() == pd1.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { - return pd1.ErrNA + if n.Kind() != pd1.Kind_List { + return pd2.ErrNA } else { *v = make(AnonList1, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd1.ErrNA + return pd2.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -195,39 +195,39 @@ func (v *AnonList1) Parse(n pd2.Node) error { } } -func (AnonList1) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList1) Kind() pd1.Kind { + return pd1.Kind_List } -func (AnonList1) LookupByString(string) (pd2.Node, error) { - return nil, pd1.ErrNA +func (AnonList1) LookupByString(string) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (AnonList1) LookupByNode(key pd2.Node) (pd2.Node, error) { - return nil, pd1.ErrNA +func (AnonList1) LookupByNode(key pd1.Node) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (v AnonList1) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList1) LookupByIndex(i int64) (pd1.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd1.ErrBounds + return nil, pd2.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList1) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList1) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList1) MapIterator() pd2.MapIterator { +func (AnonList1) MapIterator() pd1.MapIterator { return nil } -func (v AnonList1) ListIterator() pd2.ListIterator { +func (v AnonList1) ListIterator() pd1.ListIterator { return &AnonList1_ListIterator{v, 0} } @@ -244,30 +244,30 @@ func (AnonList1) IsNull() bool { } func (v AnonList1) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (AnonList1) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (AnonList1) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (AnonList1) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (AnonList1) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (AnonList1) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (AnonList1) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (AnonList1) Prototype() pd2.NodePrototype { +func (AnonList1) Prototype() pd1.NodePrototype { return nil // not needed } @@ -276,9 +276,9 @@ type AnonList1_ListIterator struct { at int64 } -func (iter *AnonList1_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList1_ListIterator) Next() (int64, pd1.Node, error) { if iter.Done() { - return -1, nil, pd1.ErrBounds + return -1, nil, pd2.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -296,16 +296,16 @@ type GreetingService_IdentifyResult struct { Methods AnonList1 } -func (x GreetingService_IdentifyResult) Node() pd2.Node { +func (x GreetingService_IdentifyResult) Node() pd1.Node { return x } -func (x *GreetingService_IdentifyResult) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA +func (x *GreetingService_IdentifyResult) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ + fieldMap := map[string]pd2.ParseFunc{ "Methods": x.Methods.Parse, } for !iter.Done() { @@ -331,7 +331,7 @@ func (x *GreetingService_IdentifyResult) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd1.Null); err != nil { return err } } @@ -343,74 +343,74 @@ type GreetingService_IdentifyResult_MapIterator struct { s *GreetingService_IdentifyResult } -func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { x.i++ switch x.i { case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + return pd2.String("Methods"), x.s.Methods.Node(), nil } - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } func (x *GreetingService_IdentifyResult_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x GreetingService_IdentifyResult) Kind() pd2.Kind { - return pd2.Kind_Map +func (x GreetingService_IdentifyResult) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x GreetingService_IdentifyResult) LookupByString(key string) (pd2.Node, error) { +func (x GreetingService_IdentifyResult) LookupByString(key string) (pd1.Node, error) { switch key { case "Methods": return x.Methods.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyResult) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x GreetingService_IdentifyResult) LookupByNode(key pd1.Node) (pd1.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd1.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd1.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd2.Node, error) { +func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd1.Node, error) { switch idx { case 0: return x.Methods.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyResult) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x GreetingService_IdentifyResult) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "0", "Methods": return x.Methods.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyResult) MapIterator() pd2.MapIterator { +func (x GreetingService_IdentifyResult) MapIterator() pd1.MapIterator { return &GreetingService_IdentifyResult_MapIterator{-1, &x} } -func (x GreetingService_IdentifyResult) ListIterator() pd2.ListIterator { +func (x GreetingService_IdentifyResult) ListIterator() pd1.ListIterator { return nil } @@ -427,49 +427,49 @@ func (x GreetingService_IdentifyResult) IsNull() bool { } func (x GreetingService_IdentifyResult) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x GreetingService_IdentifyResult) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x GreetingService_IdentifyResult) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x GreetingService_IdentifyResult) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x GreetingService_IdentifyResult) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyResult) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x GreetingService_IdentifyResult) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x GreetingService_IdentifyResult) Prototype() pd2.NodePrototype { +func (x GreetingService_IdentifyResult) Prototype() pd1.NodePrototype { return nil } // -- protocol type GreetingService_Error -- type GreetingService_Error struct { - Code pd1.String + Code pd2.String } -func (x GreetingService_Error) Node() pd2.Node { +func (x GreetingService_Error) Node() pd1.Node { return x } -func (x *GreetingService_Error) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA +func (x *GreetingService_Error) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ + fieldMap := map[string]pd2.ParseFunc{ "Code": x.Code.Parse, } for !iter.Done() { @@ -495,7 +495,7 @@ func (x *GreetingService_Error) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd1.Null); err != nil { return err } } @@ -507,74 +507,74 @@ type GreetingService_Error_MapIterator struct { s *GreetingService_Error } -func (x *GreetingService_Error_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *GreetingService_Error_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { x.i++ switch x.i { case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + return pd2.String("Code"), x.s.Code.Node(), nil } - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } func (x *GreetingService_Error_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x GreetingService_Error) Kind() pd2.Kind { - return pd2.Kind_Map +func (x GreetingService_Error) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x GreetingService_Error) LookupByString(key string) (pd2.Node, error) { +func (x GreetingService_Error) LookupByString(key string) (pd1.Node, error) { switch key { case "Code": return x.Code.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_Error) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x GreetingService_Error) LookupByNode(key pd1.Node) (pd1.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd1.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd1.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_Error) LookupByIndex(idx int64) (pd2.Node, error) { +func (x GreetingService_Error) LookupByIndex(idx int64) (pd1.Node, error) { switch idx { case 0: return x.Code.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_Error) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x GreetingService_Error) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "0", "Code": return x.Code.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_Error) MapIterator() pd2.MapIterator { +func (x GreetingService_Error) MapIterator() pd1.MapIterator { return &GreetingService_Error_MapIterator{-1, &x} } -func (x GreetingService_Error) ListIterator() pd2.ListIterator { +func (x GreetingService_Error) ListIterator() pd1.ListIterator { return nil } @@ -591,30 +591,30 @@ func (x GreetingService_Error) IsNull() bool { } func (x GreetingService_Error) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x GreetingService_Error) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x GreetingService_Error) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x GreetingService_Error) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x GreetingService_Error) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x GreetingService_Error) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x GreetingService_Error) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x GreetingService_Error) Prototype() pd2.NodePrototype { +func (x GreetingService_Error) Prototype() pd1.NodePrototype { return nil } @@ -625,10 +625,10 @@ type AnonInductive4 struct { Hello *HelloRequest } -func (x *AnonInductive4) Parse(n pd2.Node) error { +func (x *AnonInductive4) Parse(n pd1.Node) error { *x = AnonInductive4{} - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -666,16 +666,16 @@ type AnonInductive4_MapIterator struct { s *AnonInductive4 } -func (x *AnonInductive4_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *AnonInductive4_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { if x.done { - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } else { x.done = true switch { case x.s.Identify != nil: - return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil + return pd2.String("IdentifyRequest"), x.s.Identify.Node(), nil case x.s.Hello != nil: - return pd1.String("HelloRequest"), x.s.Hello.Node(), nil + return pd2.String("HelloRequest"), x.s.Hello.Node(), nil default: return nil, nil, pd3.Errorf("no inductive cases are set") @@ -687,15 +687,15 @@ func (x *AnonInductive4_MapIterator) Done() bool { return x.done } -func (x AnonInductive4) Node() pd2.Node { +func (x AnonInductive4) Node() pd1.Node { return x } -func (x AnonInductive4) Kind() pd2.Kind { - return pd2.Kind_Map +func (x AnonInductive4) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x AnonInductive4) LookupByString(key string) (pd2.Node, error) { +func (x AnonInductive4) LookupByString(key string) (pd1.Node, error) { switch { case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil @@ -703,12 +703,12 @@ func (x AnonInductive4) LookupByString(key string) (pd2.Node, error) { return x.Hello.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x AnonInductive4) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { - return nil, pd1.ErrNA +func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { + if key.Kind() != pd1.Kind_String { + return nil, pd2.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -717,11 +717,11 @@ func (x AnonInductive4) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x AnonInductive4) LookupByIndex(idx int64) (pd2.Node, error) { - return nil, pd1.ErrNA +func (x AnonInductive4) LookupByIndex(idx int64) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (x AnonInductive4) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x AnonInductive4) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "IdentifyRequest": return x.Identify.Node(), nil @@ -729,14 +729,14 @@ func (x AnonInductive4) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return x.Hello.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x AnonInductive4) MapIterator() pd2.MapIterator { +func (x AnonInductive4) MapIterator() pd1.MapIterator { return &AnonInductive4_MapIterator{false, &x} } -func (x AnonInductive4) ListIterator() pd2.ListIterator { +func (x AnonInductive4) ListIterator() pd1.ListIterator { return nil } @@ -753,30 +753,30 @@ func (x AnonInductive4) IsNull() bool { } func (x AnonInductive4) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x AnonInductive4) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x AnonInductive4) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x AnonInductive4) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x AnonInductive4) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x AnonInductive4) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x AnonInductive4) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x AnonInductive4) Prototype() pd2.NodePrototype { +func (x AnonInductive4) Prototype() pd1.NodePrototype { return nil } @@ -788,10 +788,10 @@ type AnonInductive5 struct { Error *GreetingService_Error } -func (x *AnonInductive5) Parse(n pd2.Node) error { +func (x *AnonInductive5) Parse(n pd1.Node) error { *x = AnonInductive5{} - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -836,18 +836,18 @@ type AnonInductive5_MapIterator struct { s *AnonInductive5 } -func (x *AnonInductive5_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *AnonInductive5_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { if x.done { - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } else { x.done = true switch { case x.s.Identify != nil: - return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil + return pd2.String("IdentifyResponse"), x.s.Identify.Node(), nil case x.s.Hello != nil: - return pd1.String("HelloResponse"), x.s.Hello.Node(), nil + return pd2.String("HelloResponse"), x.s.Hello.Node(), nil case x.s.Error != nil: - return pd1.String("Error"), x.s.Error.Node(), nil + return pd2.String("Error"), x.s.Error.Node(), nil default: return nil, nil, pd3.Errorf("no inductive cases are set") @@ -859,15 +859,15 @@ func (x *AnonInductive5_MapIterator) Done() bool { return x.done } -func (x AnonInductive5) Node() pd2.Node { +func (x AnonInductive5) Node() pd1.Node { return x } -func (x AnonInductive5) Kind() pd2.Kind { - return pd2.Kind_Map +func (x AnonInductive5) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x AnonInductive5) LookupByString(key string) (pd2.Node, error) { +func (x AnonInductive5) LookupByString(key string) (pd1.Node, error) { switch { case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil @@ -877,12 +877,12 @@ func (x AnonInductive5) LookupByString(key string) (pd2.Node, error) { return x.Error.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x AnonInductive5) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { - return nil, pd1.ErrNA +func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { + if key.Kind() != pd1.Kind_String { + return nil, pd2.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -891,11 +891,11 @@ func (x AnonInductive5) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x AnonInductive5) LookupByIndex(idx int64) (pd2.Node, error) { - return nil, pd1.ErrNA +func (x AnonInductive5) LookupByIndex(idx int64) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (x AnonInductive5) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x AnonInductive5) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "IdentifyResponse": return x.Identify.Node(), nil @@ -905,14 +905,14 @@ func (x AnonInductive5) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return x.Error.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x AnonInductive5) MapIterator() pd2.MapIterator { +func (x AnonInductive5) MapIterator() pd1.MapIterator { return &AnonInductive5_MapIterator{false, &x} } -func (x AnonInductive5) ListIterator() pd2.ListIterator { +func (x AnonInductive5) ListIterator() pd1.ListIterator { return nil } @@ -929,43 +929,43 @@ func (x AnonInductive5) IsNull() bool { } func (x AnonInductive5) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x AnonInductive5) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x AnonInductive5) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x AnonInductive5) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x AnonInductive5) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x AnonInductive5) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x AnonInductive5) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x AnonInductive5) Prototype() pd2.NodePrototype { +func (x AnonInductive5) Prototype() pd1.NodePrototype { return nil } -var logger_client_GreetingService = pd13.Logger("service/client/greetingservice") +var logger_client_GreetingService = pd12.Logger("service/client/greetingservice") type GreetingService_Client interface { - Identify(ctx pd6.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) + Identify(ctx pd5.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) - Hello(ctx pd6.Context, req *HelloRequest) ([]*HelloResponse, error) + Hello(ctx pd5.Context, req *HelloRequest) ([]*HelloResponse, error) - Identify_Async(ctx pd6.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) + Identify_Async(ctx pd5.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) - Hello_Async(ctx pd6.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) + Hello_Async(ctx pd5.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) } type GreetingService_Identify_AsyncResult struct { @@ -981,13 +981,13 @@ type GreetingService_Hello_AsyncResult struct { type GreetingService_ClientOption func(*client_GreetingService) error type client_GreetingService struct { - httpClient *pd5.Client + httpClient *pd9.Client endpoint *pd10.URL - ulk pd12.Mutex + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } -func GreetingService_Client_WithHTTPClient(hc *pd5.Client) GreetingService_ClientOption { +func GreetingService_Client_WithHTTPClient(hc *pd9.Client) GreetingService_ClientOption { return func(c *client_GreetingService) error { c.httpClient = hc return nil @@ -999,7 +999,7 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO if err != nil { return nil, err } - c := &client_GreetingService{endpoint: u, httpClient: pd5.DefaultClient, unsupported: make(map[string]bool)} + c := &client_GreetingService{endpoint: u, httpClient: pd9.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1008,8 +1008,8 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO return c, nil } -func (c *client_GreetingService) Identify(ctx pd6.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { - ctx, cancel := pd6.WithCancel(ctx) +func (c *client_GreetingService) Identify(ctx pd5.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { + ctx, cancel := pd5.WithCancel(ctx) defer cancel() ch, err := c.Identify_Async(ctx, req) if err != nil { @@ -1037,27 +1037,27 @@ func (c *client_GreetingService) Identify(ctx pd6.Context, req *GreetingService_ } } -func (c *client_GreetingService) Identify_Async(ctx pd6.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) { +func (c *client_GreetingService) Identify_Async(ctx pd5.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_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, pd14.ErrSchema + return nil, pd13.ErrSchema } envelope := &AnonInductive4{ Identify: req, } - buf, err := pd4.Encode(envelope, pd7.Encode) + buf, err := pd6.Encode(envelope, pd4.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd5.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) + httpReq, err := pd9.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) if err != nil { return nil, err } @@ -1079,7 +1079,7 @@ func (c *client_GreetingService) Identify_Async(ctx pd6.Context, req *GreetingSe c.ulk.Lock() c.unsupported["Identify"] = true c.ulk.Unlock() - return nil, pd14.ErrSchema + return nil, pd13.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1087,7 +1087,7 @@ func (c *client_GreetingService) Identify_Async(ctx pd6.Context, req *GreetingSe resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1102,29 +1102,39 @@ func (c *client_GreetingService) Identify_Async(ctx pd6.Context, req *GreetingSe return ch, nil } -func process_GreetingService_Identify_AsyncResult(ctx pd6.Context, ch chan<- GreetingService_Identify_AsyncResult, r pd8.ReadCloser) { +func process_GreetingService_Identify_AsyncResult(ctx pd5.Context, ch chan<- GreetingService_Identify_AsyncResult, r pd8.ReadCloser) { defer close(ch) defer r.Close() + opt := pd4.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out GreetingService_Identify_AsyncResult - n, err := pd4.DecodeStreaming(r, pd7.Decode) - if pd9.Is(err, pd8.EOF) || pd9.Is(err, pd8.ErrUnexpectedEOF) { + n, err := pd6.DecodeStreaming(r, opt.Decode) + if pd7.Is(err, pd8.EOF) || pd7.Is(err, pd8.ErrUnexpectedEOF) { return } if err != nil { - out = GreetingService_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error + out = GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = GreetingService_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = GreetingService_Identify_AsyncResult{Err: pd14.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error - } else if env.Identify != nil { - out = GreetingService_Identify_AsyncResult{Resp: env.Identify} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = GreetingService_Identify_AsyncResult{Err: pd13.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 = GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = GreetingService_Identify_AsyncResult{Err: pd13.ErrService{Cause: pd7.New(string(env.Error.Code))}} // service-level error + } else if env.Identify != nil { + out = GreetingService_Identify_AsyncResult{Resp: env.Identify} + } else { + continue + } } } @@ -1136,8 +1146,8 @@ func process_GreetingService_Identify_AsyncResult(ctx pd6.Context, ch chan<- Gre } } -func (c *client_GreetingService) Hello(ctx pd6.Context, req *HelloRequest) ([]*HelloResponse, error) { - ctx, cancel := pd6.WithCancel(ctx) +func (c *client_GreetingService) Hello(ctx pd5.Context, req *HelloRequest) ([]*HelloResponse, error) { + ctx, cancel := pd5.WithCancel(ctx) defer cancel() ch, err := c.Hello_Async(ctx, req) if err != nil { @@ -1165,27 +1175,27 @@ func (c *client_GreetingService) Hello(ctx pd6.Context, req *HelloRequest) ([]*H } } -func (c *client_GreetingService) Hello_Async(ctx pd6.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) { +func (c *client_GreetingService) Hello_Async(ctx pd5.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["Hello"] c.ulk.Unlock() if notSupported { - return nil, pd14.ErrSchema + return nil, pd13.ErrSchema } envelope := &AnonInductive4{ Hello: req, } - buf, err := pd4.Encode(envelope, pd7.Encode) + buf, err := pd6.Encode(envelope, pd4.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd5.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) + httpReq, err := pd9.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) if err != nil { return nil, err } @@ -1207,7 +1217,7 @@ func (c *client_GreetingService) Hello_Async(ctx pd6.Context, req *HelloRequest) c.ulk.Lock() c.unsupported["Hello"] = true c.ulk.Unlock() - return nil, pd14.ErrSchema + return nil, pd13.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1215,7 +1225,7 @@ func (c *client_GreetingService) Hello_Async(ctx pd6.Context, req *HelloRequest) resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1230,29 +1240,39 @@ func (c *client_GreetingService) Hello_Async(ctx pd6.Context, req *HelloRequest) return ch, nil } -func process_GreetingService_Hello_AsyncResult(ctx pd6.Context, ch chan<- GreetingService_Hello_AsyncResult, r pd8.ReadCloser) { +func process_GreetingService_Hello_AsyncResult(ctx pd5.Context, ch chan<- GreetingService_Hello_AsyncResult, r pd8.ReadCloser) { defer close(ch) defer r.Close() + opt := pd4.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, + DontParseBeyondEnd: true, + } for { var out GreetingService_Hello_AsyncResult - n, err := pd4.DecodeStreaming(r, pd7.Decode) - if pd9.Is(err, pd8.EOF) || pd9.Is(err, pd8.ErrUnexpectedEOF) { + n, err := pd6.DecodeStreaming(r, opt.Decode) + if pd7.Is(err, pd8.EOF) || pd7.Is(err, pd8.ErrUnexpectedEOF) { return } if err != nil { - out = GreetingService_Hello_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error + out = GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error } else { - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - out = GreetingService_Hello_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error - } else if env.Error != nil { - out = GreetingService_Hello_AsyncResult{Err: pd14.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error - } else if env.Hello != nil { - out = GreetingService_Hello_AsyncResult{Resp: env.Hello} + var x [1]byte + if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { + out = GreetingService_Hello_AsyncResult{Err: pd13.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 = GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = GreetingService_Hello_AsyncResult{Err: pd13.ErrService{Cause: pd7.New(string(env.Error.Code))}} // service-level error + } else if env.Hello != nil { + out = GreetingService_Hello_AsyncResult{Resp: env.Hello} + } else { + continue + } } } @@ -1264,14 +1284,14 @@ func process_GreetingService_Hello_AsyncResult(ctx pd6.Context, ch chan<- Greeti } } -var logger_server_GreetingService = pd13.Logger("service/server/greetingservice") +var logger_server_GreetingService = pd12.Logger("service/server/greetingservice") type GreetingService_Server interface { - Hello(ctx pd6.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) + Hello(ctx pd5.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) } -func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { - return func(writer pd5.ResponseWriter, request *pd5.Request) { +func GreetingService_AsyncHandler(s GreetingService_Server) pd9.HandlerFunc { + return func(writer pd9.ResponseWriter, request *pd9.Request) { // parse request msg, err := pd15.ReadAll(request.Body) if err != nil { @@ -1279,7 +1299,7 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { writer.WriteHeader(400) return } - n, err := pd4.Decode(msg, pd7.Decode) + n, err := pd6.Decode(msg, pd4.Decode) if err != nil { logger_server_GreetingService.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1300,7 +1320,7 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { switch { case env.Hello != nil: - ch, err := s.Hello(pd6.Background(), env.Hello) + ch, err := s.Hello(pd5.Background(), env.Hello) if err != nil { logger_server_GreetingService.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1310,12 +1330,12 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { for resp := range ch { var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())}} + env = &AnonInductive5{Error: &GreetingService_Error{Code: pd2.String(resp.Err.Error())}} } else { env = &AnonInductive5{Hello: resp.Resp} } var buf pd11.Buffer - if err = pd4.EncodeStreaming(&buf, env, pd7.Encode); err != nil { + if err = pd6.EncodeStreaming(&buf, env, pd4.Encode); err != nil { logger_server_GreetingService.Errorf("cannot encode response (%v)", err) continue } @@ -1327,13 +1347,13 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { var env *AnonInductive5 env = &AnonInductive5{ Identify: &GreetingService_IdentifyResult{ - Methods: []pd1.String{ + Methods: []pd2.String{ "Hello", }, }, } var buf pd11.Buffer - if err = pd4.EncodeStreaming(&buf, env, pd7.Encode); err != nil { + if err = pd6.EncodeStreaming(&buf, env, pd4.Encode); err != nil { logger_server_GreetingService.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return @@ -1351,20 +1371,20 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { // -- protocol type HelloRequest -- type HelloRequest struct { - Name pd1.String + Name pd2.String Address Address } -func (x HelloRequest) Node() pd2.Node { +func (x HelloRequest) Node() pd1.Node { return x } -func (x *HelloRequest) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA +func (x *HelloRequest) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ + fieldMap := map[string]pd2.ParseFunc{ "Name": x.Name.Parse, "Address": x.Address.Parse, } @@ -1399,7 +1419,7 @@ func (x *HelloRequest) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd1.Null); err != nil { return err } } @@ -1411,27 +1431,27 @@ type HelloRequest_MapIterator struct { s *HelloRequest } -func (x *HelloRequest_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *HelloRequest_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { x.i++ switch x.i { case 0: - return pd1.String("Name"), x.s.Name.Node(), nil + return pd2.String("Name"), x.s.Name.Node(), nil case 1: - return pd1.String("Address"), x.s.Address.Node(), nil + return pd2.String("Address"), x.s.Address.Node(), nil } - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } func (x *HelloRequest_MapIterator) Done() bool { return x.i+1 >= 2 } -func (x HelloRequest) Kind() pd2.Kind { - return pd2.Kind_Map +func (x HelloRequest) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x HelloRequest) LookupByString(key string) (pd2.Node, error) { +func (x HelloRequest) LookupByString(key string) (pd1.Node, error) { switch key { case "Name": return x.Name.Node(), nil @@ -1439,28 +1459,28 @@ func (x HelloRequest) LookupByString(key string) (pd2.Node, error) { return x.Address.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x HelloRequest) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x HelloRequest) LookupByNode(key pd1.Node) (pd1.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd1.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd1.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x HelloRequest) LookupByIndex(idx int64) (pd2.Node, error) { +func (x HelloRequest) LookupByIndex(idx int64) (pd1.Node, error) { switch idx { case 0: return x.Name.Node(), nil @@ -1468,10 +1488,10 @@ func (x HelloRequest) LookupByIndex(idx int64) (pd2.Node, error) { return x.Address.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x HelloRequest) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x HelloRequest) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "0", "Name": return x.Name.Node(), nil @@ -1479,14 +1499,14 @@ func (x HelloRequest) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return x.Address.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x HelloRequest) MapIterator() pd2.MapIterator { +func (x HelloRequest) MapIterator() pd1.MapIterator { return &HelloRequest_MapIterator{-1, &x} } -func (x HelloRequest) ListIterator() pd2.ListIterator { +func (x HelloRequest) ListIterator() pd1.ListIterator { return nil } @@ -1503,54 +1523,54 @@ func (x HelloRequest) IsNull() bool { } func (x HelloRequest) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x HelloRequest) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x HelloRequest) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x HelloRequest) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x HelloRequest) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x HelloRequest) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x HelloRequest) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x HelloRequest) Prototype() pd2.NodePrototype { +func (x HelloRequest) Prototype() pd1.NodePrototype { return nil } // -- protocol type AddressLines -- -type AddressLines []pd1.String +type AddressLines []pd2.String -func (v AddressLines) Node() pd2.Node { +func (v AddressLines) Node() pd1.Node { return v } -func (v *AddressLines) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AddressLines) Parse(n pd1.Node) error { + if n.Kind() == pd1.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { - return pd1.ErrNA + if n.Kind() != pd1.Kind_List { + return pd2.ErrNA } else { *v = make(AddressLines, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd1.ErrNA + return pd2.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -1559,39 +1579,39 @@ func (v *AddressLines) Parse(n pd2.Node) error { } } -func (AddressLines) Kind() pd2.Kind { - return pd2.Kind_List +func (AddressLines) Kind() pd1.Kind { + return pd1.Kind_List } -func (AddressLines) LookupByString(string) (pd2.Node, error) { - return nil, pd1.ErrNA +func (AddressLines) LookupByString(string) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (AddressLines) LookupByNode(key pd2.Node) (pd2.Node, error) { - return nil, pd1.ErrNA +func (AddressLines) LookupByNode(key pd1.Node) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (v AddressLines) LookupByIndex(i int64) (pd2.Node, error) { +func (v AddressLines) LookupByIndex(i int64) (pd1.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd1.ErrBounds + return nil, pd2.ErrBounds } else { return v[i].Node(), nil } } -func (v AddressLines) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AddressLines) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } else { return v.LookupByIndex(i) } } -func (AddressLines) MapIterator() pd2.MapIterator { +func (AddressLines) MapIterator() pd1.MapIterator { return nil } -func (v AddressLines) ListIterator() pd2.ListIterator { +func (v AddressLines) ListIterator() pd1.ListIterator { return &AddressLines_ListIterator{v, 0} } @@ -1608,30 +1628,30 @@ func (AddressLines) IsNull() bool { } func (v AddressLines) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (AddressLines) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (AddressLines) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (AddressLines) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (AddressLines) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (AddressLines) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (AddressLines) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (AddressLines) Prototype() pd2.NodePrototype { +func (AddressLines) Prototype() pd1.NodePrototype { return nil // not needed } @@ -1640,9 +1660,9 @@ type AddressLines_ListIterator struct { at int64 } -func (iter *AddressLines_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AddressLines_ListIterator) Next() (int64, pd1.Node, error) { if iter.Done() { - return -1, nil, pd1.ErrBounds + return -1, nil, pd2.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -1664,10 +1684,10 @@ type Address struct { OtherAddress *AddressLines } -func (x *Address) Parse(n pd2.Node) error { +func (x *Address) Parse(n pd1.Node) error { *x = Address{} - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -1712,19 +1732,19 @@ type Address_MapIterator struct { s *Address } -func (x *Address_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *Address_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { if x.done { - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } else { x.done = true switch { case x.s.US != nil: - return pd1.String("US"), x.s.US.Node(), nil + return pd2.String("US"), x.s.US.Node(), nil case x.s.SK != nil: - return pd1.String("SouthKorea"), x.s.SK.Node(), nil + return pd2.String("SouthKorea"), x.s.SK.Node(), nil case x.s.OtherAddress != nil: - return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil + return pd2.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil default: return nil, nil, pd3.Errorf("no inductive cases are set") @@ -1736,15 +1756,15 @@ func (x *Address_MapIterator) Done() bool { return x.done } -func (x Address) Node() pd2.Node { +func (x Address) Node() pd1.Node { return x } -func (x Address) Kind() pd2.Kind { - return pd2.Kind_Map +func (x Address) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x Address) LookupByString(key string) (pd2.Node, error) { +func (x Address) LookupByString(key string) (pd1.Node, error) { switch { case x.US != nil && key == "US": return x.US.Node(), nil @@ -1755,12 +1775,12 @@ func (x Address) LookupByString(key string) (pd2.Node, error) { return x.OtherAddress.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x Address) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { - return nil, pd1.ErrNA +func (x Address) LookupByNode(key pd1.Node) (pd1.Node, error) { + if key.Kind() != pd1.Kind_String { + return nil, pd2.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -1769,11 +1789,11 @@ func (x Address) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x Address) LookupByIndex(idx int64) (pd2.Node, error) { - return nil, pd1.ErrNA +func (x Address) LookupByIndex(idx int64) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (x Address) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x Address) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "US": return x.US.Node(), nil @@ -1784,14 +1804,14 @@ func (x Address) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return x.OtherAddress.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x Address) MapIterator() pd2.MapIterator { +func (x Address) MapIterator() pd1.MapIterator { return &Address_MapIterator{false, &x} } -func (x Address) ListIterator() pd2.ListIterator { +func (x Address) ListIterator() pd1.ListIterator { return nil } @@ -1808,52 +1828,52 @@ func (x Address) IsNull() bool { } func (x Address) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x Address) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x Address) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x Address) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x Address) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x Address) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x Address) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x Address) Prototype() pd2.NodePrototype { +func (x Address) Prototype() pd1.NodePrototype { return nil } // -- protocol type USAddress -- type USAddress struct { - Street pd1.String - City pd1.String + Street pd2.String + City pd2.String State State - ZIP pd1.Int + ZIP pd2.Int } -func (x USAddress) Node() pd2.Node { +func (x USAddress) Node() pd1.Node { return x } -func (x *USAddress) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA +func (x *USAddress) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ + fieldMap := map[string]pd2.ParseFunc{ "street": x.Street.Parse, "city": x.City.Parse, "state": x.State.Parse, @@ -1906,7 +1926,7 @@ func (x *USAddress) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd1.Null); err != nil { return err } } @@ -1918,31 +1938,31 @@ type USAddress_MapIterator struct { s *USAddress } -func (x *USAddress_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *USAddress_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { x.i++ switch x.i { case 0: - return pd1.String("street"), x.s.Street.Node(), nil + return pd2.String("street"), x.s.Street.Node(), nil case 1: - return pd1.String("city"), x.s.City.Node(), nil + return pd2.String("city"), x.s.City.Node(), nil case 2: - return pd1.String("state"), x.s.State.Node(), nil + return pd2.String("state"), x.s.State.Node(), nil case 3: - return pd1.String("zip"), x.s.ZIP.Node(), nil + return pd2.String("zip"), x.s.ZIP.Node(), nil } - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } func (x *USAddress_MapIterator) Done() bool { return x.i+1 >= 4 } -func (x USAddress) Kind() pd2.Kind { - return pd2.Kind_Map +func (x USAddress) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x USAddress) LookupByString(key string) (pd2.Node, error) { +func (x USAddress) LookupByString(key string) (pd1.Node, error) { switch key { case "street": return x.Street.Node(), nil @@ -1954,28 +1974,28 @@ func (x USAddress) LookupByString(key string) (pd2.Node, error) { return x.ZIP.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x USAddress) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x USAddress) LookupByNode(key pd1.Node) (pd1.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd1.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd1.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x USAddress) LookupByIndex(idx int64) (pd2.Node, error) { +func (x USAddress) LookupByIndex(idx int64) (pd1.Node, error) { switch idx { case 0: return x.Street.Node(), nil @@ -1987,10 +2007,10 @@ func (x USAddress) LookupByIndex(idx int64) (pd2.Node, error) { return x.ZIP.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x USAddress) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x USAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "0", "street": return x.Street.Node(), nil @@ -2002,14 +2022,14 @@ func (x USAddress) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return x.ZIP.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x USAddress) MapIterator() pd2.MapIterator { +func (x USAddress) MapIterator() pd1.MapIterator { return &USAddress_MapIterator{-1, &x} } -func (x USAddress) ListIterator() pd2.ListIterator { +func (x USAddress) ListIterator() pd1.ListIterator { return nil } @@ -2026,30 +2046,30 @@ func (x USAddress) IsNull() bool { } func (x USAddress) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x USAddress) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x USAddress) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x USAddress) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x USAddress) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x USAddress) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x USAddress) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x USAddress) Prototype() pd2.NodePrototype { +func (x USAddress) Prototype() pd1.NodePrototype { return nil } @@ -2057,49 +2077,49 @@ func (x USAddress) Prototype() pd2.NodePrototype { type StateCA struct{} -func (StateCA) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_String { - return pd1.ErrNA +func (StateCA) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_String { + return pd2.ErrNA } v, err := n.AsString() if err != nil { return err } if v != "CA" { - return pd1.ErrNA + return pd2.ErrNA } return nil } -func (v StateCA) Node() pd2.Node { +func (v StateCA) Node() pd1.Node { return v } -func (StateCA) Kind() pd2.Kind { - return pd2.Kind_String +func (StateCA) Kind() pd1.Kind { + return pd1.Kind_String } -func (StateCA) LookupByString(string) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateCA) LookupByString(string) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateCA) LookupByNode(key pd2.Node) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateCA) LookupByNode(key pd1.Node) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateCA) LookupByIndex(idx int64) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateCA) LookupByIndex(idx int64) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateCA) LookupBySegment(_ pd2.PathSegment) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateCA) LookupBySegment(_ pd1.PathSegment) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateCA) MapIterator() pd2.MapIterator { +func (StateCA) MapIterator() pd1.MapIterator { return nil } -func (StateCA) ListIterator() pd2.ListIterator { +func (StateCA) ListIterator() pd1.ListIterator { return nil } @@ -2116,15 +2136,15 @@ func (StateCA) IsNull() bool { } func (v StateCA) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (StateCA) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (StateCA) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (StateCA) AsString() (string, error) { @@ -2132,14 +2152,14 @@ func (StateCA) AsString() (string, error) { } func (StateCA) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (StateCA) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (StateCA) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (StateCA) Prototype() pd2.NodePrototype { +func (StateCA) Prototype() pd1.NodePrototype { return nil } @@ -2147,49 +2167,49 @@ func (StateCA) Prototype() pd2.NodePrototype { type StateNY struct{} -func (StateNY) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_String { - return pd1.ErrNA +func (StateNY) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_String { + return pd2.ErrNA } v, err := n.AsString() if err != nil { return err } if v != "NY" { - return pd1.ErrNA + return pd2.ErrNA } return nil } -func (v StateNY) Node() pd2.Node { +func (v StateNY) Node() pd1.Node { return v } -func (StateNY) Kind() pd2.Kind { - return pd2.Kind_String +func (StateNY) Kind() pd1.Kind { + return pd1.Kind_String } -func (StateNY) LookupByString(string) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateNY) LookupByString(string) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateNY) LookupByNode(key pd2.Node) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateNY) LookupByNode(key pd1.Node) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateNY) LookupByIndex(idx int64) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateNY) LookupByIndex(idx int64) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateNY) LookupBySegment(_ pd2.PathSegment) (pd2.Node, error) { - return nil, pd1.ErrNA +func (StateNY) LookupBySegment(_ pd1.PathSegment) (pd1.Node, error) { + return nil, pd2.ErrNA } -func (StateNY) MapIterator() pd2.MapIterator { +func (StateNY) MapIterator() pd1.MapIterator { return nil } -func (StateNY) ListIterator() pd2.ListIterator { +func (StateNY) ListIterator() pd1.ListIterator { return nil } @@ -2206,15 +2226,15 @@ func (StateNY) IsNull() bool { } func (v StateNY) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (StateNY) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (StateNY) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (StateNY) AsString() (string, error) { @@ -2222,14 +2242,14 @@ func (StateNY) AsString() (string, error) { } func (StateNY) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (StateNY) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (StateNY) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (StateNY) Prototype() pd2.NodePrototype { +func (StateNY) Prototype() pd1.NodePrototype { return nil } @@ -2238,10 +2258,10 @@ func (StateNY) Prototype() pd2.NodePrototype { type State struct { CA *StateCA NY *StateNY - Other *pd1.String + Other *pd2.String } -func (x *State) Parse(n pd2.Node) error { +func (x *State) Parse(n pd1.Node) error { *x = State{} var CA StateCA @@ -2256,7 +2276,7 @@ func (x *State) Parse(n pd2.Node) error { return nil } - var Other pd1.String + var Other pd2.String if err := Other.Parse(n); err == nil { x.Other = &Other return nil @@ -2265,7 +2285,7 @@ func (x *State) Parse(n pd2.Node) error { return pd3.Errorf("no union cases parses") } -func (x State) Node() pd2.Node { +func (x State) Node() pd1.Node { if x.CA != nil { return x.CA } @@ -2281,7 +2301,7 @@ func (x State) Node() pd2.Node { // proxy Node methods to active case -func (x State) Kind() pd2.Kind { +func (x State) Kind() pd1.Kind { if x.CA != nil { return x.CA.Kind() } @@ -2292,10 +2312,10 @@ func (x State) Kind() pd2.Kind { return x.Other.Kind() } - return pd2.Kind_Invalid + return pd1.Kind_Invalid } -func (x State) LookupByString(key string) (pd2.Node, error) { +func (x State) LookupByString(key string) (pd1.Node, error) { if x.CA != nil { return x.CA.LookupByString(key) } @@ -2309,7 +2329,7 @@ func (x State) LookupByString(key string) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x State) LookupByNode(key pd1.Node) (pd1.Node, error) { if x.CA != nil { return x.CA.LookupByNode(key) } @@ -2323,7 +2343,7 @@ func (x State) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) LookupByIndex(idx int64) (pd2.Node, error) { +func (x State) LookupByIndex(idx int64) (pd1.Node, error) { if x.CA != nil { return x.CA.LookupByIndex(idx) } @@ -2337,7 +2357,7 @@ func (x State) LookupByIndex(idx int64) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x State) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { if x.CA != nil { return x.CA.LookupBySegment(seg) } @@ -2351,7 +2371,7 @@ func (x State) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) MapIterator() pd2.MapIterator { +func (x State) MapIterator() pd1.MapIterator { if x.CA != nil { return x.CA.MapIterator() } @@ -2365,7 +2385,7 @@ func (x State) MapIterator() pd2.MapIterator { return nil } -func (x State) ListIterator() pd2.ListIterator { +func (x State) ListIterator() pd1.ListIterator { if x.CA != nil { return x.CA.ListIterator() } @@ -2491,7 +2511,7 @@ func (x State) AsBytes() ([]byte, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) AsLink() (pd2.Link, error) { +func (x State) AsLink() (pd1.Link, error) { if x.CA != nil { return x.CA.AsLink() } @@ -2505,29 +2525,29 @@ func (x State) AsLink() (pd2.Link, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) Prototype() pd2.NodePrototype { +func (x State) Prototype() pd1.NodePrototype { return nil } // -- protocol type SKAddress -- type SKAddress struct { - Street pd1.String - City pd1.String - Province pd1.String - PostalCode pd1.Int + Street pd2.String + City pd2.String + Province pd2.String + PostalCode pd2.Int } -func (x SKAddress) Node() pd2.Node { +func (x SKAddress) Node() pd1.Node { return x } -func (x *SKAddress) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { - return pd1.ErrNA +func (x *SKAddress) Parse(n pd1.Node) error { + if n.Kind() != pd1.Kind_Map { + return pd2.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ + fieldMap := map[string]pd2.ParseFunc{ "street": x.Street.Parse, "city": x.City.Parse, "province": x.Province.Parse, @@ -2580,7 +2600,7 @@ func (x *SKAddress) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd1.Null); err != nil { return err } } @@ -2592,31 +2612,31 @@ type SKAddress_MapIterator struct { s *SKAddress } -func (x *SKAddress_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *SKAddress_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { x.i++ switch x.i { case 0: - return pd1.String("street"), x.s.Street.Node(), nil + return pd2.String("street"), x.s.Street.Node(), nil case 1: - return pd1.String("city"), x.s.City.Node(), nil + return pd2.String("city"), x.s.City.Node(), nil case 2: - return pd1.String("province"), x.s.Province.Node(), nil + return pd2.String("province"), x.s.Province.Node(), nil case 3: - return pd1.String("postal_code"), x.s.PostalCode.Node(), nil + return pd2.String("postal_code"), x.s.PostalCode.Node(), nil } - return nil, nil, pd1.ErrNA + return nil, nil, pd2.ErrNA } func (x *SKAddress_MapIterator) Done() bool { return x.i+1 >= 4 } -func (x SKAddress) Kind() pd2.Kind { - return pd2.Kind_Map +func (x SKAddress) Kind() pd1.Kind { + return pd1.Kind_Map } -func (x SKAddress) LookupByString(key string) (pd2.Node, error) { +func (x SKAddress) LookupByString(key string) (pd1.Node, error) { switch key { case "street": return x.Street.Node(), nil @@ -2628,28 +2648,28 @@ func (x SKAddress) LookupByString(key string) (pd2.Node, error) { return x.PostalCode.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x SKAddress) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x SKAddress) LookupByNode(key pd1.Node) (pd1.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd1.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd1.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x SKAddress) LookupByIndex(idx int64) (pd2.Node, error) { +func (x SKAddress) LookupByIndex(idx int64) (pd1.Node, error) { switch idx { case 0: return x.Street.Node(), nil @@ -2661,10 +2681,10 @@ func (x SKAddress) LookupByIndex(idx int64) (pd2.Node, error) { return x.PostalCode.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x SKAddress) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x SKAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { switch seg.String() { case "0", "street": return x.Street.Node(), nil @@ -2676,14 +2696,14 @@ func (x SKAddress) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return x.PostalCode.Node(), nil } - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x SKAddress) MapIterator() pd2.MapIterator { +func (x SKAddress) MapIterator() pd1.MapIterator { return &SKAddress_MapIterator{-1, &x} } -func (x SKAddress) ListIterator() pd2.ListIterator { +func (x SKAddress) ListIterator() pd1.ListIterator { return nil } @@ -2700,50 +2720,50 @@ func (x SKAddress) IsNull() bool { } func (x SKAddress) AsBool() (bool, error) { - return false, pd1.ErrNA + return false, pd2.ErrNA } func (x SKAddress) AsInt() (int64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x SKAddress) AsFloat() (float64, error) { - return 0, pd1.ErrNA + return 0, pd2.ErrNA } func (x SKAddress) AsString() (string, error) { - return "", pd1.ErrNA + return "", pd2.ErrNA } func (x SKAddress) AsBytes() ([]byte, error) { - return nil, pd1.ErrNA + return nil, pd2.ErrNA } -func (x SKAddress) AsLink() (pd2.Link, error) { - return nil, pd1.ErrNA +func (x SKAddress) AsLink() (pd1.Link, error) { + return nil, pd2.ErrNA } -func (x SKAddress) Prototype() pd2.NodePrototype { +func (x SKAddress) Prototype() pd1.NodePrototype { return nil } // -- protocol type HelloResponse -- type HelloResponse struct { - English *pd1.String - Korean *pd1.String + English *pd2.String + Korean *pd2.String } -func (x *HelloResponse) Parse(n pd2.Node) error { +func (x *HelloResponse) Parse(n pd1.Node) error { *x = HelloResponse{} - var English pd1.String + var English pd2.String if err := English.Parse(n); err == nil { x.English = &English return nil } - var Korean pd1.String + var Korean pd2.String if err := Korean.Parse(n); err == nil { x.Korean = &Korean return nil @@ -2752,7 +2772,7 @@ func (x *HelloResponse) Parse(n pd2.Node) error { return pd3.Errorf("no union cases parses") } -func (x HelloResponse) Node() pd2.Node { +func (x HelloResponse) Node() pd1.Node { if x.English != nil { return x.English } @@ -2765,7 +2785,7 @@ func (x HelloResponse) Node() pd2.Node { // proxy Node methods to active case -func (x HelloResponse) Kind() pd2.Kind { +func (x HelloResponse) Kind() pd1.Kind { if x.English != nil { return x.English.Kind() } @@ -2773,10 +2793,10 @@ func (x HelloResponse) Kind() pd2.Kind { return x.Korean.Kind() } - return pd2.Kind_Invalid + return pd1.Kind_Invalid } -func (x HelloResponse) LookupByString(key string) (pd2.Node, error) { +func (x HelloResponse) LookupByString(key string) (pd1.Node, error) { if x.English != nil { return x.English.LookupByString(key) } @@ -2787,7 +2807,7 @@ func (x HelloResponse) LookupByString(key string) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x HelloResponse) LookupByNode(key pd1.Node) (pd1.Node, error) { if x.English != nil { return x.English.LookupByNode(key) } @@ -2798,7 +2818,7 @@ func (x HelloResponse) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) LookupByIndex(idx int64) (pd2.Node, error) { +func (x HelloResponse) LookupByIndex(idx int64) (pd1.Node, error) { if x.English != nil { return x.English.LookupByIndex(idx) } @@ -2809,7 +2829,7 @@ func (x HelloResponse) LookupByIndex(idx int64) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x HelloResponse) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { if x.English != nil { return x.English.LookupBySegment(seg) } @@ -2820,7 +2840,7 @@ func (x HelloResponse) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) MapIterator() pd2.MapIterator { +func (x HelloResponse) MapIterator() pd1.MapIterator { if x.English != nil { return x.English.MapIterator() } @@ -2831,7 +2851,7 @@ func (x HelloResponse) MapIterator() pd2.MapIterator { return nil } -func (x HelloResponse) ListIterator() pd2.ListIterator { +func (x HelloResponse) ListIterator() pd1.ListIterator { if x.English != nil { return x.English.ListIterator() } @@ -2930,7 +2950,7 @@ func (x HelloResponse) AsBytes() ([]byte, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) AsLink() (pd2.Link, error) { +func (x HelloResponse) AsLink() (pd1.Link, error) { if x.English != nil { return x.English.AsLink() } @@ -2941,6 +2961,6 @@ func (x HelloResponse) AsLink() (pd2.Link, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) Prototype() pd2.NodePrototype { +func (x HelloResponse) Prototype() pd1.NodePrototype { return nil } diff --git a/go.mod b/go.mod index 1b980e3..b573b45 100644 --- a/go.mod +++ b/go.mod @@ -3,29 +3,33 @@ module github.com/ipld/edelweiss go 1.17 require ( - github.com/ipfs/go-cid v0.0.4 + github.com/ipfs/go-cid v0.2.0 github.com/ipfs/go-log v1.0.5 - github.com/ipld/go-ipld-prime v0.14.4-0.20211217152141-008fd70fc96f + github.com/ipld/go-ipld-prime v0.17.0 ) require ( github.com/gogo/protobuf v1.3.2 // indirect + github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/ipfs/go-log/v2 v2.1.3 // indirect + github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.0.3 // indirect - github.com/multiformats/go-multibase v0.0.1 // indirect + github.com/multiformats/go-base36 v0.1.0 // indirect + github.com/multiformats/go-multibase v0.0.3 // indirect github.com/multiformats/go-multihash v0.1.0 // indirect github.com/multiformats/go-varint v0.0.6 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect + github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.16.0 // indirect - golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect + golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf // indirect golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect lukechampine.com/blake3 v1.1.6 // indirect ) diff --git a/go.sum b/go.sum index 3036dec..d091571 100644 --- a/go.sum +++ b/go.sum @@ -4,23 +4,24 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss= -github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/ipfs/go-cid v0.0.4 h1:UlfXKrZx1DjZoBhQHmNHLC1fK1dUJDN20Y28A7s+gJ8= -github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj6+M= +github.com/ipfs/go-cid v0.2.0 h1:01JTiihFq9en9Vz0lc0VDWvZe/uBonGpzo4THP0vcQ0= +github.com/ipfs/go-cid v0.2.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3 h1:1iS3IU7aXRlbgUpN8yTTpJ53NXYjAe37vcI5+5nYrzk= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= -github.com/ipld/go-ipld-prime v0.14.4-0.20211217152141-008fd70fc96f h1:6ISKbCjgF2pR2W/YRNBeTV7XL0+d+r6h9vRoer0zFm8= -github.com/ipld/go-ipld-prime v0.14.4-0.20211217152141-008fd70fc96f/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704nH0RDcQtgTP0= +github.com/ipld/go-ipld-prime v0.17.0 h1:+U2peiA3aQsE7mrXjD2nYZaZrCcakoz2Wge8K42Ld8g= +github.com/ipld/go-ipld-prime v0.17.0/go.mod h1:aYcKm5TIvGfY8P3QBKz/2gKcLxzJ1zDaD+o0bOowhgs= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -37,20 +38,20 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= -github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= -github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= -github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA= -github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= -github.com/multiformats/go-multicodec v0.3.0 h1:tstDwfIjiHbnIjeM5Lp+pMrSeN+LCMsEwOrkPmWm03A= -github.com/multiformats/go-multicodec v0.3.0/go.mod h1:qGGaQmioCDh+TeFOnxrbU0DaIPw8yFgAZgFG0V7p1qQ= -github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= +github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= +github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= +github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= +github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= +github.com/multiformats/go-multicodec v0.5.0 h1:EgU6cBe/D7WRwQb1KmnBvU7lrcFGMggZVTPtOW9dDHs= +github.com/multiformats/go-multicodec v0.5.0/go.mod h1:DiY2HFaEp5EhEXb/iYzVAunmyX/aSFMxq2KMKfWEues= +github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg= github.com/multiformats/go-multihash v0.1.0 h1:CgAgwqk3//SVEw3T+6DqI4mWMyRuDwZtOWcJT0q9+EA= github.com/multiformats/go-multihash v0.1.0/go.mod h1:RJlXsxt6vHGaia+S8We0ErjhojtKzPP2AH4+kYM7k84= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= @@ -76,7 +77,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/warpfork/go-testmark v0.3.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0= +github.com/warpfork/go-testmark v0.10.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -92,11 +93,11 @@ go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf h1:B2n+Zi5QeYRDAEodEu72OS36gmTWjgpXr2+cWcBW90o= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -108,6 +109,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -115,9 +117,11 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/test/harness.go b/test/harness.go index 99cafb2..ab66c59 100644 --- a/test/harness.go +++ b/test/harness.go @@ -40,7 +40,7 @@ module test go 1.16 require ( - github.com/ipld/edelweiss e8b466dd5c436d901f6098836a2ab42c9e18d485 + github.com/ipld/edelweiss 13981a091ad908bfcbce6e0db02764cdeecaaa9a github.com/ipld/go-ipld-prime v0.14.4 github.com/ipfs/go-cid v0.0.4 ) diff --git a/test/service_test.go b/test/service_test.go index f6b7d34..a501e7a 100644 --- a/test/service_test.go +++ b/test/service_test.go @@ -13,6 +13,7 @@ func TestServiceWithoutErrors(t *testing.T) { Methods: defs.Methods{ defs.Method{Name: "Method1", Type: defs.Fn{Arg: defs.Int{}, Return: defs.Bool{}}}, defs.Method{Name: "Method2", Type: defs.Fn{Arg: defs.String{}, Return: defs.Float{}}}, + defs.Method{Name: "Method4", Type: defs.Fn{Arg: defs.String{}, Return: defs.Float{}}}, }, }, }, @@ -22,13 +23,16 @@ func TestServiceWithoutErrors(t *testing.T) { defs.Method{Name: "Method1", Type: defs.Fn{Arg: defs.Int{}, Return: defs.Bool{}}}, defs.Method{Name: "Method2", Type: defs.Fn{Arg: defs.String{}, Return: defs.Float{}}}, defs.Method{Name: "Method3", Type: defs.Fn{Arg: defs.String{}, Return: defs.String{}}}, + defs.Method{Name: "Method4", Type: defs.Fn{Arg: defs.String{}, Return: defs.Float{}}}, }, }, }, } testSrc := ` -type TestService1_ServerImpl struct{} +type TestService1_ServerImpl struct{ + Release4 chan struct{} +} func (TestService1_ServerImpl) Method1(ctx context.Context, req *values.Int) (<-chan *TestService1_Method1_AsyncResult, error) { respCh := make(chan *TestService1_Method1_AsyncResult) @@ -46,20 +50,32 @@ func (TestService1_ServerImpl) Method2(ctx context.Context, req *values.String) defer close(respCh) var r1 values.Float = 1.23 respCh <- &TestService1_Method2_AsyncResult{ Resp: &r1 } - // TODO: dagjson.Decode does not support multiple streaming values - // var r2 values.Float = 4.56 - // respCh <- &TestService1_Method2_AsyncResult{ Resp: &r2 } + var r2 values.Float = 4.56 + respCh <- &TestService1_Method2_AsyncResult{ Resp: &r2 } + }() + return respCh, nil +} + +// This method returns one response and stalls. The test verifies that the first response is received. +func (s TestService1_ServerImpl) Method4(ctx context.Context, req *values.String) (<-chan *TestService1_Method4_AsyncResult, error) { + respCh := make(chan *TestService1_Method4_AsyncResult) + go func() { + defer close(respCh) + var r1 values.Float = 1.23 + respCh <- &TestService1_Method4_AsyncResult{ Resp: &r1 } + <-s.Release4 }() return respCh, nil } var testServiceIdentifyResult = &TestService1_IdentifyResult{ - Methods: []values.String{"Method1", "Method2"}, + Methods: []values.String{"Method1", "Method2", "Method4"}, } func TestRoundtrip(t *testing.T) { - s := httptest.NewServer(TestService1_AsyncHandler(TestService1_ServerImpl{})) + svc := TestService1_ServerImpl{Release4: make(chan struct{})} + s := httptest.NewServer(TestService1_AsyncHandler(svc)) defer s.Close() c1, err := New_TestService1_Client(s.URL, TestService1_Client_WithHTTPClient(s.Client())) @@ -74,6 +90,7 @@ func TestRoundtrip(t *testing.T) { ctx := context.Background() + // test method returning one response r1, err := c1.Method1(ctx, values.NewInt(5)) if err != nil { t.Fatal(err) @@ -82,20 +99,34 @@ func TestRoundtrip(t *testing.T) { t.Errorf("expecting true, fot false") } + // test method returning two responses r2, err := c1.Method2(ctx, values.NewString("5")) if err != nil { t.Fatal(err) } - if len(r2) != 1 { - t.Fatalf("expecting 1 results, got %d", len(r2)) + if len(r2) != 2 { + t.Fatalf("expecting 2 results, got %d", len(r2)) } if *r2[0] != values.Float(1.23) { t.Fatalf("expecting 1.23, got %v", *r2[0]) } - // TODO: dagjson.Decode does not support multiple streaming values - // if *r2[1] != values.Float(4.56) { - // t.Fatalf("expecting 4.56, got %v", *r2[1]) - // } + if *r2[1] != values.Float(4.56) { + t.Fatalf("expecting 4.56, got %v", *r2[1]) + } + + // test method that returns one response and stalls + rch, err := c1.Method4_Async(ctx, values.NewString("5")) + if err != nil { + t.Fatal(err) + } + resp := <-rch + if resp.Resp == nil { + t.Fatalf("expecting response") + } + if *resp.Resp != values.Float(1.23) { + t.Fatalf("expecting 1.23, got %v", *r2[0]) + } + close(svc.Release4) // test Identify method r3, err := c1.Identify(ctx, &TestService1_IdentifyArg{})