Documentation
¶
Index ¶
- func GraphQLImporter(config *GraphQLImporterConfig) *graphqlImporter
- func IsCSPCensusOrigin(api frontend.API, origin frontend.Variable) frontend.Variable
- func IsMerkleTreeCensusOrigin(api frontend.API, origin frontend.Variable) frontend.Variable
- func IsValidCensusOrigin(api frontend.API, origin frontend.Variable) frontend.Variable
- func JSONImporter() *jsonImporter
- type CensusImporter
- type GraphQLImporterConfig
- type ImporterPlugin
- type JSONFormat
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 ¶
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 ¶
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
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 ¶
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.