raft.pb.go 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768
  1. // Code generated by protoc-gen-gogo.
  2. // source: raft.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package raftpb is a generated protocol buffer package.
  6. It is generated from these files:
  7. raft.proto
  8. It has these top-level messages:
  9. Entry
  10. SnapshotMetadata
  11. Snapshot
  12. Message
  13. HardState
  14. ConfState
  15. ConfChange
  16. */
  17. package raftpb
  18. import (
  19. "fmt"
  20. proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
  21. )
  22. import math "math"
  23. import io "io"
  24. // Reference imports to suppress errors if they are not otherwise used.
  25. var _ = proto.Marshal
  26. var _ = fmt.Errorf
  27. var _ = math.Inf
  28. type EntryType int32
  29. const (
  30. EntryNormal EntryType = 0
  31. EntryConfChange EntryType = 1
  32. )
  33. var EntryType_name = map[int32]string{
  34. 0: "EntryNormal",
  35. 1: "EntryConfChange",
  36. }
  37. var EntryType_value = map[string]int32{
  38. "EntryNormal": 0,
  39. "EntryConfChange": 1,
  40. }
  41. func (x EntryType) Enum() *EntryType {
  42. p := new(EntryType)
  43. *p = x
  44. return p
  45. }
  46. func (x EntryType) String() string {
  47. return proto.EnumName(EntryType_name, int32(x))
  48. }
  49. func (x *EntryType) UnmarshalJSON(data []byte) error {
  50. value, err := proto.UnmarshalJSONEnum(EntryType_value, data, "EntryType")
  51. if err != nil {
  52. return err
  53. }
  54. *x = EntryType(value)
  55. return nil
  56. }
  57. type MessageType int32
  58. const (
  59. MsgHup MessageType = 0
  60. MsgBeat MessageType = 1
  61. MsgProp MessageType = 2
  62. MsgApp MessageType = 3
  63. MsgAppResp MessageType = 4
  64. MsgVote MessageType = 5
  65. MsgVoteResp MessageType = 6
  66. MsgSnap MessageType = 7
  67. MsgHeartbeat MessageType = 8
  68. MsgHeartbeatResp MessageType = 9
  69. MsgUnreachable MessageType = 10
  70. MsgSnapStatus MessageType = 11
  71. MsgCheckQuorum MessageType = 12
  72. )
  73. var MessageType_name = map[int32]string{
  74. 0: "MsgHup",
  75. 1: "MsgBeat",
  76. 2: "MsgProp",
  77. 3: "MsgApp",
  78. 4: "MsgAppResp",
  79. 5: "MsgVote",
  80. 6: "MsgVoteResp",
  81. 7: "MsgSnap",
  82. 8: "MsgHeartbeat",
  83. 9: "MsgHeartbeatResp",
  84. 10: "MsgUnreachable",
  85. 11: "MsgSnapStatus",
  86. 12: "MsgCheckQuorum",
  87. }
  88. var MessageType_value = map[string]int32{
  89. "MsgHup": 0,
  90. "MsgBeat": 1,
  91. "MsgProp": 2,
  92. "MsgApp": 3,
  93. "MsgAppResp": 4,
  94. "MsgVote": 5,
  95. "MsgVoteResp": 6,
  96. "MsgSnap": 7,
  97. "MsgHeartbeat": 8,
  98. "MsgHeartbeatResp": 9,
  99. "MsgUnreachable": 10,
  100. "MsgSnapStatus": 11,
  101. "MsgCheckQuorum": 12,
  102. }
  103. func (x MessageType) Enum() *MessageType {
  104. p := new(MessageType)
  105. *p = x
  106. return p
  107. }
  108. func (x MessageType) String() string {
  109. return proto.EnumName(MessageType_name, int32(x))
  110. }
  111. func (x *MessageType) UnmarshalJSON(data []byte) error {
  112. value, err := proto.UnmarshalJSONEnum(MessageType_value, data, "MessageType")
  113. if err != nil {
  114. return err
  115. }
  116. *x = MessageType(value)
  117. return nil
  118. }
  119. type ConfChangeType int32
  120. const (
  121. ConfChangeAddNode ConfChangeType = 0
  122. ConfChangeRemoveNode ConfChangeType = 1
  123. ConfChangeUpdateNode ConfChangeType = 2
  124. )
  125. var ConfChangeType_name = map[int32]string{
  126. 0: "ConfChangeAddNode",
  127. 1: "ConfChangeRemoveNode",
  128. 2: "ConfChangeUpdateNode",
  129. }
  130. var ConfChangeType_value = map[string]int32{
  131. "ConfChangeAddNode": 0,
  132. "ConfChangeRemoveNode": 1,
  133. "ConfChangeUpdateNode": 2,
  134. }
  135. func (x ConfChangeType) Enum() *ConfChangeType {
  136. p := new(ConfChangeType)
  137. *p = x
  138. return p
  139. }
  140. func (x ConfChangeType) String() string {
  141. return proto.EnumName(ConfChangeType_name, int32(x))
  142. }
  143. func (x *ConfChangeType) UnmarshalJSON(data []byte) error {
  144. value, err := proto.UnmarshalJSONEnum(ConfChangeType_value, data, "ConfChangeType")
  145. if err != nil {
  146. return err
  147. }
  148. *x = ConfChangeType(value)
  149. return nil
  150. }
  151. type Entry struct {
  152. Type EntryType `protobuf:"varint,1,opt,name=Type,enum=raftpb.EntryType" json:"Type"`
  153. Term uint64 `protobuf:"varint,2,opt,name=Term" json:"Term"`
  154. Index uint64 `protobuf:"varint,3,opt,name=Index" json:"Index"`
  155. Data []byte `protobuf:"bytes,4,opt,name=Data" json:"Data,omitempty"`
  156. XXX_unrecognized []byte `json:"-"`
  157. }
  158. func (m *Entry) Reset() { *m = Entry{} }
  159. func (m *Entry) String() string { return proto.CompactTextString(m) }
  160. func (*Entry) ProtoMessage() {}
  161. type SnapshotMetadata struct {
  162. ConfState ConfState `protobuf:"bytes,1,opt,name=conf_state" json:"conf_state"`
  163. Index uint64 `protobuf:"varint,2,opt,name=index" json:"index"`
  164. Term uint64 `protobuf:"varint,3,opt,name=term" json:"term"`
  165. XXX_unrecognized []byte `json:"-"`
  166. }
  167. func (m *SnapshotMetadata) Reset() { *m = SnapshotMetadata{} }
  168. func (m *SnapshotMetadata) String() string { return proto.CompactTextString(m) }
  169. func (*SnapshotMetadata) ProtoMessage() {}
  170. type Snapshot struct {
  171. Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
  172. Metadata SnapshotMetadata `protobuf:"bytes,2,opt,name=metadata" json:"metadata"`
  173. XXX_unrecognized []byte `json:"-"`
  174. }
  175. func (m *Snapshot) Reset() { *m = Snapshot{} }
  176. func (m *Snapshot) String() string { return proto.CompactTextString(m) }
  177. func (*Snapshot) ProtoMessage() {}
  178. type Message struct {
  179. Type MessageType `protobuf:"varint,1,opt,name=type,enum=raftpb.MessageType" json:"type"`
  180. To uint64 `protobuf:"varint,2,opt,name=to" json:"to"`
  181. From uint64 `protobuf:"varint,3,opt,name=from" json:"from"`
  182. Term uint64 `protobuf:"varint,4,opt,name=term" json:"term"`
  183. LogTerm uint64 `protobuf:"varint,5,opt,name=logTerm" json:"logTerm"`
  184. Index uint64 `protobuf:"varint,6,opt,name=index" json:"index"`
  185. Entries []Entry `protobuf:"bytes,7,rep,name=entries" json:"entries"`
  186. Commit uint64 `protobuf:"varint,8,opt,name=commit" json:"commit"`
  187. Snapshot Snapshot `protobuf:"bytes,9,opt,name=snapshot" json:"snapshot"`
  188. Reject bool `protobuf:"varint,10,opt,name=reject" json:"reject"`
  189. RejectHint uint64 `protobuf:"varint,11,opt,name=rejectHint" json:"rejectHint"`
  190. XXX_unrecognized []byte `json:"-"`
  191. }
  192. func (m *Message) Reset() { *m = Message{} }
  193. func (m *Message) String() string { return proto.CompactTextString(m) }
  194. func (*Message) ProtoMessage() {}
  195. type HardState struct {
  196. Term uint64 `protobuf:"varint,1,opt,name=term" json:"term"`
  197. Vote uint64 `protobuf:"varint,2,opt,name=vote" json:"vote"`
  198. Commit uint64 `protobuf:"varint,3,opt,name=commit" json:"commit"`
  199. XXX_unrecognized []byte `json:"-"`
  200. }
  201. func (m *HardState) Reset() { *m = HardState{} }
  202. func (m *HardState) String() string { return proto.CompactTextString(m) }
  203. func (*HardState) ProtoMessage() {}
  204. type ConfState struct {
  205. Nodes []uint64 `protobuf:"varint,1,rep,name=nodes" json:"nodes,omitempty"`
  206. XXX_unrecognized []byte `json:"-"`
  207. }
  208. func (m *ConfState) Reset() { *m = ConfState{} }
  209. func (m *ConfState) String() string { return proto.CompactTextString(m) }
  210. func (*ConfState) ProtoMessage() {}
  211. type ConfChange struct {
  212. ID uint64 `protobuf:"varint,1,opt,name=ID" json:"ID"`
  213. Type ConfChangeType `protobuf:"varint,2,opt,name=Type,enum=raftpb.ConfChangeType" json:"Type"`
  214. NodeID uint64 `protobuf:"varint,3,opt,name=NodeID" json:"NodeID"`
  215. Context []byte `protobuf:"bytes,4,opt,name=Context" json:"Context,omitempty"`
  216. XXX_unrecognized []byte `json:"-"`
  217. }
  218. func (m *ConfChange) Reset() { *m = ConfChange{} }
  219. func (m *ConfChange) String() string { return proto.CompactTextString(m) }
  220. func (*ConfChange) ProtoMessage() {}
  221. func init() {
  222. proto.RegisterType((*Entry)(nil), "raftpb.Entry")
  223. proto.RegisterType((*SnapshotMetadata)(nil), "raftpb.SnapshotMetadata")
  224. proto.RegisterType((*Snapshot)(nil), "raftpb.Snapshot")
  225. proto.RegisterType((*Message)(nil), "raftpb.Message")
  226. proto.RegisterType((*HardState)(nil), "raftpb.HardState")
  227. proto.RegisterType((*ConfState)(nil), "raftpb.ConfState")
  228. proto.RegisterType((*ConfChange)(nil), "raftpb.ConfChange")
  229. proto.RegisterEnum("raftpb.EntryType", EntryType_name, EntryType_value)
  230. proto.RegisterEnum("raftpb.MessageType", MessageType_name, MessageType_value)
  231. proto.RegisterEnum("raftpb.ConfChangeType", ConfChangeType_name, ConfChangeType_value)
  232. }
  233. func (m *Entry) Marshal() (data []byte, err error) {
  234. size := m.Size()
  235. data = make([]byte, size)
  236. n, err := m.MarshalTo(data)
  237. if err != nil {
  238. return nil, err
  239. }
  240. return data[:n], nil
  241. }
  242. func (m *Entry) MarshalTo(data []byte) (int, error) {
  243. var i int
  244. _ = i
  245. var l int
  246. _ = l
  247. data[i] = 0x8
  248. i++
  249. i = encodeVarintRaft(data, i, uint64(m.Type))
  250. data[i] = 0x10
  251. i++
  252. i = encodeVarintRaft(data, i, uint64(m.Term))
  253. data[i] = 0x18
  254. i++
  255. i = encodeVarintRaft(data, i, uint64(m.Index))
  256. if m.Data != nil {
  257. data[i] = 0x22
  258. i++
  259. i = encodeVarintRaft(data, i, uint64(len(m.Data)))
  260. i += copy(data[i:], m.Data)
  261. }
  262. if m.XXX_unrecognized != nil {
  263. i += copy(data[i:], m.XXX_unrecognized)
  264. }
  265. return i, nil
  266. }
  267. func (m *SnapshotMetadata) Marshal() (data []byte, err error) {
  268. size := m.Size()
  269. data = make([]byte, size)
  270. n, err := m.MarshalTo(data)
  271. if err != nil {
  272. return nil, err
  273. }
  274. return data[:n], nil
  275. }
  276. func (m *SnapshotMetadata) MarshalTo(data []byte) (int, error) {
  277. var i int
  278. _ = i
  279. var l int
  280. _ = l
  281. data[i] = 0xa
  282. i++
  283. i = encodeVarintRaft(data, i, uint64(m.ConfState.Size()))
  284. n1, err := m.ConfState.MarshalTo(data[i:])
  285. if err != nil {
  286. return 0, err
  287. }
  288. i += n1
  289. data[i] = 0x10
  290. i++
  291. i = encodeVarintRaft(data, i, uint64(m.Index))
  292. data[i] = 0x18
  293. i++
  294. i = encodeVarintRaft(data, i, uint64(m.Term))
  295. if m.XXX_unrecognized != nil {
  296. i += copy(data[i:], m.XXX_unrecognized)
  297. }
  298. return i, nil
  299. }
  300. func (m *Snapshot) Marshal() (data []byte, err error) {
  301. size := m.Size()
  302. data = make([]byte, size)
  303. n, err := m.MarshalTo(data)
  304. if err != nil {
  305. return nil, err
  306. }
  307. return data[:n], nil
  308. }
  309. func (m *Snapshot) MarshalTo(data []byte) (int, error) {
  310. var i int
  311. _ = i
  312. var l int
  313. _ = l
  314. if m.Data != nil {
  315. data[i] = 0xa
  316. i++
  317. i = encodeVarintRaft(data, i, uint64(len(m.Data)))
  318. i += copy(data[i:], m.Data)
  319. }
  320. data[i] = 0x12
  321. i++
  322. i = encodeVarintRaft(data, i, uint64(m.Metadata.Size()))
  323. n2, err := m.Metadata.MarshalTo(data[i:])
  324. if err != nil {
  325. return 0, err
  326. }
  327. i += n2
  328. if m.XXX_unrecognized != nil {
  329. i += copy(data[i:], m.XXX_unrecognized)
  330. }
  331. return i, nil
  332. }
  333. func (m *Message) Marshal() (data []byte, err error) {
  334. size := m.Size()
  335. data = make([]byte, size)
  336. n, err := m.MarshalTo(data)
  337. if err != nil {
  338. return nil, err
  339. }
  340. return data[:n], nil
  341. }
  342. func (m *Message) MarshalTo(data []byte) (int, error) {
  343. var i int
  344. _ = i
  345. var l int
  346. _ = l
  347. data[i] = 0x8
  348. i++
  349. i = encodeVarintRaft(data, i, uint64(m.Type))
  350. data[i] = 0x10
  351. i++
  352. i = encodeVarintRaft(data, i, uint64(m.To))
  353. data[i] = 0x18
  354. i++
  355. i = encodeVarintRaft(data, i, uint64(m.From))
  356. data[i] = 0x20
  357. i++
  358. i = encodeVarintRaft(data, i, uint64(m.Term))
  359. data[i] = 0x28
  360. i++
  361. i = encodeVarintRaft(data, i, uint64(m.LogTerm))
  362. data[i] = 0x30
  363. i++
  364. i = encodeVarintRaft(data, i, uint64(m.Index))
  365. if len(m.Entries) > 0 {
  366. for _, msg := range m.Entries {
  367. data[i] = 0x3a
  368. i++
  369. i = encodeVarintRaft(data, i, uint64(msg.Size()))
  370. n, err := msg.MarshalTo(data[i:])
  371. if err != nil {
  372. return 0, err
  373. }
  374. i += n
  375. }
  376. }
  377. data[i] = 0x40
  378. i++
  379. i = encodeVarintRaft(data, i, uint64(m.Commit))
  380. data[i] = 0x4a
  381. i++
  382. i = encodeVarintRaft(data, i, uint64(m.Snapshot.Size()))
  383. n3, err := m.Snapshot.MarshalTo(data[i:])
  384. if err != nil {
  385. return 0, err
  386. }
  387. i += n3
  388. data[i] = 0x50
  389. i++
  390. if m.Reject {
  391. data[i] = 1
  392. } else {
  393. data[i] = 0
  394. }
  395. i++
  396. data[i] = 0x58
  397. i++
  398. i = encodeVarintRaft(data, i, uint64(m.RejectHint))
  399. if m.XXX_unrecognized != nil {
  400. i += copy(data[i:], m.XXX_unrecognized)
  401. }
  402. return i, nil
  403. }
  404. func (m *HardState) Marshal() (data []byte, err error) {
  405. size := m.Size()
  406. data = make([]byte, size)
  407. n, err := m.MarshalTo(data)
  408. if err != nil {
  409. return nil, err
  410. }
  411. return data[:n], nil
  412. }
  413. func (m *HardState) MarshalTo(data []byte) (int, error) {
  414. var i int
  415. _ = i
  416. var l int
  417. _ = l
  418. data[i] = 0x8
  419. i++
  420. i = encodeVarintRaft(data, i, uint64(m.Term))
  421. data[i] = 0x10
  422. i++
  423. i = encodeVarintRaft(data, i, uint64(m.Vote))
  424. data[i] = 0x18
  425. i++
  426. i = encodeVarintRaft(data, i, uint64(m.Commit))
  427. if m.XXX_unrecognized != nil {
  428. i += copy(data[i:], m.XXX_unrecognized)
  429. }
  430. return i, nil
  431. }
  432. func (m *ConfState) Marshal() (data []byte, err error) {
  433. size := m.Size()
  434. data = make([]byte, size)
  435. n, err := m.MarshalTo(data)
  436. if err != nil {
  437. return nil, err
  438. }
  439. return data[:n], nil
  440. }
  441. func (m *ConfState) MarshalTo(data []byte) (int, error) {
  442. var i int
  443. _ = i
  444. var l int
  445. _ = l
  446. if len(m.Nodes) > 0 {
  447. for _, num := range m.Nodes {
  448. data[i] = 0x8
  449. i++
  450. i = encodeVarintRaft(data, i, uint64(num))
  451. }
  452. }
  453. if m.XXX_unrecognized != nil {
  454. i += copy(data[i:], m.XXX_unrecognized)
  455. }
  456. return i, nil
  457. }
  458. func (m *ConfChange) Marshal() (data []byte, err error) {
  459. size := m.Size()
  460. data = make([]byte, size)
  461. n, err := m.MarshalTo(data)
  462. if err != nil {
  463. return nil, err
  464. }
  465. return data[:n], nil
  466. }
  467. func (m *ConfChange) MarshalTo(data []byte) (int, error) {
  468. var i int
  469. _ = i
  470. var l int
  471. _ = l
  472. data[i] = 0x8
  473. i++
  474. i = encodeVarintRaft(data, i, uint64(m.ID))
  475. data[i] = 0x10
  476. i++
  477. i = encodeVarintRaft(data, i, uint64(m.Type))
  478. data[i] = 0x18
  479. i++
  480. i = encodeVarintRaft(data, i, uint64(m.NodeID))
  481. if m.Context != nil {
  482. data[i] = 0x22
  483. i++
  484. i = encodeVarintRaft(data, i, uint64(len(m.Context)))
  485. i += copy(data[i:], m.Context)
  486. }
  487. if m.XXX_unrecognized != nil {
  488. i += copy(data[i:], m.XXX_unrecognized)
  489. }
  490. return i, nil
  491. }
  492. func encodeFixed64Raft(data []byte, offset int, v uint64) int {
  493. data[offset] = uint8(v)
  494. data[offset+1] = uint8(v >> 8)
  495. data[offset+2] = uint8(v >> 16)
  496. data[offset+3] = uint8(v >> 24)
  497. data[offset+4] = uint8(v >> 32)
  498. data[offset+5] = uint8(v >> 40)
  499. data[offset+6] = uint8(v >> 48)
  500. data[offset+7] = uint8(v >> 56)
  501. return offset + 8
  502. }
  503. func encodeFixed32Raft(data []byte, offset int, v uint32) int {
  504. data[offset] = uint8(v)
  505. data[offset+1] = uint8(v >> 8)
  506. data[offset+2] = uint8(v >> 16)
  507. data[offset+3] = uint8(v >> 24)
  508. return offset + 4
  509. }
  510. func encodeVarintRaft(data []byte, offset int, v uint64) int {
  511. for v >= 1<<7 {
  512. data[offset] = uint8(v&0x7f | 0x80)
  513. v >>= 7
  514. offset++
  515. }
  516. data[offset] = uint8(v)
  517. return offset + 1
  518. }
  519. func (m *Entry) Size() (n int) {
  520. var l int
  521. _ = l
  522. n += 1 + sovRaft(uint64(m.Type))
  523. n += 1 + sovRaft(uint64(m.Term))
  524. n += 1 + sovRaft(uint64(m.Index))
  525. if m.Data != nil {
  526. l = len(m.Data)
  527. n += 1 + l + sovRaft(uint64(l))
  528. }
  529. if m.XXX_unrecognized != nil {
  530. n += len(m.XXX_unrecognized)
  531. }
  532. return n
  533. }
  534. func (m *SnapshotMetadata) Size() (n int) {
  535. var l int
  536. _ = l
  537. l = m.ConfState.Size()
  538. n += 1 + l + sovRaft(uint64(l))
  539. n += 1 + sovRaft(uint64(m.Index))
  540. n += 1 + sovRaft(uint64(m.Term))
  541. if m.XXX_unrecognized != nil {
  542. n += len(m.XXX_unrecognized)
  543. }
  544. return n
  545. }
  546. func (m *Snapshot) Size() (n int) {
  547. var l int
  548. _ = l
  549. if m.Data != nil {
  550. l = len(m.Data)
  551. n += 1 + l + sovRaft(uint64(l))
  552. }
  553. l = m.Metadata.Size()
  554. n += 1 + l + sovRaft(uint64(l))
  555. if m.XXX_unrecognized != nil {
  556. n += len(m.XXX_unrecognized)
  557. }
  558. return n
  559. }
  560. func (m *Message) Size() (n int) {
  561. var l int
  562. _ = l
  563. n += 1 + sovRaft(uint64(m.Type))
  564. n += 1 + sovRaft(uint64(m.To))
  565. n += 1 + sovRaft(uint64(m.From))
  566. n += 1 + sovRaft(uint64(m.Term))
  567. n += 1 + sovRaft(uint64(m.LogTerm))
  568. n += 1 + sovRaft(uint64(m.Index))
  569. if len(m.Entries) > 0 {
  570. for _, e := range m.Entries {
  571. l = e.Size()
  572. n += 1 + l + sovRaft(uint64(l))
  573. }
  574. }
  575. n += 1 + sovRaft(uint64(m.Commit))
  576. l = m.Snapshot.Size()
  577. n += 1 + l + sovRaft(uint64(l))
  578. n += 2
  579. n += 1 + sovRaft(uint64(m.RejectHint))
  580. if m.XXX_unrecognized != nil {
  581. n += len(m.XXX_unrecognized)
  582. }
  583. return n
  584. }
  585. func (m *HardState) Size() (n int) {
  586. var l int
  587. _ = l
  588. n += 1 + sovRaft(uint64(m.Term))
  589. n += 1 + sovRaft(uint64(m.Vote))
  590. n += 1 + sovRaft(uint64(m.Commit))
  591. if m.XXX_unrecognized != nil {
  592. n += len(m.XXX_unrecognized)
  593. }
  594. return n
  595. }
  596. func (m *ConfState) Size() (n int) {
  597. var l int
  598. _ = l
  599. if len(m.Nodes) > 0 {
  600. for _, e := range m.Nodes {
  601. n += 1 + sovRaft(uint64(e))
  602. }
  603. }
  604. if m.XXX_unrecognized != nil {
  605. n += len(m.XXX_unrecognized)
  606. }
  607. return n
  608. }
  609. func (m *ConfChange) Size() (n int) {
  610. var l int
  611. _ = l
  612. n += 1 + sovRaft(uint64(m.ID))
  613. n += 1 + sovRaft(uint64(m.Type))
  614. n += 1 + sovRaft(uint64(m.NodeID))
  615. if m.Context != nil {
  616. l = len(m.Context)
  617. n += 1 + l + sovRaft(uint64(l))
  618. }
  619. if m.XXX_unrecognized != nil {
  620. n += len(m.XXX_unrecognized)
  621. }
  622. return n
  623. }
  624. func sovRaft(x uint64) (n int) {
  625. for {
  626. n++
  627. x >>= 7
  628. if x == 0 {
  629. break
  630. }
  631. }
  632. return n
  633. }
  634. func sozRaft(x uint64) (n int) {
  635. return sovRaft(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  636. }
  637. func (m *Entry) Unmarshal(data []byte) error {
  638. l := len(data)
  639. iNdEx := 0
  640. for iNdEx < l {
  641. preIndex := iNdEx
  642. var wire uint64
  643. for shift := uint(0); ; shift += 7 {
  644. if shift >= 64 {
  645. return ErrIntOverflowRaft
  646. }
  647. if iNdEx >= l {
  648. return io.ErrUnexpectedEOF
  649. }
  650. b := data[iNdEx]
  651. iNdEx++
  652. wire |= (uint64(b) & 0x7F) << shift
  653. if b < 0x80 {
  654. break
  655. }
  656. }
  657. fieldNum := int32(wire >> 3)
  658. wireType := int(wire & 0x7)
  659. if wireType == 4 {
  660. return fmt.Errorf("proto: Entry: wiretype end group for non-group")
  661. }
  662. if fieldNum <= 0 {
  663. return fmt.Errorf("proto: Entry: illegal tag %d (wire type %d)", fieldNum, wire)
  664. }
  665. switch fieldNum {
  666. case 1:
  667. if wireType != 0 {
  668. return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
  669. }
  670. m.Type = 0
  671. for shift := uint(0); ; shift += 7 {
  672. if shift >= 64 {
  673. return ErrIntOverflowRaft
  674. }
  675. if iNdEx >= l {
  676. return io.ErrUnexpectedEOF
  677. }
  678. b := data[iNdEx]
  679. iNdEx++
  680. m.Type |= (EntryType(b) & 0x7F) << shift
  681. if b < 0x80 {
  682. break
  683. }
  684. }
  685. case 2:
  686. if wireType != 0 {
  687. return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
  688. }
  689. m.Term = 0
  690. for shift := uint(0); ; shift += 7 {
  691. if shift >= 64 {
  692. return ErrIntOverflowRaft
  693. }
  694. if iNdEx >= l {
  695. return io.ErrUnexpectedEOF
  696. }
  697. b := data[iNdEx]
  698. iNdEx++
  699. m.Term |= (uint64(b) & 0x7F) << shift
  700. if b < 0x80 {
  701. break
  702. }
  703. }
  704. case 3:
  705. if wireType != 0 {
  706. return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
  707. }
  708. m.Index = 0
  709. for shift := uint(0); ; shift += 7 {
  710. if shift >= 64 {
  711. return ErrIntOverflowRaft
  712. }
  713. if iNdEx >= l {
  714. return io.ErrUnexpectedEOF
  715. }
  716. b := data[iNdEx]
  717. iNdEx++
  718. m.Index |= (uint64(b) & 0x7F) << shift
  719. if b < 0x80 {
  720. break
  721. }
  722. }
  723. case 4:
  724. if wireType != 2 {
  725. return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
  726. }
  727. var byteLen int
  728. for shift := uint(0); ; shift += 7 {
  729. if shift >= 64 {
  730. return ErrIntOverflowRaft
  731. }
  732. if iNdEx >= l {
  733. return io.ErrUnexpectedEOF
  734. }
  735. b := data[iNdEx]
  736. iNdEx++
  737. byteLen |= (int(b) & 0x7F) << shift
  738. if b < 0x80 {
  739. break
  740. }
  741. }
  742. if byteLen < 0 {
  743. return ErrInvalidLengthRaft
  744. }
  745. postIndex := iNdEx + byteLen
  746. if postIndex > l {
  747. return io.ErrUnexpectedEOF
  748. }
  749. m.Data = append(m.Data[:0], data[iNdEx:postIndex]...)
  750. if m.Data == nil {
  751. m.Data = []byte{}
  752. }
  753. iNdEx = postIndex
  754. default:
  755. iNdEx = preIndex
  756. skippy, err := skipRaft(data[iNdEx:])
  757. if err != nil {
  758. return err
  759. }
  760. if skippy < 0 {
  761. return ErrInvalidLengthRaft
  762. }
  763. if (iNdEx + skippy) > l {
  764. return io.ErrUnexpectedEOF
  765. }
  766. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  767. iNdEx += skippy
  768. }
  769. }
  770. if iNdEx > l {
  771. return io.ErrUnexpectedEOF
  772. }
  773. return nil
  774. }
  775. func (m *SnapshotMetadata) Unmarshal(data []byte) error {
  776. l := len(data)
  777. iNdEx := 0
  778. for iNdEx < l {
  779. preIndex := iNdEx
  780. var wire uint64
  781. for shift := uint(0); ; shift += 7 {
  782. if shift >= 64 {
  783. return ErrIntOverflowRaft
  784. }
  785. if iNdEx >= l {
  786. return io.ErrUnexpectedEOF
  787. }
  788. b := data[iNdEx]
  789. iNdEx++
  790. wire |= (uint64(b) & 0x7F) << shift
  791. if b < 0x80 {
  792. break
  793. }
  794. }
  795. fieldNum := int32(wire >> 3)
  796. wireType := int(wire & 0x7)
  797. if wireType == 4 {
  798. return fmt.Errorf("proto: SnapshotMetadata: wiretype end group for non-group")
  799. }
  800. if fieldNum <= 0 {
  801. return fmt.Errorf("proto: SnapshotMetadata: illegal tag %d (wire type %d)", fieldNum, wire)
  802. }
  803. switch fieldNum {
  804. case 1:
  805. if wireType != 2 {
  806. return fmt.Errorf("proto: wrong wireType = %d for field ConfState", wireType)
  807. }
  808. var msglen int
  809. for shift := uint(0); ; shift += 7 {
  810. if shift >= 64 {
  811. return ErrIntOverflowRaft
  812. }
  813. if iNdEx >= l {
  814. return io.ErrUnexpectedEOF
  815. }
  816. b := data[iNdEx]
  817. iNdEx++
  818. msglen |= (int(b) & 0x7F) << shift
  819. if b < 0x80 {
  820. break
  821. }
  822. }
  823. if msglen < 0 {
  824. return ErrInvalidLengthRaft
  825. }
  826. postIndex := iNdEx + msglen
  827. if postIndex > l {
  828. return io.ErrUnexpectedEOF
  829. }
  830. if err := m.ConfState.Unmarshal(data[iNdEx:postIndex]); err != nil {
  831. return err
  832. }
  833. iNdEx = postIndex
  834. case 2:
  835. if wireType != 0 {
  836. return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
  837. }
  838. m.Index = 0
  839. for shift := uint(0); ; shift += 7 {
  840. if shift >= 64 {
  841. return ErrIntOverflowRaft
  842. }
  843. if iNdEx >= l {
  844. return io.ErrUnexpectedEOF
  845. }
  846. b := data[iNdEx]
  847. iNdEx++
  848. m.Index |= (uint64(b) & 0x7F) << shift
  849. if b < 0x80 {
  850. break
  851. }
  852. }
  853. case 3:
  854. if wireType != 0 {
  855. return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
  856. }
  857. m.Term = 0
  858. for shift := uint(0); ; shift += 7 {
  859. if shift >= 64 {
  860. return ErrIntOverflowRaft
  861. }
  862. if iNdEx >= l {
  863. return io.ErrUnexpectedEOF
  864. }
  865. b := data[iNdEx]
  866. iNdEx++
  867. m.Term |= (uint64(b) & 0x7F) << shift
  868. if b < 0x80 {
  869. break
  870. }
  871. }
  872. default:
  873. iNdEx = preIndex
  874. skippy, err := skipRaft(data[iNdEx:])
  875. if err != nil {
  876. return err
  877. }
  878. if skippy < 0 {
  879. return ErrInvalidLengthRaft
  880. }
  881. if (iNdEx + skippy) > l {
  882. return io.ErrUnexpectedEOF
  883. }
  884. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  885. iNdEx += skippy
  886. }
  887. }
  888. if iNdEx > l {
  889. return io.ErrUnexpectedEOF
  890. }
  891. return nil
  892. }
  893. func (m *Snapshot) Unmarshal(data []byte) error {
  894. l := len(data)
  895. iNdEx := 0
  896. for iNdEx < l {
  897. preIndex := iNdEx
  898. var wire uint64
  899. for shift := uint(0); ; shift += 7 {
  900. if shift >= 64 {
  901. return ErrIntOverflowRaft
  902. }
  903. if iNdEx >= l {
  904. return io.ErrUnexpectedEOF
  905. }
  906. b := data[iNdEx]
  907. iNdEx++
  908. wire |= (uint64(b) & 0x7F) << shift
  909. if b < 0x80 {
  910. break
  911. }
  912. }
  913. fieldNum := int32(wire >> 3)
  914. wireType := int(wire & 0x7)
  915. if wireType == 4 {
  916. return fmt.Errorf("proto: Snapshot: wiretype end group for non-group")
  917. }
  918. if fieldNum <= 0 {
  919. return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire)
  920. }
  921. switch fieldNum {
  922. case 1:
  923. if wireType != 2 {
  924. return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
  925. }
  926. var byteLen int
  927. for shift := uint(0); ; shift += 7 {
  928. if shift >= 64 {
  929. return ErrIntOverflowRaft
  930. }
  931. if iNdEx >= l {
  932. return io.ErrUnexpectedEOF
  933. }
  934. b := data[iNdEx]
  935. iNdEx++
  936. byteLen |= (int(b) & 0x7F) << shift
  937. if b < 0x80 {
  938. break
  939. }
  940. }
  941. if byteLen < 0 {
  942. return ErrInvalidLengthRaft
  943. }
  944. postIndex := iNdEx + byteLen
  945. if postIndex > l {
  946. return io.ErrUnexpectedEOF
  947. }
  948. m.Data = append(m.Data[:0], data[iNdEx:postIndex]...)
  949. if m.Data == nil {
  950. m.Data = []byte{}
  951. }
  952. iNdEx = postIndex
  953. case 2:
  954. if wireType != 2 {
  955. return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
  956. }
  957. var msglen int
  958. for shift := uint(0); ; shift += 7 {
  959. if shift >= 64 {
  960. return ErrIntOverflowRaft
  961. }
  962. if iNdEx >= l {
  963. return io.ErrUnexpectedEOF
  964. }
  965. b := data[iNdEx]
  966. iNdEx++
  967. msglen |= (int(b) & 0x7F) << shift
  968. if b < 0x80 {
  969. break
  970. }
  971. }
  972. if msglen < 0 {
  973. return ErrInvalidLengthRaft
  974. }
  975. postIndex := iNdEx + msglen
  976. if postIndex > l {
  977. return io.ErrUnexpectedEOF
  978. }
  979. if err := m.Metadata.Unmarshal(data[iNdEx:postIndex]); err != nil {
  980. return err
  981. }
  982. iNdEx = postIndex
  983. default:
  984. iNdEx = preIndex
  985. skippy, err := skipRaft(data[iNdEx:])
  986. if err != nil {
  987. return err
  988. }
  989. if skippy < 0 {
  990. return ErrInvalidLengthRaft
  991. }
  992. if (iNdEx + skippy) > l {
  993. return io.ErrUnexpectedEOF
  994. }
  995. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  996. iNdEx += skippy
  997. }
  998. }
  999. if iNdEx > l {
  1000. return io.ErrUnexpectedEOF
  1001. }
  1002. return nil
  1003. }
  1004. func (m *Message) Unmarshal(data []byte) error {
  1005. l := len(data)
  1006. iNdEx := 0
  1007. for iNdEx < l {
  1008. preIndex := iNdEx
  1009. var wire uint64
  1010. for shift := uint(0); ; shift += 7 {
  1011. if shift >= 64 {
  1012. return ErrIntOverflowRaft
  1013. }
  1014. if iNdEx >= l {
  1015. return io.ErrUnexpectedEOF
  1016. }
  1017. b := data[iNdEx]
  1018. iNdEx++
  1019. wire |= (uint64(b) & 0x7F) << shift
  1020. if b < 0x80 {
  1021. break
  1022. }
  1023. }
  1024. fieldNum := int32(wire >> 3)
  1025. wireType := int(wire & 0x7)
  1026. if wireType == 4 {
  1027. return fmt.Errorf("proto: Message: wiretype end group for non-group")
  1028. }
  1029. if fieldNum <= 0 {
  1030. return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire)
  1031. }
  1032. switch fieldNum {
  1033. case 1:
  1034. if wireType != 0 {
  1035. return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
  1036. }
  1037. m.Type = 0
  1038. for shift := uint(0); ; shift += 7 {
  1039. if shift >= 64 {
  1040. return ErrIntOverflowRaft
  1041. }
  1042. if iNdEx >= l {
  1043. return io.ErrUnexpectedEOF
  1044. }
  1045. b := data[iNdEx]
  1046. iNdEx++
  1047. m.Type |= (MessageType(b) & 0x7F) << shift
  1048. if b < 0x80 {
  1049. break
  1050. }
  1051. }
  1052. case 2:
  1053. if wireType != 0 {
  1054. return fmt.Errorf("proto: wrong wireType = %d for field To", wireType)
  1055. }
  1056. m.To = 0
  1057. for shift := uint(0); ; shift += 7 {
  1058. if shift >= 64 {
  1059. return ErrIntOverflowRaft
  1060. }
  1061. if iNdEx >= l {
  1062. return io.ErrUnexpectedEOF
  1063. }
  1064. b := data[iNdEx]
  1065. iNdEx++
  1066. m.To |= (uint64(b) & 0x7F) << shift
  1067. if b < 0x80 {
  1068. break
  1069. }
  1070. }
  1071. case 3:
  1072. if wireType != 0 {
  1073. return fmt.Errorf("proto: wrong wireType = %d for field From", wireType)
  1074. }
  1075. m.From = 0
  1076. for shift := uint(0); ; shift += 7 {
  1077. if shift >= 64 {
  1078. return ErrIntOverflowRaft
  1079. }
  1080. if iNdEx >= l {
  1081. return io.ErrUnexpectedEOF
  1082. }
  1083. b := data[iNdEx]
  1084. iNdEx++
  1085. m.From |= (uint64(b) & 0x7F) << shift
  1086. if b < 0x80 {
  1087. break
  1088. }
  1089. }
  1090. case 4:
  1091. if wireType != 0 {
  1092. return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
  1093. }
  1094. m.Term = 0
  1095. for shift := uint(0); ; shift += 7 {
  1096. if shift >= 64 {
  1097. return ErrIntOverflowRaft
  1098. }
  1099. if iNdEx >= l {
  1100. return io.ErrUnexpectedEOF
  1101. }
  1102. b := data[iNdEx]
  1103. iNdEx++
  1104. m.Term |= (uint64(b) & 0x7F) << shift
  1105. if b < 0x80 {
  1106. break
  1107. }
  1108. }
  1109. case 5:
  1110. if wireType != 0 {
  1111. return fmt.Errorf("proto: wrong wireType = %d for field LogTerm", wireType)
  1112. }
  1113. m.LogTerm = 0
  1114. for shift := uint(0); ; shift += 7 {
  1115. if shift >= 64 {
  1116. return ErrIntOverflowRaft
  1117. }
  1118. if iNdEx >= l {
  1119. return io.ErrUnexpectedEOF
  1120. }
  1121. b := data[iNdEx]
  1122. iNdEx++
  1123. m.LogTerm |= (uint64(b) & 0x7F) << shift
  1124. if b < 0x80 {
  1125. break
  1126. }
  1127. }
  1128. case 6:
  1129. if wireType != 0 {
  1130. return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
  1131. }
  1132. m.Index = 0
  1133. for shift := uint(0); ; shift += 7 {
  1134. if shift >= 64 {
  1135. return ErrIntOverflowRaft
  1136. }
  1137. if iNdEx >= l {
  1138. return io.ErrUnexpectedEOF
  1139. }
  1140. b := data[iNdEx]
  1141. iNdEx++
  1142. m.Index |= (uint64(b) & 0x7F) << shift
  1143. if b < 0x80 {
  1144. break
  1145. }
  1146. }
  1147. case 7:
  1148. if wireType != 2 {
  1149. return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType)
  1150. }
  1151. var msglen int
  1152. for shift := uint(0); ; shift += 7 {
  1153. if shift >= 64 {
  1154. return ErrIntOverflowRaft
  1155. }
  1156. if iNdEx >= l {
  1157. return io.ErrUnexpectedEOF
  1158. }
  1159. b := data[iNdEx]
  1160. iNdEx++
  1161. msglen |= (int(b) & 0x7F) << shift
  1162. if b < 0x80 {
  1163. break
  1164. }
  1165. }
  1166. if msglen < 0 {
  1167. return ErrInvalidLengthRaft
  1168. }
  1169. postIndex := iNdEx + msglen
  1170. if postIndex > l {
  1171. return io.ErrUnexpectedEOF
  1172. }
  1173. m.Entries = append(m.Entries, Entry{})
  1174. if err := m.Entries[len(m.Entries)-1].Unmarshal(data[iNdEx:postIndex]); err != nil {
  1175. return err
  1176. }
  1177. iNdEx = postIndex
  1178. case 8:
  1179. if wireType != 0 {
  1180. return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
  1181. }
  1182. m.Commit = 0
  1183. for shift := uint(0); ; shift += 7 {
  1184. if shift >= 64 {
  1185. return ErrIntOverflowRaft
  1186. }
  1187. if iNdEx >= l {
  1188. return io.ErrUnexpectedEOF
  1189. }
  1190. b := data[iNdEx]
  1191. iNdEx++
  1192. m.Commit |= (uint64(b) & 0x7F) << shift
  1193. if b < 0x80 {
  1194. break
  1195. }
  1196. }
  1197. case 9:
  1198. if wireType != 2 {
  1199. return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", wireType)
  1200. }
  1201. var msglen int
  1202. for shift := uint(0); ; shift += 7 {
  1203. if shift >= 64 {
  1204. return ErrIntOverflowRaft
  1205. }
  1206. if iNdEx >= l {
  1207. return io.ErrUnexpectedEOF
  1208. }
  1209. b := data[iNdEx]
  1210. iNdEx++
  1211. msglen |= (int(b) & 0x7F) << shift
  1212. if b < 0x80 {
  1213. break
  1214. }
  1215. }
  1216. if msglen < 0 {
  1217. return ErrInvalidLengthRaft
  1218. }
  1219. postIndex := iNdEx + msglen
  1220. if postIndex > l {
  1221. return io.ErrUnexpectedEOF
  1222. }
  1223. if err := m.Snapshot.Unmarshal(data[iNdEx:postIndex]); err != nil {
  1224. return err
  1225. }
  1226. iNdEx = postIndex
  1227. case 10:
  1228. if wireType != 0 {
  1229. return fmt.Errorf("proto: wrong wireType = %d for field Reject", wireType)
  1230. }
  1231. var v int
  1232. for shift := uint(0); ; shift += 7 {
  1233. if shift >= 64 {
  1234. return ErrIntOverflowRaft
  1235. }
  1236. if iNdEx >= l {
  1237. return io.ErrUnexpectedEOF
  1238. }
  1239. b := data[iNdEx]
  1240. iNdEx++
  1241. v |= (int(b) & 0x7F) << shift
  1242. if b < 0x80 {
  1243. break
  1244. }
  1245. }
  1246. m.Reject = bool(v != 0)
  1247. case 11:
  1248. if wireType != 0 {
  1249. return fmt.Errorf("proto: wrong wireType = %d for field RejectHint", wireType)
  1250. }
  1251. m.RejectHint = 0
  1252. for shift := uint(0); ; shift += 7 {
  1253. if shift >= 64 {
  1254. return ErrIntOverflowRaft
  1255. }
  1256. if iNdEx >= l {
  1257. return io.ErrUnexpectedEOF
  1258. }
  1259. b := data[iNdEx]
  1260. iNdEx++
  1261. m.RejectHint |= (uint64(b) & 0x7F) << shift
  1262. if b < 0x80 {
  1263. break
  1264. }
  1265. }
  1266. default:
  1267. iNdEx = preIndex
  1268. skippy, err := skipRaft(data[iNdEx:])
  1269. if err != nil {
  1270. return err
  1271. }
  1272. if skippy < 0 {
  1273. return ErrInvalidLengthRaft
  1274. }
  1275. if (iNdEx + skippy) > l {
  1276. return io.ErrUnexpectedEOF
  1277. }
  1278. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  1279. iNdEx += skippy
  1280. }
  1281. }
  1282. if iNdEx > l {
  1283. return io.ErrUnexpectedEOF
  1284. }
  1285. return nil
  1286. }
  1287. func (m *HardState) Unmarshal(data []byte) error {
  1288. l := len(data)
  1289. iNdEx := 0
  1290. for iNdEx < l {
  1291. preIndex := iNdEx
  1292. var wire uint64
  1293. for shift := uint(0); ; shift += 7 {
  1294. if shift >= 64 {
  1295. return ErrIntOverflowRaft
  1296. }
  1297. if iNdEx >= l {
  1298. return io.ErrUnexpectedEOF
  1299. }
  1300. b := data[iNdEx]
  1301. iNdEx++
  1302. wire |= (uint64(b) & 0x7F) << shift
  1303. if b < 0x80 {
  1304. break
  1305. }
  1306. }
  1307. fieldNum := int32(wire >> 3)
  1308. wireType := int(wire & 0x7)
  1309. if wireType == 4 {
  1310. return fmt.Errorf("proto: HardState: wiretype end group for non-group")
  1311. }
  1312. if fieldNum <= 0 {
  1313. return fmt.Errorf("proto: HardState: illegal tag %d (wire type %d)", fieldNum, wire)
  1314. }
  1315. switch fieldNum {
  1316. case 1:
  1317. if wireType != 0 {
  1318. return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
  1319. }
  1320. m.Term = 0
  1321. for shift := uint(0); ; shift += 7 {
  1322. if shift >= 64 {
  1323. return ErrIntOverflowRaft
  1324. }
  1325. if iNdEx >= l {
  1326. return io.ErrUnexpectedEOF
  1327. }
  1328. b := data[iNdEx]
  1329. iNdEx++
  1330. m.Term |= (uint64(b) & 0x7F) << shift
  1331. if b < 0x80 {
  1332. break
  1333. }
  1334. }
  1335. case 2:
  1336. if wireType != 0 {
  1337. return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType)
  1338. }
  1339. m.Vote = 0
  1340. for shift := uint(0); ; shift += 7 {
  1341. if shift >= 64 {
  1342. return ErrIntOverflowRaft
  1343. }
  1344. if iNdEx >= l {
  1345. return io.ErrUnexpectedEOF
  1346. }
  1347. b := data[iNdEx]
  1348. iNdEx++
  1349. m.Vote |= (uint64(b) & 0x7F) << shift
  1350. if b < 0x80 {
  1351. break
  1352. }
  1353. }
  1354. case 3:
  1355. if wireType != 0 {
  1356. return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
  1357. }
  1358. m.Commit = 0
  1359. for shift := uint(0); ; shift += 7 {
  1360. if shift >= 64 {
  1361. return ErrIntOverflowRaft
  1362. }
  1363. if iNdEx >= l {
  1364. return io.ErrUnexpectedEOF
  1365. }
  1366. b := data[iNdEx]
  1367. iNdEx++
  1368. m.Commit |= (uint64(b) & 0x7F) << shift
  1369. if b < 0x80 {
  1370. break
  1371. }
  1372. }
  1373. default:
  1374. iNdEx = preIndex
  1375. skippy, err := skipRaft(data[iNdEx:])
  1376. if err != nil {
  1377. return err
  1378. }
  1379. if skippy < 0 {
  1380. return ErrInvalidLengthRaft
  1381. }
  1382. if (iNdEx + skippy) > l {
  1383. return io.ErrUnexpectedEOF
  1384. }
  1385. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  1386. iNdEx += skippy
  1387. }
  1388. }
  1389. if iNdEx > l {
  1390. return io.ErrUnexpectedEOF
  1391. }
  1392. return nil
  1393. }
  1394. func (m *ConfState) Unmarshal(data []byte) error {
  1395. l := len(data)
  1396. iNdEx := 0
  1397. for iNdEx < l {
  1398. preIndex := iNdEx
  1399. var wire uint64
  1400. for shift := uint(0); ; shift += 7 {
  1401. if shift >= 64 {
  1402. return ErrIntOverflowRaft
  1403. }
  1404. if iNdEx >= l {
  1405. return io.ErrUnexpectedEOF
  1406. }
  1407. b := data[iNdEx]
  1408. iNdEx++
  1409. wire |= (uint64(b) & 0x7F) << shift
  1410. if b < 0x80 {
  1411. break
  1412. }
  1413. }
  1414. fieldNum := int32(wire >> 3)
  1415. wireType := int(wire & 0x7)
  1416. if wireType == 4 {
  1417. return fmt.Errorf("proto: ConfState: wiretype end group for non-group")
  1418. }
  1419. if fieldNum <= 0 {
  1420. return fmt.Errorf("proto: ConfState: illegal tag %d (wire type %d)", fieldNum, wire)
  1421. }
  1422. switch fieldNum {
  1423. case 1:
  1424. if wireType != 0 {
  1425. return fmt.Errorf("proto: wrong wireType = %d for field Nodes", wireType)
  1426. }
  1427. var v uint64
  1428. for shift := uint(0); ; shift += 7 {
  1429. if shift >= 64 {
  1430. return ErrIntOverflowRaft
  1431. }
  1432. if iNdEx >= l {
  1433. return io.ErrUnexpectedEOF
  1434. }
  1435. b := data[iNdEx]
  1436. iNdEx++
  1437. v |= (uint64(b) & 0x7F) << shift
  1438. if b < 0x80 {
  1439. break
  1440. }
  1441. }
  1442. m.Nodes = append(m.Nodes, v)
  1443. default:
  1444. iNdEx = preIndex
  1445. skippy, err := skipRaft(data[iNdEx:])
  1446. if err != nil {
  1447. return err
  1448. }
  1449. if skippy < 0 {
  1450. return ErrInvalidLengthRaft
  1451. }
  1452. if (iNdEx + skippy) > l {
  1453. return io.ErrUnexpectedEOF
  1454. }
  1455. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  1456. iNdEx += skippy
  1457. }
  1458. }
  1459. if iNdEx > l {
  1460. return io.ErrUnexpectedEOF
  1461. }
  1462. return nil
  1463. }
  1464. func (m *ConfChange) Unmarshal(data []byte) error {
  1465. l := len(data)
  1466. iNdEx := 0
  1467. for iNdEx < l {
  1468. preIndex := iNdEx
  1469. var wire uint64
  1470. for shift := uint(0); ; shift += 7 {
  1471. if shift >= 64 {
  1472. return ErrIntOverflowRaft
  1473. }
  1474. if iNdEx >= l {
  1475. return io.ErrUnexpectedEOF
  1476. }
  1477. b := data[iNdEx]
  1478. iNdEx++
  1479. wire |= (uint64(b) & 0x7F) << shift
  1480. if b < 0x80 {
  1481. break
  1482. }
  1483. }
  1484. fieldNum := int32(wire >> 3)
  1485. wireType := int(wire & 0x7)
  1486. if wireType == 4 {
  1487. return fmt.Errorf("proto: ConfChange: wiretype end group for non-group")
  1488. }
  1489. if fieldNum <= 0 {
  1490. return fmt.Errorf("proto: ConfChange: illegal tag %d (wire type %d)", fieldNum, wire)
  1491. }
  1492. switch fieldNum {
  1493. case 1:
  1494. if wireType != 0 {
  1495. return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
  1496. }
  1497. m.ID = 0
  1498. for shift := uint(0); ; shift += 7 {
  1499. if shift >= 64 {
  1500. return ErrIntOverflowRaft
  1501. }
  1502. if iNdEx >= l {
  1503. return io.ErrUnexpectedEOF
  1504. }
  1505. b := data[iNdEx]
  1506. iNdEx++
  1507. m.ID |= (uint64(b) & 0x7F) << shift
  1508. if b < 0x80 {
  1509. break
  1510. }
  1511. }
  1512. case 2:
  1513. if wireType != 0 {
  1514. return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
  1515. }
  1516. m.Type = 0
  1517. for shift := uint(0); ; shift += 7 {
  1518. if shift >= 64 {
  1519. return ErrIntOverflowRaft
  1520. }
  1521. if iNdEx >= l {
  1522. return io.ErrUnexpectedEOF
  1523. }
  1524. b := data[iNdEx]
  1525. iNdEx++
  1526. m.Type |= (ConfChangeType(b) & 0x7F) << shift
  1527. if b < 0x80 {
  1528. break
  1529. }
  1530. }
  1531. case 3:
  1532. if wireType != 0 {
  1533. return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
  1534. }
  1535. m.NodeID = 0
  1536. for shift := uint(0); ; shift += 7 {
  1537. if shift >= 64 {
  1538. return ErrIntOverflowRaft
  1539. }
  1540. if iNdEx >= l {
  1541. return io.ErrUnexpectedEOF
  1542. }
  1543. b := data[iNdEx]
  1544. iNdEx++
  1545. m.NodeID |= (uint64(b) & 0x7F) << shift
  1546. if b < 0x80 {
  1547. break
  1548. }
  1549. }
  1550. case 4:
  1551. if wireType != 2 {
  1552. return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType)
  1553. }
  1554. var byteLen int
  1555. for shift := uint(0); ; shift += 7 {
  1556. if shift >= 64 {
  1557. return ErrIntOverflowRaft
  1558. }
  1559. if iNdEx >= l {
  1560. return io.ErrUnexpectedEOF
  1561. }
  1562. b := data[iNdEx]
  1563. iNdEx++
  1564. byteLen |= (int(b) & 0x7F) << shift
  1565. if b < 0x80 {
  1566. break
  1567. }
  1568. }
  1569. if byteLen < 0 {
  1570. return ErrInvalidLengthRaft
  1571. }
  1572. postIndex := iNdEx + byteLen
  1573. if postIndex > l {
  1574. return io.ErrUnexpectedEOF
  1575. }
  1576. m.Context = append(m.Context[:0], data[iNdEx:postIndex]...)
  1577. if m.Context == nil {
  1578. m.Context = []byte{}
  1579. }
  1580. iNdEx = postIndex
  1581. default:
  1582. iNdEx = preIndex
  1583. skippy, err := skipRaft(data[iNdEx:])
  1584. if err != nil {
  1585. return err
  1586. }
  1587. if skippy < 0 {
  1588. return ErrInvalidLengthRaft
  1589. }
  1590. if (iNdEx + skippy) > l {
  1591. return io.ErrUnexpectedEOF
  1592. }
  1593. m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
  1594. iNdEx += skippy
  1595. }
  1596. }
  1597. if iNdEx > l {
  1598. return io.ErrUnexpectedEOF
  1599. }
  1600. return nil
  1601. }
  1602. func skipRaft(data []byte) (n int, err error) {
  1603. l := len(data)
  1604. iNdEx := 0
  1605. for iNdEx < l {
  1606. var wire uint64
  1607. for shift := uint(0); ; shift += 7 {
  1608. if shift >= 64 {
  1609. return 0, ErrIntOverflowRaft
  1610. }
  1611. if iNdEx >= l {
  1612. return 0, io.ErrUnexpectedEOF
  1613. }
  1614. b := data[iNdEx]
  1615. iNdEx++
  1616. wire |= (uint64(b) & 0x7F) << shift
  1617. if b < 0x80 {
  1618. break
  1619. }
  1620. }
  1621. wireType := int(wire & 0x7)
  1622. switch wireType {
  1623. case 0:
  1624. for shift := uint(0); ; shift += 7 {
  1625. if shift >= 64 {
  1626. return 0, ErrIntOverflowRaft
  1627. }
  1628. if iNdEx >= l {
  1629. return 0, io.ErrUnexpectedEOF
  1630. }
  1631. iNdEx++
  1632. if data[iNdEx-1] < 0x80 {
  1633. break
  1634. }
  1635. }
  1636. return iNdEx, nil
  1637. case 1:
  1638. iNdEx += 8
  1639. return iNdEx, nil
  1640. case 2:
  1641. var length int
  1642. for shift := uint(0); ; shift += 7 {
  1643. if shift >= 64 {
  1644. return 0, ErrIntOverflowRaft
  1645. }
  1646. if iNdEx >= l {
  1647. return 0, io.ErrUnexpectedEOF
  1648. }
  1649. b := data[iNdEx]
  1650. iNdEx++
  1651. length |= (int(b) & 0x7F) << shift
  1652. if b < 0x80 {
  1653. break
  1654. }
  1655. }
  1656. iNdEx += length
  1657. if length < 0 {
  1658. return 0, ErrInvalidLengthRaft
  1659. }
  1660. return iNdEx, nil
  1661. case 3:
  1662. for {
  1663. var innerWire uint64
  1664. var start int = iNdEx
  1665. for shift := uint(0); ; shift += 7 {
  1666. if shift >= 64 {
  1667. return 0, ErrIntOverflowRaft
  1668. }
  1669. if iNdEx >= l {
  1670. return 0, io.ErrUnexpectedEOF
  1671. }
  1672. b := data[iNdEx]
  1673. iNdEx++
  1674. innerWire |= (uint64(b) & 0x7F) << shift
  1675. if b < 0x80 {
  1676. break
  1677. }
  1678. }
  1679. innerWireType := int(innerWire & 0x7)
  1680. if innerWireType == 4 {
  1681. break
  1682. }
  1683. next, err := skipRaft(data[start:])
  1684. if err != nil {
  1685. return 0, err
  1686. }
  1687. iNdEx = start + next
  1688. }
  1689. return iNdEx, nil
  1690. case 4:
  1691. return iNdEx, nil
  1692. case 5:
  1693. iNdEx += 4
  1694. return iNdEx, nil
  1695. default:
  1696. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  1697. }
  1698. }
  1699. panic("unreachable")
  1700. }
  1701. var (
  1702. ErrInvalidLengthRaft = fmt.Errorf("proto: negative length found during unmarshaling")
  1703. ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow")
  1704. )