census

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GraphQLImporter

func GraphQLImporter(config *GraphQLImporterConfig) *graphqlImporter

GraphQLImporter returns an instance of graphqlImporter with the provided configuration. If config is nil, it uses the default configuration.

func IsCSPCensusOrigin

func IsCSPCensusOrigin(api frontend.API, origin frontend.Variable) frontend.Variable

IsCSPCensusOrigin returns a frontend.Variable that is 1 if the provided origin corresponds to a CSP census origin, 0 otherwise. The supported CSP census origin is:

  • CensusOriginCSPEdDSABN254V1

func IsMerkleTreeCensusOrigin

func IsMerkleTreeCensusOrigin(api frontend.API, origin frontend.Variable) frontend.Variable

IsMerkleTreeCensusOrigin returns a frontend.Variable that is 1 if the provided origin corresponds to a Merkle Tree census origin, 0 otherwise. The supported Merkle Tree census origins are:

  • CensusOriginMerkleTreeOffchainStaticV1
  • CensusOriginMerkleTreeOffchainDynamicV1
  • CensusOriginMerkleTreeOnchainV1

func IsValidCensusOrigin added in v0.0.4

func IsValidCensusOrigin(api frontend.API, origin frontend.Variable) frontend.Variable

IsValidCensusOrigin returns a frontend.Variable that is 1 if the provided origin corresponds to any supported census origin, 0 otherwise.

func JSONImporter

func JSONImporter() *jsonImporter

JSONImporter method returns an instance of jsonImporter.

Types

type CensusImporter

type CensusImporter struct {
	// contains filtered or unexported fields
}

CensusImporter is responsible for importing censuses from various origins.

func NewCensusImporter

func NewCensusImporter(stg *storage.Storage, plugins ...ImporterPlugin) *CensusImporter

NewCensusImporter creates a new CensusImporter with the given storage and optional plugins. If no plugins are provided, the importer will not be able to import any censuses. The caller is responsible for providing the desired plugins in the correct order of precedence.

func (*CensusImporter) ImportCensus

func (d *CensusImporter) ImportCensus(ctx context.Context, census *types.Census, processedElements int) (int, error)

ImportCensus downloads and imports the census from the given URI. It checks the census origin to ensure that it is supported. Merkle Tree censuses are downloaded and imported using the appropriate plugin based on the URI. CSP censuses do not require downloading, as the census data is managed by the CSP itself. Other census origins are not supported. It returns an error if the download or import fails.

type GraphQLImporterConfig

type GraphQLImporterConfig struct {
	PageSize     int
	QueryTimeout time.Duration
	Insecure     bool
}

GraphQLImporterConfig holds configuration options for the GraphQL importer.

type ImporterPlugin

type ImporterPlugin interface {
	ValidURI(targetURI string) bool
	ImportCensus(ctx context.Context, db *censusdb.CensusDB, census *types.Census, from int) (int, error)
}

ImporterPlugin defines the interface for census import plugins. Each plugin must implement the following methods:

  • ValidURI: checks if the provided targetURI is valid for this plugin.
  • DownloadAndImportCensus: downloads and imports the census from the specified targetURI into the provided censusDB, verifying against the expectedRoot.

type JSONFormat

type JSONFormat int

JSONFormat represents the format of the JSON census dump.

const (
	// JSONL represents the JSON Lines format (newline-delimited JSON). It is
	// used for large JSON dumps where each line is a separate JSON object and
	// it can be streamed.
	JSONL JSONFormat = iota
	// JSONArray represents the JSON Array format. It is used for smaller JSON
	// dumps where the entire dump is contained within a single JSON array.
	JSONArray
	// UnknownJSON represents an unknown JSON format.
	UnknownJSON
)

func (JSONFormat) String

func (format JSONFormat) String() string

String returns the string representation of the JSONFormat.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL