diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index e8f49981ff..e8ea1dc525 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -12,6 +12,7 @@ // xdr/Stellar-internal.x // xdr/Stellar-ledger-entries.x // xdr/Stellar-ledger.x +// xdr/Stellar-lighthorizon.x // xdr/Stellar-overlay.x // xdr/Stellar-transaction.x // xdr/Stellar-types.x @@ -40,6 +41,7 @@ var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-internal.x": "227835866c1b2122d1eaf28839ba85ea7289d1cb681dda4ca619c2da3d71fe00", "xdr/Stellar-ledger-entries.x": "4f8f2324f567a40065f54f696ea1428740f043ea4154f5986d9f499ad00ac333", "xdr/Stellar-ledger.x": "2c842f3fe6e269498af5467f849cf6818554e90babc845f34c87cda471298d0f", + "xdr/Stellar-lighthorizon.x": "1aac09eaeda224154f653a0c95f02167be0c110fc295bb41b756a080eb8c06df", "xdr/Stellar-overlay.x": "de3957c58b96ae07968b3d3aebea84f83603e95322d1fa336360e13e3aba737a", "xdr/Stellar-transaction.x": "0d2b35a331a540b48643925d0869857236eb2487c02d340ea32e365e784ea2b8", "xdr/Stellar-types.x": "6e3b13f0d3e360b09fa5e2b0e55d43f4d974a769df66afb34e8aecbb329d3f15", @@ -56546,4 +56548,480 @@ func (s ConfigSettingEntry) xdrType() {} var _ xdrType = (*ConfigSettingEntry)(nil) +// BitmapIndex is an XDR Struct defines as: +// +// struct BitmapIndex { +// uint32 firstBit; +// uint32 lastBit; +// Value bitmap; +// }; +type BitmapIndex struct { + FirstBit Uint32 + LastBit Uint32 + Bitmap Value +} + +// EncodeTo encodes this value using the Encoder. +func (s *BitmapIndex) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.FirstBit.EncodeTo(e); err != nil { + return err + } + if err = s.LastBit.EncodeTo(e); err != nil { + return err + } + if err = s.Bitmap.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*BitmapIndex)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *BitmapIndex) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BitmapIndex: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.FirstBit.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.LastBit.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.Bitmap.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Value: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s BitmapIndex) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *BitmapIndex) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*BitmapIndex)(nil) + _ encoding.BinaryUnmarshaler = (*BitmapIndex)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s BitmapIndex) xdrType() {} + +var _ xdrType = (*BitmapIndex)(nil) + +// TrieIndex is an XDR Struct defines as: +// +// struct TrieIndex { +// uint32 version_; // goxdr gives an error if we simply use "version" as an identifier +// TrieNode root; +// }; +type TrieIndex struct { + Version Uint32 + Root TrieNode +} + +// EncodeTo encodes this value using the Encoder. +func (s *TrieIndex) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Version.EncodeTo(e); err != nil { + return err + } + if err = s.Root.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*TrieIndex)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *TrieIndex) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrieIndex: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Version.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.Root.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TrieNode: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TrieIndex) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TrieIndex) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*TrieIndex)(nil) + _ encoding.BinaryUnmarshaler = (*TrieIndex)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s TrieIndex) xdrType() {} + +var _ xdrType = (*TrieIndex)(nil) + +// TrieNodeChild is an XDR Struct defines as: +// +// struct TrieNodeChild { +// opaque key[1]; +// TrieNode node; +// }; +type TrieNodeChild struct { + Key [1]byte `xdrmaxsize:"1"` + Node TrieNode +} + +// EncodeTo encodes this value using the Encoder. +func (s *TrieNodeChild) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeFixedOpaque(s.Key[:]); err != nil { + return err + } + if err = s.Node.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*TrieNodeChild)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *TrieNodeChild) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrieNodeChild: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = d.DecodeFixedOpaqueInplace(s.Key[:]) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Key: %w", err) + } + nTmp, err = s.Node.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TrieNode: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TrieNodeChild) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TrieNodeChild) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*TrieNodeChild)(nil) + _ encoding.BinaryUnmarshaler = (*TrieNodeChild)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s TrieNodeChild) xdrType() {} + +var _ xdrType = (*TrieNodeChild)(nil) + +// TrieNode is an XDR Struct defines as: +// +// struct TrieNode { +// Value prefix; +// Value value; +// TrieNodeChild children<>; +// }; +type TrieNode struct { + Prefix Value + Value Value + Children []TrieNodeChild +} + +// EncodeTo encodes this value using the Encoder. +func (s *TrieNode) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Prefix.EncodeTo(e); err != nil { + return err + } + if err = s.Value.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.Children))); err != nil { + return err + } + for i := 0; i < len(s.Children); i++ { + if err = s.Children[i].EncodeTo(e); err != nil { + return err + } + } + return nil +} + +var _ decoderFrom = (*TrieNode)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *TrieNode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrieNode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Prefix.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Value: %w", err) + } + nTmp, err = s.Value.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Value: %w", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TrieNodeChild: %w", err) + } + s.Children = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TrieNodeChild: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Children = make([]TrieNodeChild, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Children[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TrieNodeChild: %w", err) + } + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TrieNode) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TrieNode) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*TrieNode)(nil) + _ encoding.BinaryUnmarshaler = (*TrieNode)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s TrieNode) xdrType() {} + +var _ xdrType = (*TrieNode)(nil) + +// SerializedLedgerCloseMeta is an XDR Union defines as: +// +// union SerializedLedgerCloseMeta switch (int v) +// { +// case 0: +// LedgerCloseMeta v0; +// }; +type SerializedLedgerCloseMeta struct { + V int32 + V0 *LedgerCloseMeta +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u SerializedLedgerCloseMeta) SwitchFieldName() string { + return "V" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of SerializedLedgerCloseMeta +func (u SerializedLedgerCloseMeta) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "V0", true + } + return "-", false +} + +// NewSerializedLedgerCloseMeta creates a new SerializedLedgerCloseMeta. +func NewSerializedLedgerCloseMeta(v int32, value interface{}) (result SerializedLedgerCloseMeta, err error) { + result.V = v + switch int32(v) { + case 0: + tv, ok := value.(LedgerCloseMeta) + if !ok { + err = errors.New("invalid value, must be LedgerCloseMeta") + return + } + result.V0 = &tv + } + return +} + +// MustV0 retrieves the V0 value from the union, +// panicing if the value is not set. +func (u SerializedLedgerCloseMeta) MustV0() LedgerCloseMeta { + val, ok := u.GetV0() + + if !ok { + panic("arm V0 is not set") + } + + return val +} + +// GetV0 retrieves the V0 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u SerializedLedgerCloseMeta) GetV0() (result LedgerCloseMeta, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V0" { + result = *u.V0 + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u SerializedLedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeInt(int32(u.V)); err != nil { + return err + } + switch int32(u.V) { + case 0: + if err = (*u.V0).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("V (int32) switch value '%d' is not valid for union SerializedLedgerCloseMeta", u.V) +} + +var _ decoderFrom = (*SerializedLedgerCloseMeta)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *SerializedLedgerCloseMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SerializedLedgerCloseMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + u.V, nTmp, err = d.DecodeInt() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int: %w", err) + } + switch int32(u.V) { + case 0: + u.V0 = new(LedgerCloseMeta) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerCloseMeta: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union SerializedLedgerCloseMeta has invalid V (int32) switch value '%d'", u.V) +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SerializedLedgerCloseMeta) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SerializedLedgerCloseMeta) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SerializedLedgerCloseMeta)(nil) + _ encoding.BinaryUnmarshaler = (*SerializedLedgerCloseMeta)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s SerializedLedgerCloseMeta) xdrType() {} + +var _ xdrType = (*SerializedLedgerCloseMeta)(nil) + var fmtTest = fmt.Sprint("this is a dummy usage of fmt")