You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

836 lines
19 KiB

  1. // Code generated by protoc-gen-gogo. DO NOT EDIT.
  2. // source: crypto/merkle/merkle.proto
  3. package merkle
  4. import (
  5. bytes "bytes"
  6. fmt "fmt"
  7. _ "github.com/gogo/protobuf/gogoproto"
  8. proto "github.com/gogo/protobuf/proto"
  9. io "io"
  10. math "math"
  11. math_bits "math/bits"
  12. )
  13. // Reference imports to suppress errors if they are not otherwise used.
  14. var _ = proto.Marshal
  15. var _ = fmt.Errorf
  16. var _ = math.Inf
  17. // This is a compile-time assertion to ensure that this generated file
  18. // is compatible with the proto package it is being compiled against.
  19. // A compilation error at this line likely means your copy of the
  20. // proto package needs to be updated.
  21. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
  22. // ProofOp defines an operation used for calculating Merkle root
  23. // The data could be arbitrary format, providing nessecary data
  24. // for example neighbouring node hash
  25. type ProofOp struct {
  26. Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
  27. Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
  28. Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
  29. XXX_NoUnkeyedLiteral struct{} `json:"-"`
  30. XXX_unrecognized []byte `json:"-"`
  31. XXX_sizecache int32 `json:"-"`
  32. }
  33. func (m *ProofOp) Reset() { *m = ProofOp{} }
  34. func (m *ProofOp) String() string { return proto.CompactTextString(m) }
  35. func (*ProofOp) ProtoMessage() {}
  36. func (*ProofOp) Descriptor() ([]byte, []int) {
  37. return fileDescriptor_9c1c2162d560d38e, []int{0}
  38. }
  39. func (m *ProofOp) XXX_Unmarshal(b []byte) error {
  40. return m.Unmarshal(b)
  41. }
  42. func (m *ProofOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
  43. if deterministic {
  44. return xxx_messageInfo_ProofOp.Marshal(b, m, deterministic)
  45. } else {
  46. b = b[:cap(b)]
  47. n, err := m.MarshalToSizedBuffer(b)
  48. if err != nil {
  49. return nil, err
  50. }
  51. return b[:n], nil
  52. }
  53. }
  54. func (m *ProofOp) XXX_Merge(src proto.Message) {
  55. xxx_messageInfo_ProofOp.Merge(m, src)
  56. }
  57. func (m *ProofOp) XXX_Size() int {
  58. return m.Size()
  59. }
  60. func (m *ProofOp) XXX_DiscardUnknown() {
  61. xxx_messageInfo_ProofOp.DiscardUnknown(m)
  62. }
  63. var xxx_messageInfo_ProofOp proto.InternalMessageInfo
  64. func (m *ProofOp) GetType() string {
  65. if m != nil {
  66. return m.Type
  67. }
  68. return ""
  69. }
  70. func (m *ProofOp) GetKey() []byte {
  71. if m != nil {
  72. return m.Key
  73. }
  74. return nil
  75. }
  76. func (m *ProofOp) GetData() []byte {
  77. if m != nil {
  78. return m.Data
  79. }
  80. return nil
  81. }
  82. // Proof is Merkle proof defined by the list of ProofOps
  83. type Proof struct {
  84. Ops []ProofOp `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops"`
  85. XXX_NoUnkeyedLiteral struct{} `json:"-"`
  86. XXX_unrecognized []byte `json:"-"`
  87. XXX_sizecache int32 `json:"-"`
  88. }
  89. func (m *Proof) Reset() { *m = Proof{} }
  90. func (m *Proof) String() string { return proto.CompactTextString(m) }
  91. func (*Proof) ProtoMessage() {}
  92. func (*Proof) Descriptor() ([]byte, []int) {
  93. return fileDescriptor_9c1c2162d560d38e, []int{1}
  94. }
  95. func (m *Proof) XXX_Unmarshal(b []byte) error {
  96. return m.Unmarshal(b)
  97. }
  98. func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
  99. if deterministic {
  100. return xxx_messageInfo_Proof.Marshal(b, m, deterministic)
  101. } else {
  102. b = b[:cap(b)]
  103. n, err := m.MarshalToSizedBuffer(b)
  104. if err != nil {
  105. return nil, err
  106. }
  107. return b[:n], nil
  108. }
  109. }
  110. func (m *Proof) XXX_Merge(src proto.Message) {
  111. xxx_messageInfo_Proof.Merge(m, src)
  112. }
  113. func (m *Proof) XXX_Size() int {
  114. return m.Size()
  115. }
  116. func (m *Proof) XXX_DiscardUnknown() {
  117. xxx_messageInfo_Proof.DiscardUnknown(m)
  118. }
  119. var xxx_messageInfo_Proof proto.InternalMessageInfo
  120. func (m *Proof) GetOps() []ProofOp {
  121. if m != nil {
  122. return m.Ops
  123. }
  124. return nil
  125. }
  126. func init() {
  127. proto.RegisterType((*ProofOp)(nil), "merkle.ProofOp")
  128. proto.RegisterType((*Proof)(nil), "merkle.Proof")
  129. }
  130. func init() { proto.RegisterFile("crypto/merkle/merkle.proto", fileDescriptor_9c1c2162d560d38e) }
  131. var fileDescriptor_9c1c2162d560d38e = []byte{
  132. // 200 bytes of a gzipped FileDescriptorProto
  133. 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x2e, 0xaa, 0x2c,
  134. 0x28, 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0xca, 0xce, 0x49, 0x85, 0x52, 0x7a, 0x05, 0x45, 0xf9, 0x25,
  135. 0xf9, 0x42, 0x6c, 0x10, 0x9e, 0x94, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e,
  136. 0xae, 0x7e, 0x7a, 0x7e, 0x7a, 0xbe, 0x3e, 0x58, 0x3a, 0xa9, 0x34, 0x0d, 0xcc, 0x03, 0x73, 0xc0,
  137. 0x2c, 0x88, 0x36, 0x25, 0x67, 0x2e, 0xf6, 0x80, 0xa2, 0xfc, 0xfc, 0x34, 0xff, 0x02, 0x21, 0x21,
  138. 0x2e, 0x96, 0x92, 0xca, 0x82, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x30, 0x5b, 0x48,
  139. 0x80, 0x8b, 0x39, 0x3b, 0xb5, 0x52, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc4, 0x04, 0xa9,
  140. 0x4a, 0x49, 0x2c, 0x49, 0x94, 0x60, 0x06, 0x0b, 0x81, 0xd9, 0x4a, 0x06, 0x5c, 0xac, 0x60, 0x43,
  141. 0x84, 0xd4, 0xb9, 0x98, 0xf3, 0x0b, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0xf8, 0xf5,
  142. 0xa0, 0x0e, 0x84, 0x5a, 0xe0, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x48, 0x85, 0x93, 0xc8,
  143. 0x8f, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c,
  144. 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x49, 0x6c, 0x60, 0x37, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff,
  145. 0xb9, 0x2b, 0x0f, 0xd1, 0xe8, 0x00, 0x00, 0x00,
  146. }
  147. func (this *ProofOp) Equal(that interface{}) bool {
  148. if that == nil {
  149. return this == nil
  150. }
  151. that1, ok := that.(*ProofOp)
  152. if !ok {
  153. that2, ok := that.(ProofOp)
  154. if ok {
  155. that1 = &that2
  156. } else {
  157. return false
  158. }
  159. }
  160. if that1 == nil {
  161. return this == nil
  162. } else if this == nil {
  163. return false
  164. }
  165. if this.Type != that1.Type {
  166. return false
  167. }
  168. if !bytes.Equal(this.Key, that1.Key) {
  169. return false
  170. }
  171. if !bytes.Equal(this.Data, that1.Data) {
  172. return false
  173. }
  174. if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
  175. return false
  176. }
  177. return true
  178. }
  179. func (this *Proof) Equal(that interface{}) bool {
  180. if that == nil {
  181. return this == nil
  182. }
  183. that1, ok := that.(*Proof)
  184. if !ok {
  185. that2, ok := that.(Proof)
  186. if ok {
  187. that1 = &that2
  188. } else {
  189. return false
  190. }
  191. }
  192. if that1 == nil {
  193. return this == nil
  194. } else if this == nil {
  195. return false
  196. }
  197. if len(this.Ops) != len(that1.Ops) {
  198. return false
  199. }
  200. for i := range this.Ops {
  201. if !this.Ops[i].Equal(&that1.Ops[i]) {
  202. return false
  203. }
  204. }
  205. if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
  206. return false
  207. }
  208. return true
  209. }
  210. func (m *ProofOp) Marshal() (dAtA []byte, err error) {
  211. size := m.Size()
  212. dAtA = make([]byte, size)
  213. n, err := m.MarshalToSizedBuffer(dAtA[:size])
  214. if err != nil {
  215. return nil, err
  216. }
  217. return dAtA[:n], nil
  218. }
  219. func (m *ProofOp) MarshalTo(dAtA []byte) (int, error) {
  220. size := m.Size()
  221. return m.MarshalToSizedBuffer(dAtA[:size])
  222. }
  223. func (m *ProofOp) MarshalToSizedBuffer(dAtA []byte) (int, error) {
  224. i := len(dAtA)
  225. _ = i
  226. var l int
  227. _ = l
  228. if m.XXX_unrecognized != nil {
  229. i -= len(m.XXX_unrecognized)
  230. copy(dAtA[i:], m.XXX_unrecognized)
  231. }
  232. if len(m.Data) > 0 {
  233. i -= len(m.Data)
  234. copy(dAtA[i:], m.Data)
  235. i = encodeVarintMerkle(dAtA, i, uint64(len(m.Data)))
  236. i--
  237. dAtA[i] = 0x1a
  238. }
  239. if len(m.Key) > 0 {
  240. i -= len(m.Key)
  241. copy(dAtA[i:], m.Key)
  242. i = encodeVarintMerkle(dAtA, i, uint64(len(m.Key)))
  243. i--
  244. dAtA[i] = 0x12
  245. }
  246. if len(m.Type) > 0 {
  247. i -= len(m.Type)
  248. copy(dAtA[i:], m.Type)
  249. i = encodeVarintMerkle(dAtA, i, uint64(len(m.Type)))
  250. i--
  251. dAtA[i] = 0xa
  252. }
  253. return len(dAtA) - i, nil
  254. }
  255. func (m *Proof) Marshal() (dAtA []byte, err error) {
  256. size := m.Size()
  257. dAtA = make([]byte, size)
  258. n, err := m.MarshalToSizedBuffer(dAtA[:size])
  259. if err != nil {
  260. return nil, err
  261. }
  262. return dAtA[:n], nil
  263. }
  264. func (m *Proof) MarshalTo(dAtA []byte) (int, error) {
  265. size := m.Size()
  266. return m.MarshalToSizedBuffer(dAtA[:size])
  267. }
  268. func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error) {
  269. i := len(dAtA)
  270. _ = i
  271. var l int
  272. _ = l
  273. if m.XXX_unrecognized != nil {
  274. i -= len(m.XXX_unrecognized)
  275. copy(dAtA[i:], m.XXX_unrecognized)
  276. }
  277. if len(m.Ops) > 0 {
  278. for iNdEx := len(m.Ops) - 1; iNdEx >= 0; iNdEx-- {
  279. {
  280. size, err := m.Ops[iNdEx].MarshalToSizedBuffer(dAtA[:i])
  281. if err != nil {
  282. return 0, err
  283. }
  284. i -= size
  285. i = encodeVarintMerkle(dAtA, i, uint64(size))
  286. }
  287. i--
  288. dAtA[i] = 0xa
  289. }
  290. }
  291. return len(dAtA) - i, nil
  292. }
  293. func encodeVarintMerkle(dAtA []byte, offset int, v uint64) int {
  294. offset -= sovMerkle(v)
  295. base := offset
  296. for v >= 1<<7 {
  297. dAtA[offset] = uint8(v&0x7f | 0x80)
  298. v >>= 7
  299. offset++
  300. }
  301. dAtA[offset] = uint8(v)
  302. return base
  303. }
  304. func NewPopulatedProofOp(r randyMerkle, easy bool) *ProofOp {
  305. this := &ProofOp{}
  306. this.Type = string(randStringMerkle(r))
  307. v1 := r.Intn(100)
  308. this.Key = make([]byte, v1)
  309. for i := 0; i < v1; i++ {
  310. this.Key[i] = byte(r.Intn(256))
  311. }
  312. v2 := r.Intn(100)
  313. this.Data = make([]byte, v2)
  314. for i := 0; i < v2; i++ {
  315. this.Data[i] = byte(r.Intn(256))
  316. }
  317. if !easy && r.Intn(10) != 0 {
  318. this.XXX_unrecognized = randUnrecognizedMerkle(r, 4)
  319. }
  320. return this
  321. }
  322. func NewPopulatedProof(r randyMerkle, easy bool) *Proof {
  323. this := &Proof{}
  324. if r.Intn(5) != 0 {
  325. v3 := r.Intn(5)
  326. this.Ops = make([]ProofOp, v3)
  327. for i := 0; i < v3; i++ {
  328. v4 := NewPopulatedProofOp(r, easy)
  329. this.Ops[i] = *v4
  330. }
  331. }
  332. if !easy && r.Intn(10) != 0 {
  333. this.XXX_unrecognized = randUnrecognizedMerkle(r, 2)
  334. }
  335. return this
  336. }
  337. type randyMerkle interface {
  338. Float32() float32
  339. Float64() float64
  340. Int63() int64
  341. Int31() int32
  342. Uint32() uint32
  343. Intn(n int) int
  344. }
  345. func randUTF8RuneMerkle(r randyMerkle) rune {
  346. ru := r.Intn(62)
  347. if ru < 10 {
  348. return rune(ru + 48)
  349. } else if ru < 36 {
  350. return rune(ru + 55)
  351. }
  352. return rune(ru + 61)
  353. }
  354. func randStringMerkle(r randyMerkle) string {
  355. v5 := r.Intn(100)
  356. tmps := make([]rune, v5)
  357. for i := 0; i < v5; i++ {
  358. tmps[i] = randUTF8RuneMerkle(r)
  359. }
  360. return string(tmps)
  361. }
  362. func randUnrecognizedMerkle(r randyMerkle, maxFieldNumber int) (dAtA []byte) {
  363. l := r.Intn(5)
  364. for i := 0; i < l; i++ {
  365. wire := r.Intn(4)
  366. if wire == 3 {
  367. wire = 5
  368. }
  369. fieldNumber := maxFieldNumber + r.Intn(100)
  370. dAtA = randFieldMerkle(dAtA, r, fieldNumber, wire)
  371. }
  372. return dAtA
  373. }
  374. func randFieldMerkle(dAtA []byte, r randyMerkle, fieldNumber int, wire int) []byte {
  375. key := uint32(fieldNumber)<<3 | uint32(wire)
  376. switch wire {
  377. case 0:
  378. dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key))
  379. v6 := r.Int63()
  380. if r.Intn(2) == 0 {
  381. v6 *= -1
  382. }
  383. dAtA = encodeVarintPopulateMerkle(dAtA, uint64(v6))
  384. case 1:
  385. dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key))
  386. dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
  387. case 2:
  388. dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key))
  389. ll := r.Intn(100)
  390. dAtA = encodeVarintPopulateMerkle(dAtA, uint64(ll))
  391. for j := 0; j < ll; j++ {
  392. dAtA = append(dAtA, byte(r.Intn(256)))
  393. }
  394. default:
  395. dAtA = encodeVarintPopulateMerkle(dAtA, uint64(key))
  396. dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
  397. }
  398. return dAtA
  399. }
  400. func encodeVarintPopulateMerkle(dAtA []byte, v uint64) []byte {
  401. for v >= 1<<7 {
  402. dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
  403. v >>= 7
  404. }
  405. dAtA = append(dAtA, uint8(v))
  406. return dAtA
  407. }
  408. func (m *ProofOp) Size() (n int) {
  409. if m == nil {
  410. return 0
  411. }
  412. var l int
  413. _ = l
  414. l = len(m.Type)
  415. if l > 0 {
  416. n += 1 + l + sovMerkle(uint64(l))
  417. }
  418. l = len(m.Key)
  419. if l > 0 {
  420. n += 1 + l + sovMerkle(uint64(l))
  421. }
  422. l = len(m.Data)
  423. if l > 0 {
  424. n += 1 + l + sovMerkle(uint64(l))
  425. }
  426. if m.XXX_unrecognized != nil {
  427. n += len(m.XXX_unrecognized)
  428. }
  429. return n
  430. }
  431. func (m *Proof) Size() (n int) {
  432. if m == nil {
  433. return 0
  434. }
  435. var l int
  436. _ = l
  437. if len(m.Ops) > 0 {
  438. for _, e := range m.Ops {
  439. l = e.Size()
  440. n += 1 + l + sovMerkle(uint64(l))
  441. }
  442. }
  443. if m.XXX_unrecognized != nil {
  444. n += len(m.XXX_unrecognized)
  445. }
  446. return n
  447. }
  448. func sovMerkle(x uint64) (n int) {
  449. return (math_bits.Len64(x|1) + 6) / 7
  450. }
  451. func sozMerkle(x uint64) (n int) {
  452. return sovMerkle(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  453. }
  454. func (m *ProofOp) Unmarshal(dAtA []byte) error {
  455. l := len(dAtA)
  456. iNdEx := 0
  457. for iNdEx < l {
  458. preIndex := iNdEx
  459. var wire uint64
  460. for shift := uint(0); ; shift += 7 {
  461. if shift >= 64 {
  462. return ErrIntOverflowMerkle
  463. }
  464. if iNdEx >= l {
  465. return io.ErrUnexpectedEOF
  466. }
  467. b := dAtA[iNdEx]
  468. iNdEx++
  469. wire |= uint64(b&0x7F) << shift
  470. if b < 0x80 {
  471. break
  472. }
  473. }
  474. fieldNum := int32(wire >> 3)
  475. wireType := int(wire & 0x7)
  476. if wireType == 4 {
  477. return fmt.Errorf("proto: ProofOp: wiretype end group for non-group")
  478. }
  479. if fieldNum <= 0 {
  480. return fmt.Errorf("proto: ProofOp: illegal tag %d (wire type %d)", fieldNum, wire)
  481. }
  482. switch fieldNum {
  483. case 1:
  484. if wireType != 2 {
  485. return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
  486. }
  487. var stringLen uint64
  488. for shift := uint(0); ; shift += 7 {
  489. if shift >= 64 {
  490. return ErrIntOverflowMerkle
  491. }
  492. if iNdEx >= l {
  493. return io.ErrUnexpectedEOF
  494. }
  495. b := dAtA[iNdEx]
  496. iNdEx++
  497. stringLen |= uint64(b&0x7F) << shift
  498. if b < 0x80 {
  499. break
  500. }
  501. }
  502. intStringLen := int(stringLen)
  503. if intStringLen < 0 {
  504. return ErrInvalidLengthMerkle
  505. }
  506. postIndex := iNdEx + intStringLen
  507. if postIndex < 0 {
  508. return ErrInvalidLengthMerkle
  509. }
  510. if postIndex > l {
  511. return io.ErrUnexpectedEOF
  512. }
  513. m.Type = string(dAtA[iNdEx:postIndex])
  514. iNdEx = postIndex
  515. case 2:
  516. if wireType != 2 {
  517. return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
  518. }
  519. var byteLen int
  520. for shift := uint(0); ; shift += 7 {
  521. if shift >= 64 {
  522. return ErrIntOverflowMerkle
  523. }
  524. if iNdEx >= l {
  525. return io.ErrUnexpectedEOF
  526. }
  527. b := dAtA[iNdEx]
  528. iNdEx++
  529. byteLen |= int(b&0x7F) << shift
  530. if b < 0x80 {
  531. break
  532. }
  533. }
  534. if byteLen < 0 {
  535. return ErrInvalidLengthMerkle
  536. }
  537. postIndex := iNdEx + byteLen
  538. if postIndex < 0 {
  539. return ErrInvalidLengthMerkle
  540. }
  541. if postIndex > l {
  542. return io.ErrUnexpectedEOF
  543. }
  544. m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
  545. if m.Key == nil {
  546. m.Key = []byte{}
  547. }
  548. iNdEx = postIndex
  549. case 3:
  550. if wireType != 2 {
  551. return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
  552. }
  553. var byteLen int
  554. for shift := uint(0); ; shift += 7 {
  555. if shift >= 64 {
  556. return ErrIntOverflowMerkle
  557. }
  558. if iNdEx >= l {
  559. return io.ErrUnexpectedEOF
  560. }
  561. b := dAtA[iNdEx]
  562. iNdEx++
  563. byteLen |= int(b&0x7F) << shift
  564. if b < 0x80 {
  565. break
  566. }
  567. }
  568. if byteLen < 0 {
  569. return ErrInvalidLengthMerkle
  570. }
  571. postIndex := iNdEx + byteLen
  572. if postIndex < 0 {
  573. return ErrInvalidLengthMerkle
  574. }
  575. if postIndex > l {
  576. return io.ErrUnexpectedEOF
  577. }
  578. m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
  579. if m.Data == nil {
  580. m.Data = []byte{}
  581. }
  582. iNdEx = postIndex
  583. default:
  584. iNdEx = preIndex
  585. skippy, err := skipMerkle(dAtA[iNdEx:])
  586. if err != nil {
  587. return err
  588. }
  589. if skippy < 0 {
  590. return ErrInvalidLengthMerkle
  591. }
  592. if (iNdEx + skippy) < 0 {
  593. return ErrInvalidLengthMerkle
  594. }
  595. if (iNdEx + skippy) > l {
  596. return io.ErrUnexpectedEOF
  597. }
  598. m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
  599. iNdEx += skippy
  600. }
  601. }
  602. if iNdEx > l {
  603. return io.ErrUnexpectedEOF
  604. }
  605. return nil
  606. }
  607. func (m *Proof) Unmarshal(dAtA []byte) error {
  608. l := len(dAtA)
  609. iNdEx := 0
  610. for iNdEx < l {
  611. preIndex := iNdEx
  612. var wire uint64
  613. for shift := uint(0); ; shift += 7 {
  614. if shift >= 64 {
  615. return ErrIntOverflowMerkle
  616. }
  617. if iNdEx >= l {
  618. return io.ErrUnexpectedEOF
  619. }
  620. b := dAtA[iNdEx]
  621. iNdEx++
  622. wire |= uint64(b&0x7F) << shift
  623. if b < 0x80 {
  624. break
  625. }
  626. }
  627. fieldNum := int32(wire >> 3)
  628. wireType := int(wire & 0x7)
  629. if wireType == 4 {
  630. return fmt.Errorf("proto: Proof: wiretype end group for non-group")
  631. }
  632. if fieldNum <= 0 {
  633. return fmt.Errorf("proto: Proof: illegal tag %d (wire type %d)", fieldNum, wire)
  634. }
  635. switch fieldNum {
  636. case 1:
  637. if wireType != 2 {
  638. return fmt.Errorf("proto: wrong wireType = %d for field Ops", wireType)
  639. }
  640. var msglen int
  641. for shift := uint(0); ; shift += 7 {
  642. if shift >= 64 {
  643. return ErrIntOverflowMerkle
  644. }
  645. if iNdEx >= l {
  646. return io.ErrUnexpectedEOF
  647. }
  648. b := dAtA[iNdEx]
  649. iNdEx++
  650. msglen |= int(b&0x7F) << shift
  651. if b < 0x80 {
  652. break
  653. }
  654. }
  655. if msglen < 0 {
  656. return ErrInvalidLengthMerkle
  657. }
  658. postIndex := iNdEx + msglen
  659. if postIndex < 0 {
  660. return ErrInvalidLengthMerkle
  661. }
  662. if postIndex > l {
  663. return io.ErrUnexpectedEOF
  664. }
  665. m.Ops = append(m.Ops, ProofOp{})
  666. if err := m.Ops[len(m.Ops)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
  667. return err
  668. }
  669. iNdEx = postIndex
  670. default:
  671. iNdEx = preIndex
  672. skippy, err := skipMerkle(dAtA[iNdEx:])
  673. if err != nil {
  674. return err
  675. }
  676. if skippy < 0 {
  677. return ErrInvalidLengthMerkle
  678. }
  679. if (iNdEx + skippy) < 0 {
  680. return ErrInvalidLengthMerkle
  681. }
  682. if (iNdEx + skippy) > l {
  683. return io.ErrUnexpectedEOF
  684. }
  685. m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
  686. iNdEx += skippy
  687. }
  688. }
  689. if iNdEx > l {
  690. return io.ErrUnexpectedEOF
  691. }
  692. return nil
  693. }
  694. func skipMerkle(dAtA []byte) (n int, err error) {
  695. l := len(dAtA)
  696. iNdEx := 0
  697. for iNdEx < l {
  698. var wire uint64
  699. for shift := uint(0); ; shift += 7 {
  700. if shift >= 64 {
  701. return 0, ErrIntOverflowMerkle
  702. }
  703. if iNdEx >= l {
  704. return 0, io.ErrUnexpectedEOF
  705. }
  706. b := dAtA[iNdEx]
  707. iNdEx++
  708. wire |= (uint64(b) & 0x7F) << shift
  709. if b < 0x80 {
  710. break
  711. }
  712. }
  713. wireType := int(wire & 0x7)
  714. switch wireType {
  715. case 0:
  716. for shift := uint(0); ; shift += 7 {
  717. if shift >= 64 {
  718. return 0, ErrIntOverflowMerkle
  719. }
  720. if iNdEx >= l {
  721. return 0, io.ErrUnexpectedEOF
  722. }
  723. iNdEx++
  724. if dAtA[iNdEx-1] < 0x80 {
  725. break
  726. }
  727. }
  728. return iNdEx, nil
  729. case 1:
  730. iNdEx += 8
  731. return iNdEx, nil
  732. case 2:
  733. var length int
  734. for shift := uint(0); ; shift += 7 {
  735. if shift >= 64 {
  736. return 0, ErrIntOverflowMerkle
  737. }
  738. if iNdEx >= l {
  739. return 0, io.ErrUnexpectedEOF
  740. }
  741. b := dAtA[iNdEx]
  742. iNdEx++
  743. length |= (int(b) & 0x7F) << shift
  744. if b < 0x80 {
  745. break
  746. }
  747. }
  748. if length < 0 {
  749. return 0, ErrInvalidLengthMerkle
  750. }
  751. iNdEx += length
  752. if iNdEx < 0 {
  753. return 0, ErrInvalidLengthMerkle
  754. }
  755. return iNdEx, nil
  756. case 3:
  757. for {
  758. var innerWire uint64
  759. var start int = iNdEx
  760. for shift := uint(0); ; shift += 7 {
  761. if shift >= 64 {
  762. return 0, ErrIntOverflowMerkle
  763. }
  764. if iNdEx >= l {
  765. return 0, io.ErrUnexpectedEOF
  766. }
  767. b := dAtA[iNdEx]
  768. iNdEx++
  769. innerWire |= (uint64(b) & 0x7F) << shift
  770. if b < 0x80 {
  771. break
  772. }
  773. }
  774. innerWireType := int(innerWire & 0x7)
  775. if innerWireType == 4 {
  776. break
  777. }
  778. next, err := skipMerkle(dAtA[start:])
  779. if err != nil {
  780. return 0, err
  781. }
  782. iNdEx = start + next
  783. if iNdEx < 0 {
  784. return 0, ErrInvalidLengthMerkle
  785. }
  786. }
  787. return iNdEx, nil
  788. case 4:
  789. return iNdEx, nil
  790. case 5:
  791. iNdEx += 4
  792. return iNdEx, nil
  793. default:
  794. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  795. }
  796. }
  797. panic("unreachable")
  798. }
  799. var (
  800. ErrInvalidLengthMerkle = fmt.Errorf("proto: negative length found during unmarshaling")
  801. ErrIntOverflowMerkle = fmt.Errorf("proto: integer overflow")
  802. )