• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vocdoni / vocdoni-node / 29729250699

14 Jul 2026 03:54PM UTC coverage: 62.889% (+0.2%) from 62.659%
29729250699

Pull #1422

github

web-flow
feat: batch transaction endpoint (POST /chain/transactions/batch) (#1420)

* feat(api): add POST /chain/transactions/batch

Submit multiple pre-signed transactions in one call, in order. Solves the
sequencing pain of creating several dependent processes: the account nonce and
the ProcessIndex-derived electionID only advance on commit, so today a client
must wait for A to commit before it can build B with the right nonce/id.

Behavior: ordered, fail-fast. The first transaction that fails to submit goes to
`failed` and submission stops; the remaining items go to `pending` (they share
the sender's now-broken nonce sequence and cannot commit). Successfully-broadcast
items go to `submitted`. Every input item is returned in exactly one group, and
each NewProcess item carries its predicted `processId` (computed server-side via
processid.BuildProcessID with a per-creator positional delta, matching what the
chain assigns in ordered commit).

`submitted` means mempool-accepted, NOT block-confirmed — documented so callers
confirm on-chain and retry. The grouping/fail-fast logic is factored into
classifyTransactionBatch (injectable submit/id funcs) and unit-tested.

* feat(apiclient): add SendTxBatch for the batch endpoint

Thin client for POST /chain/transactions/batch: submit several marshaled
SignedTx at once and get back the submitted/failed/pending grouping. Callers
build the transactions with contiguous nonces (and predicted processIds).

* api: address review comments on the batch tx endpoint

- Split the shared Transaction type out of the batch contract: request items use a
  dedicated TransactionPayload{payload} (documented, not swaggerignore) and response
  items use a dedicated TransactionBatchItem{hash,processId,code,error}. This fixes
  the OpenAPI request schema (payload was omitted) and tightens both contracts; the
  Error field is no longer bolted onto the shared Transaction type.
- Return a dedicated ErrTransactionBatchEmpty (4060) for an empty b... (continued)
Pull Request #1422: chore: promote main → release-lts-1

483 of 671 new or added lines in 8 files covered. (71.98%)

17 existing lines in 2 files now uncovered.

17260 of 27445 relevant lines covered (62.89%)

37336.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.74
/api/api_types.go
1
package api
2

3
import (
4
        "encoding/json"
5
        "time"
6

7
        comettypes "github.com/cometbft/cometbft/types"
8
        "github.com/google/uuid"
9
        "go.vocdoni.io/dvote/types"
10
        "go.vocdoni.io/dvote/vochain/indexer/indexertypes"
11
        "go.vocdoni.io/proto/build/go/models"
12
        "google.golang.org/protobuf/encoding/protojson"
13
)
14

15
// ### Params accepted ###
16

17
// PaginationParams allows the client to request a specific page, and how many items per page
18
type PaginationParams struct {
19
        Page  int `json:"page,omitempty"`
20
        Limit int `json:"limit,omitempty"`
21
}
22

23
// ElectionParams allows the client to filter elections
24
type ElectionParams struct {
25
        PaginationParams
26
        OrganizationID  string     `json:"organizationId,omitempty"`
27
        ElectionID      string     `json:"electionId,omitempty"`
28
        Status          string     `json:"status,omitempty"`
29
        WithResults     *bool      `json:"withResults,omitempty"`
30
        FinalResults    *bool      `json:"finalResults,omitempty"`
31
        ManuallyEnded   *bool      `json:"manuallyEnded,omitempty"`
32
        StartDateAfter  *time.Time `json:"startDateAfter,omitempty"`
33
        StartDateBefore *time.Time `json:"startDateBefore,omitempty"`
34
        EndDateAfter    *time.Time `json:"endDateAfter,omitempty"`
35
        EndDateBefore   *time.Time `json:"endDateBefore,omitempty"`
36
}
37

38
// OrganizationParams allows the client to filter organizations
39
type OrganizationParams struct {
40
        PaginationParams
41
        OrganizationID string `json:"organizationId,omitempty"`
42
}
43

44
// AccountParams allows the client to filter accounts
45
type AccountParams struct {
46
        PaginationParams
47
        AccountID string `json:"accountId,omitempty"`
48
}
49

50
// TransactionParams allows the client to filter transactions
51
type TransactionParams struct {
52
        PaginationParams
53
        Hash    string `json:"hash,omitempty"`
54
        Height  uint64 `json:"height,omitempty"`
55
        Type    string `json:"type,omitempty"`
56
        Subtype string `json:"subtype,omitempty"`
57
        Signer  string `json:"signer,omitempty"`
58
}
59

60
// BlockParams allows the client to filter blocks
61
type BlockParams struct {
62
        PaginationParams
63
        ChainID         string `json:"chainId,omitempty"`
64
        Hash            string `json:"hash,omitempty"`
65
        ProposerAddress string `json:"proposerAddress,omitempty"`
66
}
67

68
// FeesParams allows the client to filter fees
69
type FeesParams struct {
70
        PaginationParams
71
        Reference string `json:"reference,omitempty"`
72
        Type      string `json:"type,omitempty"`
73
        AccountID string `json:"accountId,omitempty"`
74
}
75

76
// TransfersParams allows the client to filter transfers
77
type TransfersParams struct {
78
        PaginationParams
79
        AccountID     string `json:"accountId,omitempty"`
80
        AccountIDFrom string `json:"accountIdFrom,omitempty"`
81
        AccountIDTo   string `json:"accountIdTo,omitempty"`
82
}
83

84
// VoteParams allows the client to filter votes
85
type VoteParams struct {
86
        PaginationParams
87
        ElectionID string `json:"electionId,omitempty"`
88
}
89

90
// ### Objects returned ###
91

92
// CountResult wraps a count inside an object
93
type CountResult struct {
94
        Count uint64 `json:"count" example:"10"`
95
}
96

97
// Pagination contains all the values needed for the UI to easily organize the returned data
98
type Pagination struct {
99
        TotalItems   uint64  `json:"totalItems"`
100
        PreviousPage *uint64 `json:"previousPage"`
101
        CurrentPage  uint64  `json:"currentPage"`
102
        NextPage     *uint64 `json:"nextPage"`
103
        LastPage     uint64  `json:"lastPage"`
104
}
105

106
type OrganizationSummary struct {
107
        OrganizationID types.HexBytes `json:"organizationID"  example:"0x370372b92514d81a0e3efb8eba9d036ae0877653"`
108
        ElectionCount  uint64         `json:"electionCount" example:"1"`
109
}
110

111
// OrganizationsList is used to return a paginated list to the client
112
type OrganizationsList struct {
113
        Organizations []*OrganizationSummary `json:"organizations"`
114
        Pagination    *Pagination            `json:"pagination"`
115
}
116

117
type ElectionSummary struct {
118
        ElectionID     types.HexBytes    `json:"electionId" `
119
        OrganizationID types.HexBytes    `json:"organizationId" `
120
        Status         string            `json:"status"`
121
        StartDate      time.Time         `json:"startDate"`
122
        EndDate        time.Time         `json:"endDate"`
123
        VoteCount      uint64            `json:"voteCount"`
124
        FinalResults   bool              `json:"finalResults"`
125
        Results        [][]*types.BigInt `json:"result,omitempty"`
126
        ManuallyEnded  bool              `json:"manuallyEnded"`
127
        ChainID        string            `json:"chainId"`
128
}
129

130
// ElectionsList is used to return a paginated list to the client
131
type ElectionsList struct {
132
        Elections  []*ElectionSummary `json:"elections"`
133
        Pagination *Pagination        `json:"pagination"`
134
}
135

136
// ElectionResults is the struct used to wrap the results of an election
137
type ElectionResults struct {
138
        // ABIEncoded is the abi encoded election results
139
        ABIEncoded string `json:"abiEncoded" swaggerignore:"true"`
140
        // CensusRoot is the root of the census tree
141
        CensusRoot types.HexBytes `json:"censusRoot" `
142
        // ElectionID is the ID of the election
143
        ElectionID types.HexBytes `json:"electionId" `
144
        // OrganizationID is the ID of the organization that created the election
145
        OrganizationID types.HexBytes `json:"organizationId" `
146
        // Results is the list of votes
147
        Results [][]*types.BigInt `json:"results"`
148
        // SourceContractAddress is the address of the smart contract containing the census
149
        SourceContractAddress types.HexBytes `json:"sourceContractAddress,omitempty" `
150
}
151

152
type Election struct {
153
        ElectionSummary
154
        Census       *ElectionCensus `json:"census,omitempty"`
155
        MetadataURL  string          `json:"metadataURL"`
156
        CreationTime time.Time       `json:"creationTime"`
157
        VoteMode     VoteMode        `json:"voteMode,omitempty"`
158
        ElectionMode ElectionMode    `json:"electionMode,omitempty"`
159
        TallyMode    TallyMode       `json:"tallyMode,omitempty"`
160
        Metadata     any             `json:"metadata,omitempty"`
161
}
162

163
type ElectionKeys struct {
164
        PublicKeys  []Key `json:"publicKeys,omitempty" swaggertype:"string"`
165
        PrivateKeys []Key `json:"privateKeys,omitempty" swaggertype:"string"`
166
}
167

168
type ElectionCensus struct {
169
        CensusOrigin           string         `json:"censusOrigin"`
170
        CensusRoot             types.HexBytes `json:"censusRoot" `
171
        PostRegisterCensusRoot types.HexBytes `json:"postRegisterCensusRoot" `
172
        CensusURL              string         `json:"censusURL"`
173
        MaxCensusSize          uint64         `json:"maxCensusSize"`
174
}
175

176
type ElectionCreate struct {
177
        TxPayload                 []byte         `json:"txPayload,omitempty"`
178
        Metadata                  []byte         `json:"metadata,omitempty"`
179
        TxHash                    types.HexBytes `json:"txHash" `
180
        ElectionID                types.HexBytes `json:"electionID" `
181
        MetadataURL               string         `json:"metadataURL"`
182
        MetadataEncryptionPrivKey types.HexBytes `json:"metadataEncryptionPrivKey,omitempty"`
183
}
184

185
type ElectionDescription struct {
186
        Title        LanguageString        `json:"title"`
187
        Description  LanguageString        `json:"description"`
188
        Header       string                `json:"header"`
189
        StreamURI    string                `json:"streamUri"`
190
        StartDate    time.Time             `json:"startDate,omitempty"`
191
        EndDate      time.Time             `json:"endDate"`
192
        VoteType     VoteType              `json:"voteType"`
193
        ElectionType ElectionType          `json:"electionType"`
194
        Questions    []Question            `json:"questions"`
195
        Census       CensusTypeDescription `json:"census"`
196
        TempSIKs     bool                  `json:"tempSIKs"`
197
}
198

199
type Key struct {
200
        Index int            `json:"index"`
201
        Key   types.HexBytes `json:"key" `
202
}
203

204
type Vote struct {
205
        TxPayload []byte         `json:"txPayload,omitempty"  extensions:"x-omitempty" swaggerignore:"true"`
206
        TxHash    types.HexBytes `json:"txHash,omitempty"  extensions:"x-omitempty" `
207
        // VoteID here produces a `voteID` over JSON that differs in casing from the rest of params and JSONs
208
        // but is kept for backwards compatibility
209
        VoteID types.HexBytes `json:"voteID,omitempty"  extensions:"x-omitempty" `
210
        // Sent only for encrypted elections (no results until the end)
211
        EncryptionKeyIndexes []uint32 `json:"encryptionKeys,omitempty" extensions:"x-omitempty"`
212
        // For encrypted elections this will be codified
213
        VotePackage      json.RawMessage `json:"package,omitempty" extensions:"x-omitempty"`
214
        VoteWeight       string          `json:"weight,omitempty" extensions:"x-omitempty"` // [math/big.Int.String]
215
        VoteNumber       *uint32         `json:"number,omitempty" extensions:"x-omitempty"`
216
        ElectionID       types.HexBytes  `json:"electionID,omitempty" extensions:"x-omitempty" `
217
        VoterID          types.HexBytes  `json:"voterID,omitempty" extensions:"x-omitempty" `
218
        BlockHeight      uint32          `json:"blockHeight,omitempty" extensions:"x-omitempty"`
219
        TransactionIndex *int32          `json:"transactionIndex,omitempty" extensions:"x-omitempty"`
220
        OverwriteCount   *uint32         `json:"overwriteCount,omitempty" extensions:"x-omitempty"`
221
        // Date when the vote was emitted
222
        Date *time.Time `json:"date,omitempty" extensions:"x-omitempty"`
223
}
224

225
type VotesList struct {
226
        Votes      []*Vote     `json:"votes"`
227
        Pagination *Pagination `json:"pagination"`
228
}
229

230
type CensusTypeDescription struct {
231
        Type      string         `json:"type"`
232
        Size      uint64         `json:"size"`
233
        URL       string         `json:"url,omitempty"`
234
        PublicKey types.HexBytes `json:"publicKey,omitempty" `
235
        RootHash  types.HexBytes `json:"rootHash,omitempty" `
236
}
237

238
type CensusParticipants struct {
239
        Participants []CensusParticipant `json:"participants"`
240
}
241

242
type CensusParticipant struct {
243
        Key    types.HexBytes `json:"key" `
244
        Weight *types.BigInt  `json:"weight"`
245
}
246

247
type VoteType struct {
248
        UniqueChoices     bool `json:"uniqueChoices"`
249
        MaxVoteOverwrites int  `json:"maxVoteOverwrites"`
250
        CostFromWeight    bool `json:"costFromWeight"`
251
        CostExponent      int  `json:"costExponent"`
252
        MaxCount          int  `json:"maxCount"`
253
        MaxValue          int  `json:"maxValue"`
254
}
255

256
type ElectionType struct {
257
        Autostart         bool `json:"autostart"`
258
        Interruptible     bool `json:"interruptible"`
259
        DynamicCensus     bool `json:"dynamicCensus"`
260
        SecretUntilTheEnd bool `json:"secretUntilTheEnd"`
261
        Anonymous         bool `json:"anonymous"`
262
}
263

264
type Transaction struct {
265
        Payload   []byte            `json:"payload,omitempty" extensions:"x-omitempty" swaggerignore:"true"`
266
        Hash      types.HexBytes    `json:"hash,omitempty" extensions:"x-omitempty" `
267
        Response  []byte            `json:"response,omitempty" extensions:"x-omitempty" swaggertype:"string" format:"base64"`
268
        Code      *uint32           `json:"code,omitempty" extensions:"x-omitempty"`
269
        Costs     map[string]uint64 `json:"costs,omitempty" extensions:"x-omitempty" swaggerignore:"true"`
270
        Address   types.HexBytes    `json:"address,omitempty" extensions:"x-omitempty" swaggerignore:"true" `
271
        ProcessID types.HexBytes    `json:"processId,omitempty" extensions:"x-omitempty" `
272
}
273

274
// TransactionPayload is one pre-signed transaction (base64-encoded models.SignedTx)
275
// in a batch request.
276
type TransactionPayload struct {
277
        Payload []byte `json:"payload" swaggertype:"string" format:"base64"`
278
        // Metadata is the optional raw election metadata for a NewProcess payload. When
279
        // provided, its CID must match the metadata URI in the transaction, and it is
280
        // pinned to IPFS on submission (same as POST /elections).
281
        Metadata []byte `json:"metadata,omitempty" swaggertype:"string" format:"base64"`
282
}
283

284
// TransactionBatch is a request to submit multiple transactions at once, in order.
285
type TransactionBatch struct {
286
        Transactions []TransactionPayload `json:"transactions"`
287
}
288

289
// TransactionBatchItem is the outcome of a single transaction in a batch. For a
290
// NewProcess transaction, ProcessID is the predicted election id. Error is set
291
// only on the item that failed to be submitted.
292
type TransactionBatchItem struct {
293
        Hash      types.HexBytes `json:"hash,omitempty" extensions:"x-omitempty"`
294
        ProcessID types.HexBytes `json:"processId,omitempty" extensions:"x-omitempty"`
295
        // Code is the mempool CheckTx response code. For submitted items it is always
296
        // 0: a non-zero CheckTx code is turned into a submit error, so the item lands
297
        // in Failed instead. The field is kept for parity with the single-tx endpoint.
298
        Code        *uint32 `json:"code,omitempty" extensions:"x-omitempty"`
299
        Error       string  `json:"error,omitempty" extensions:"x-omitempty"`
300
        MetadataURL string  `json:"metadataURL,omitempty" extensions:"x-omitempty"`
301
}
302

303
// TransactionBatchResult groups every input transaction of a batch by its
304
// submission outcome. Note: "submitted" means the mempool accepted the broadcast,
305
// NOT that the transaction is block-confirmed — a mempool-accepted transaction can
306
// still be discarded at commit (e.g. a stale/contended nonce, which is not checked
307
// at mempool admission). The caller must confirm each submitted item on-chain and
308
// resubmit any that did not land, together with the failed and pending items.
309
type TransactionBatchResult struct {
310
        // Submitted are the transactions accepted by the mempool, in order.
311
        Submitted []TransactionBatchItem `json:"submitted"`
312
        // Failed holds the first transaction that failed to be submitted (Error set);
313
        // submission stops there.
314
        Failed []TransactionBatchItem `json:"failed"`
315
        // Pending are the transactions after the failed one that were not sent.
316
        Pending []TransactionBatchItem `json:"pending"`
317
}
318

319
type TransactionReference struct {
320
        Height uint32 `json:"blockHeight"`
321
        Index  uint32 `json:"transactionIndex"`
322
}
323

324
// TransactionsList is used to return a paginated list to the client
325
type TransactionsList struct {
326
        Transactions []*indexertypes.TransactionMetadata `json:"transactions"`
327
        Pagination   *Pagination                         `json:"pagination"`
328
}
329

330
// FeesList is used to return a paginated list to the client
331
type FeesList struct {
332
        Fees       []*indexertypes.TokenFeeMeta `json:"fees"`
333
        Pagination *Pagination                  `json:"pagination"`
334
}
335

336
// TransfersList is used to return a paginated list to the client
337
type TransfersList struct {
338
        Transfers  []*indexertypes.TokenTransferMeta `json:"transfers"`
339
        Pagination *Pagination                       `json:"pagination"`
340
}
341

342
type GenericTransactionWithInfo struct {
343
        TxContent json.RawMessage           `json:"tx"`
344
        TxInfo    *indexertypes.Transaction `json:"txInfo"`
345
        Signature types.HexBytes            `json:"signature"`
346
}
347

348
type ChainInfo struct {
349
        ID                string    `json:"chainId" example:"azeno"`
350
        BlockTime         [5]uint64 `json:"blockTime" example:"12000,11580,11000,11100,11100"`
351
        ElectionCount     uint64    `json:"electionCount" example:"120"`
352
        OrganizationCount uint64    `json:"organizationCount" example:"20"`
353
        GenesisTime       time.Time `json:"genesisTime"  format:"date-time" example:"2022-11-17T18:00:57.379551614Z"`
354
        InitialHeight     uint32    `json:"initialHeight"  example:"5467"`
355
        Height            uint32    `json:"height" example:"5467"`
356
        BlockStoreBase    uint32    `json:"blockStoreBase" example:"5467"`
357
        Syncing           bool      `json:"syncing" example:"true"`
358
        Timestamp         int64     `json:"blockTimestamp" swaggertype:"string" format:"date-time" example:"2022-11-17T18:00:57.379551614Z"`
359
        TransactionCount  uint64    `json:"transactionCount" example:"554"`
360
        ValidatorCount    uint32    `json:"validatorCount" example:"5"`
361
        VoteCount         uint64    `json:"voteCount" example:"432"`
362
        CircuitVersion    string    `json:"circuitVersion" example:"v1.0.0"`
363
        MaxCensusSize     uint64    `json:"maxCensusSize" example:"50000"`
364
        NetworkCapacity   uint64    `json:"networkCapacity" example:"2000"`
365
}
366

367
type Account struct {
368
        Address        types.HexBytes   `json:"address" `
369
        Nonce          uint32           `json:"nonce"`
370
        Balance        uint64           `json:"balance"`
371
        ElectionIndex  uint32           `json:"electionIndex"`
372
        TransfersCount uint64           `json:"transfersCount,omitempty"`
373
        FeesCount      uint64           `json:"feesCount,omitempty"`
374
        InfoURL        string           `json:"infoURL,omitempty"`
375
        Token          *uuid.UUID       `json:"token,omitempty" swaggerignore:"true"`
376
        Metadata       *AccountMetadata `json:"metadata,omitempty"`
377
        SIK            types.HexBytes   `json:"sik"`
378
}
379

380
type AccountsList struct {
381
        Accounts   []*indexertypes.Account `json:"accounts"`
382
        Pagination *Pagination             `json:"pagination"`
383
}
384

385
type AccountSet struct {
386
        TxPayload   []byte         `json:"txPayload,omitempty" swaggerignore:"true"`
387
        Metadata    []byte         `json:"metadata,omitempty" swaggerignore:"true"`
388
        TxHash      types.HexBytes `json:"txHash" `
389
        MetadataURL string         `json:"metadataURL" swaggertype:"string"`
390
}
391

392
type Census struct {
393
        // CensusID here produces a `censusID` over JSON that differs in casing from the rest of params and JSONs
394
        // but is kept for backwards compatibility
395
        CensusID types.HexBytes `json:"censusID,omitempty"`
396
        Type     string         `json:"type,omitempty"`
397
        Weight   *types.BigInt  `json:"weight,omitempty"`
398
        Size     uint64         `json:"size,omitempty"`
399
        Valid    bool           `json:"valid,omitempty"`
400
        URI      string         `json:"uri,omitempty"`
401
        // proof stuff
402
        CensusRoot     types.HexBytes `json:"censusRoot,omitempty"`
403
        CensusProof    types.HexBytes `json:"censusProof,omitempty"`
404
        Key            types.HexBytes `json:"key,omitempty"`
405
        Value          types.HexBytes `json:"value,omitempty"`
406
        CensusSiblings []string       `json:"censusSiblings,omitempty"`
407
}
408

409
type File struct {
410
        Payload []byte `json:"payload,omitempty" swaggerignore:"true"`
411
        CID     string `json:"cid,omitempty"`
412
}
413

414
type ValidatorList struct {
415
        Validators []Validator `json:"validators"`
416
}
417

418
type Validator struct {
419
        Power            uint64         `json:"power"`
420
        PubKey           types.HexBytes `json:"pubKey"`
421
        AccountAddress   types.HexBytes `json:"address"`
422
        Name             string         `json:"name"`
423
        ValidatorAddress types.HexBytes `json:"validatorAddress"`
424
        JoinHeight       uint64         `json:"joinHeight"`
425
        Votes            uint64         `json:"votes"`
426
        Proposals        uint64         `json:"proposals"`
427
        Score            uint32         `json:"score"`
428
}
429

430
type BuildElectionID struct {
431
        Delta          int32          `json:"delta"` // 0 means build next ElectionID
432
        OrganizationID types.HexBytes `json:"organizationId"`
433
        CensusOrigin   int32          `json:"censusOrigin"`
434
        EnvelopeType   struct {
435
                Serial         bool `json:"serial"`
436
                Anonymous      bool `json:"anonymous"`
437
                EncryptedVotes bool `json:"encryptedVotes"`
438
                UniqueValues   bool `json:"uniqueValues"`
439
                CostFromWeight bool `json:"costFromWeight"`
440
        } `json:"envelopeType"`
441
}
442

443
// Protobuf wrappers
444

445
type VoteMode struct {
446
        *models.EnvelopeType
447
}
448

449
func (v VoteMode) MarshalJSON() ([]byte, error) {
61✔
450
        m := protojson.MarshalOptions{EmitUnpopulated: true, UseEnumNumbers: false}
61✔
451
        return m.Marshal(&v)
61✔
452
}
61✔
453

454
type ElectionMode struct {
455
        *models.ProcessMode
456
}
457

458
func (e ElectionMode) MarshalJSON() ([]byte, error) {
61✔
459
        m := protojson.MarshalOptions{EmitUnpopulated: true, UseEnumNumbers: false}
61✔
460
        return m.Marshal(&e)
61✔
461
}
61✔
462

463
type TallyMode struct {
464
        *models.ProcessVoteOptions
465
}
466

467
func (t TallyMode) MarshalJSON() ([]byte, error) {
48✔
468
        m := protojson.MarshalOptions{EmitUnpopulated: true, UseEnumNumbers: false}
48✔
469
        return m.Marshal(&t)
48✔
470
}
48✔
471

472
func CensusTypeToOrigin(ctype CensusTypeDescription) (models.CensusOrigin, []byte, error) {
14✔
473
        var origin models.CensusOrigin
14✔
474
        var root []byte
14✔
475
        switch ctype.Type {
14✔
476
        case CensusTypeCSP:
×
477
                origin = models.CensusOrigin_OFF_CHAIN_CA
×
478
                root = ctype.PublicKey
×
479
        case CensusTypeWeighted, CensusTypeZKWeighted:
14✔
480
                origin = models.CensusOrigin_OFF_CHAIN_TREE_WEIGHTED
14✔
481
                root = ctype.RootHash
14✔
482
        case CensusTypeFarcaster:
×
483
                origin = models.CensusOrigin_FARCASTER_FRAME
×
484
                root = ctype.RootHash
×
485
        default:
×
NEW
486
                return 0, nil, ErrCensusTypeUnknown.Withf("%v", ctype)
×
487
        }
488
        if root == nil {
14✔
489
                return 0, nil, ErrCensusRootIsNil
×
490
        }
×
491
        return origin, root, nil
14✔
492
}
493

494
type Block struct {
495
        comettypes.Header `json:"header"`
496
        Hash              types.HexBytes `json:"hash" `
497
        TxCount           int64          `json:"txCount"`
498
}
499

500
// BlockList is used to return a paginated list to the client
501
type BlockList struct {
502
        Blocks     []*indexertypes.Block `json:"blocks"`
503
        Pagination *Pagination           `json:"pagination"`
504
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc