Documentation ¶
Overview ¶
Package chain provides the functions to interact with the Ethereum-like control blockchain
Index ¶
- Variables
- func EnsResolve(ctx context.Context, ensRegistryAddr, ethDomain, w3uri string) (contractAddr string, err error)
- func NameHash(name string) (hash [32]byte, err error)
- func NameHashPart(currentHash [32]byte, name string) (hash [32]byte, err error)
- func Normalize(input string) (output string, err error)
- func ResolveEntityMetadataURL(ctx context.Context, ensRegistryAddr, entityID, ethEndpoint string) (string, error)
- func VotingProcessAddress(ctx context.Context, publicRegistryAddr, domain, ethEndpoint string) (string, error)
- type ENSCallerHandler
- type EthChainConfig
- type EthChainContext
- func (e *EthChainContext) CollectMetrics(ctx context.Context, ma *metrics.Agent)
- func (e *EthChainContext) PrintInfo(ctx context.Context, seconds time.Duration)
- func (e *EthChainContext) Start()
- func (e *EthChainContext) SyncGuard(ctx context.Context)
- func (e *EthChainContext) SyncInfo(ctx context.Context) (info EthSyncInfo, err error)
- type EthSyncInfo
- type ProcessHandle
- func (ph *ProcessHandle) CancelProcessTxArgs(ctx context.Context, pid [32]byte) (*types.CancelProcessTx, error)
- func (ph *ProcessHandle) Genesis(ctx context.Context) (string, error)
- func (ph *ProcessHandle) Oracles(ctx context.Context) ([]string, error)
- func (ph *ProcessHandle) ProcessIndex(ctx context.Context, pid [32]byte) (*big.Int, error)
- func (ph *ProcessHandle) ProcessTxArgs(ctx context.Context, pid [32]byte) (*types.NewProcessTx, error)
- func (ph *ProcessHandle) Validators(ctx context.Context) ([]string, error)
- type Specs
Constants ¶
This section is empty.
Variables ¶
var ( EthereumSynced = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: "ethereum", Name: "synced", Help: "Boolean, 1 if chain is synced", }) EthereumHeight = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: "ethereum", Name: "height", Help: "Current height of the ethereum chain", }) EthereumMaxHeight = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: "ethereum", Name: "max_height", Help: "Height of the ethereum chain (last block)", }) EthereumPeers = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: "ethereum", Name: "peers", Help: "Number of ethereum peers connected", }) )
Ethereum collectors
var AvailableChains = []string{"mainnet", "goerli", "xdai", "xdaistage", "sokol"}
Functions ¶
func EnsResolve ¶ added in v0.6.0
func EnsResolve(ctx context.Context, ensRegistryAddr, ethDomain, w3uri string) (contractAddr string, err error)
EnsResolve resolves the voting process contract address through the stardard ENS
func NameHash ¶ added in v0.6.3
nameHash generates a hash from a name that can be used to look up the name in ENS
func NameHashPart ¶ added in v0.6.3
Types ¶
type ENSCallerHandler ¶ added in v0.3.0
type ENSCallerHandler struct { // Registry public registry contract instance Registry *contracts.EnsRegistryWithFallbackCaller // Resolver resolver contract instance Resolver *contracts.EntityResolverCaller // EthereumClient is the client interacting with the ethereum node EthereumClient *ethclient.Client // PublicRegistryAddr public registry contract address PublicRegistryAddr string // ResolverAddr address resolved by calling Resolve() on Registry contract ResolverAddr string }
ENSCallerHandler contains the contracts and their addresses and an eth client
func (*ENSCallerHandler) NewENSRegistryWithFallbackHandle ¶ added in v0.3.0
func (e *ENSCallerHandler) NewENSRegistryWithFallbackHandle() (err error)
NewENSRegistryWithFallbackHandle connects to a web3 endpoint and creates an ENS public registry read only contact instance
func (*ENSCallerHandler) NewEntityResolverHandle ¶ added in v0.3.0
func (e *ENSCallerHandler) NewEntityResolverHandle() (err error)
NewEntityResolverHandle connects to a web3 endpoint and creates an EntityResolver read only contact instance
func (*ENSCallerHandler) Resolve ¶ added in v0.3.0
func (e *ENSCallerHandler) Resolve(ctx context.Context, nameHash [32]byte, resolvePublicRegistry bool) (string, error)
Resolve if resolvePublicRegistry is set to true it will resolve the given namehash on the public registry. If false it will resolve the given namehash on a standard resolver
type EthChainConfig ¶
type EthChainContext ¶
type EthChainContext struct { Node *node.Node API *eth.EthAPIBackend // Ethereum backend API (if fastmode enabled) LAPI *les.LesApiBackend // Ethereum Light API (if lightmode enabled) Config *eth.Config Keys *keystore.KeyStore DefaultConfig *EthChainConfig ProcessHandle *ProcessHandle MetricsAgent *metrics.Agent RestartLock sync.RWMutex }
func Init ¶
func Init(c *EthChainConfig) (*EthChainContext, error)
func (*EthChainContext) CollectMetrics ¶ added in v0.3.0
func (e *EthChainContext) CollectMetrics(ctx context.Context, ma *metrics.Agent)
CollectMetrics constantly updates the metric values for prometheus The function is blocking, should be called in a go routine If the metrics Agent is nil, do nothing
func (*EthChainContext) PrintInfo ¶
func (e *EthChainContext) PrintInfo(ctx context.Context, seconds time.Duration)
PrintInfo prints every N seconds some ethereum information (sync and height). It's blocking!
func (*EthChainContext) Start ¶
func (e *EthChainContext) Start()
Start starts an Ethereum blockchain connection and web3 APIs
func (*EthChainContext) SyncGuard ¶ added in v0.4.0
func (e *EthChainContext) SyncGuard(ctx context.Context)
func (*EthChainContext) SyncInfo ¶
func (e *EthChainContext) SyncInfo(ctx context.Context) (info EthSyncInfo, err error)
SyncInfo returns the height and syncing Ethereum blockchain information
type EthSyncInfo ¶ added in v0.3.0
type ProcessHandle ¶
type ProcessHandle struct { VotingProcess *contracts.VotingProcess EthereumClient *ethclient.Client }
These methods represent an exportable abstraction over raw contract bindings` Use these methods, rather than those present in the contracts folder
func NewVotingProcessHandle ¶
func NewVotingProcessHandle(contractAddressHex string, dialEndpoint string) (*ProcessHandle, error)
Constructor for proc_transactor on node
func (*ProcessHandle) CancelProcessTxArgs ¶
func (ph *ProcessHandle) CancelProcessTxArgs(ctx context.Context, pid [32]byte) (*types.CancelProcessTx, error)
func (*ProcessHandle) Genesis ¶
func (ph *ProcessHandle) Genesis(ctx context.Context) (string, error)
func (*ProcessHandle) Oracles ¶
func (ph *ProcessHandle) Oracles(ctx context.Context) ([]string, error)
func (*ProcessHandle) ProcessIndex ¶
func (*ProcessHandle) ProcessTxArgs ¶
func (ph *ProcessHandle) ProcessTxArgs(ctx context.Context, pid [32]byte) (*types.NewProcessTx, error)
func (*ProcessHandle) Validators ¶
func (ph *ProcessHandle) Validators(ctx context.Context) ([]string, error)
type Specs ¶
type Specs struct { Name string // Identity name GenesisB64 string // Base64 JSON encoded genesis file GenesisHash string // Genesis Hash NetworkId int // Ethereum Like network identification number BootNodes []string // List of Bootnodes for this network StartingBlock int64 // Where to start looking for events ENSregistryAddr string }
Specs defines a set of blockchain network specifications