configstore

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultService

func DefaultService(repository Repository, idService identity.Service) config.Service

DefaultService returns an implementation of the config.Service

func NewAccount

func NewAccount(ethAccountName string, c config.Configuration) (config.Account, error)

NewAccount creates a new Account instance with configs TODO(ved): why do we need temp and this function ?

func NewNodeConfig

func NewNodeConfig(c config.Configuration) config.Configuration

NewNodeConfig creates a new NodeConfig instance with configs

func StartGenerateIdentityJob added in v1.3.0

func StartGenerateIdentityJob(
	did identity.DID, dispatcher jobs.Dispatcher, validUntil time.Time) (jobID []byte, err error)

StartGenerateIdentityJob starts a new job that creates the provided identity on chain account must be already stored in the repo

func TempAccount

func TempAccount(ethAccountName string, c config.Configuration) (config.Account, error)

TempAccount creates a new Account without id validation, Must only be used for account creation.

Types

type Account

type Account struct {
	EthereumAccount                  *config.AccountConfig
	EthereumDefaultAccountName       string
	EthereumContextWaitTimeout       time.Duration
	ReceiveEventNotificationEndpoint string
	IdentityID                       []byte
	SigningKeyPair                   KeyPair
	P2PKeyPair                       KeyPair

	PrecommitEnabled bool
	CentChainAccount config.CentChainAccount
	// contains filtered or unexported fields
}

Account exposes options specific to an account in the node

func (*Account) FromJSON

func (acc *Account) FromJSON(data []byte) error

FromJSON initialize the model with a json

func (*Account) GetCentChainAccount added in v1.0.0

func (acc *Account) GetCentChainAccount() config.CentChainAccount

GetCentChainAccount gets CentChainAccount

func (*Account) GetEthereumAccount

func (acc *Account) GetEthereumAccount() *config.AccountConfig

GetEthereumAccount gets EthereumAccount

func (*Account) GetEthereumContextWaitTimeout

func (acc *Account) GetEthereumContextWaitTimeout() time.Duration

GetEthereumContextWaitTimeout gets EthereumContextWaitTimeout

func (*Account) GetEthereumDefaultAccountName

func (acc *Account) GetEthereumDefaultAccountName() string

GetEthereumDefaultAccountName gets EthereumDefaultAccountName

func (*Account) GetIdentityID

func (acc *Account) GetIdentityID() []byte

GetIdentityID gets IdentityID

func (*Account) GetKeys

func (acc *Account) GetKeys() (idKeys map[string]config.IDKey, err error)

GetKeys returns the keys of an account TODO remove GetKeys and add signing methods to account

func (*Account) GetP2PKeyPair

func (acc *Account) GetP2PKeyPair() (pub, priv string)

GetP2PKeyPair gets P2PKeyPair

func (*Account) GetPrecommitEnabled

func (acc *Account) GetPrecommitEnabled() bool

GetPrecommitEnabled gets the enable pre commit value

func (*Account) GetReceiveEventNotificationEndpoint

func (acc *Account) GetReceiveEventNotificationEndpoint() string

GetReceiveEventNotificationEndpoint gets ReceiveEventNotificationEndpoint

func (*Account) GetSigningKeyPair

func (acc *Account) GetSigningKeyPair() (pub, priv string)

GetSigningKeyPair gets SigningKeyPair

func (*Account) ID

func (acc *Account) ID() []byte

ID Get the ID of the document represented by this model

func (*Account) JSON

func (acc *Account) JSON() ([]byte, error)

JSON return the json representation of the model

func (*Account) SignMsg

func (acc *Account) SignMsg(msg []byte) (*coredocumentpb.Signature, error)

SignMsg signs a message with the signing key

func (*Account) Type

func (acc *Account) Type() reflect.Type

Type Returns the underlying type of the Account

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper to initialise configstore package.

func (*Bootstrapper) Bootstrap

func (*Bootstrapper) Bootstrap(context map[string]interface{}) error

Bootstrap takes the passed in config file, loads the config and puts the config back into context.

type KeyPair

type KeyPair struct {
	Pub string `json:"Pub"`
	Pvt string `json:"Priv"`
}

KeyPair represents a key pair config

func NewKeyPair

func NewKeyPair(pub, priv string) KeyPair

NewKeyPair creates a KeyPair

type NodeConfig

type NodeConfig struct {
	MainIdentity                   Account
	StoragePath                    string
	AccountsKeystore               string
	P2PPort                        int
	P2PExternalIP                  string
	P2PConnectionTimeout           time.Duration
	P2PResponseDelay               time.Duration
	ServerPort                     int
	ServerAddress                  string
	NumWorkers                     int
	WorkerWaitTimeMS               int
	TaskValidDuration              time.Duration
	EthereumNodeURL                string
	EthereumContextReadWaitTimeout time.Duration
	EthereumContextWaitTimeout     time.Duration
	EthereumIntervalRetry          time.Duration
	EthereumMaxRetries             int
	EthereumMaxGasPrice            *big.Int
	EthereumGasLimits              map[config.ContractOp]uint64
	EthereumGasMultiplier          float64
	NetworkString                  string
	BootstrapPeers                 []string
	NetworkID                      uint32
	SmartContractAddresses         map[config.ContractName]common.Address
	SmartContractBytecode          map[config.ContractName]string
	PprofEnabled                   bool
	DebugLogEnabled                bool
	CentChainNodeURL               string
	CentChainIntervalRetry         time.Duration
	CentChainMaxRetries            int
	CentChainAnchorLifespan        time.Duration
}

NodeConfig exposes configs specific to the node

func (*NodeConfig) FromJSON

func (nc *NodeConfig) FromJSON(data []byte) error

FromJSON initialize the model with a json

func (*NodeConfig) Get

func (nc *NodeConfig) Get(key string) interface{}

Get refer the interface

func (*NodeConfig) GetAccountsKeystore

func (nc *NodeConfig) GetAccountsKeystore() string

GetAccountsKeystore returns the accounts keystore path.

func (*NodeConfig) GetBool

func (nc *NodeConfig) GetBool(key string) bool

GetBool refer the interface

func (*NodeConfig) GetBootstrapPeers

func (nc *NodeConfig) GetBootstrapPeers() []string

GetBootstrapPeers refer the interface

func (*NodeConfig) GetCentChainAccount added in v1.0.0

func (nc *NodeConfig) GetCentChainAccount() (config.CentChainAccount, error)

GetCentChainAccount returns the Cent Chain account of the current node.

func (*NodeConfig) GetCentChainAnchorLifespan added in v1.0.0

func (nc *NodeConfig) GetCentChainAnchorLifespan() time.Duration

GetCentChainAnchorLifespan returns the default lifespan of an anchor.

func (*NodeConfig) GetCentChainIntervalRetry added in v1.0.0

func (nc *NodeConfig) GetCentChainIntervalRetry() time.Duration

GetCentChainIntervalRetry returns duration to wait between retries.

func (*NodeConfig) GetCentChainMaxRetries added in v1.0.0

func (nc *NodeConfig) GetCentChainMaxRetries() int

GetCentChainMaxRetries returns the max acceptable retries.

func (*NodeConfig) GetCentChainNodeURL added in v1.0.0

func (nc *NodeConfig) GetCentChainNodeURL() string

GetCentChainNodeURL returns the URL of the CentChain Node.

func (*NodeConfig) GetConfigStoragePath

func (nc *NodeConfig) GetConfigStoragePath() string

GetConfigStoragePath refer the interface

func (*NodeConfig) GetContractAddress

func (nc *NodeConfig) GetContractAddress(contractName config.ContractName) common.Address

GetContractAddress refer the interface

func (*NodeConfig) GetContractAddressString

func (nc *NodeConfig) GetContractAddressString(address string) string

GetContractAddressString refer the interface

func (*NodeConfig) GetDuration

func (nc *NodeConfig) GetDuration(key string) time.Duration

GetDuration refer the interface

func (*NodeConfig) GetEthereumAccount

func (nc *NodeConfig) GetEthereumAccount(accountName string) (account *config.AccountConfig, err error)

GetEthereumAccount refer the interface

func (*NodeConfig) GetEthereumContextReadWaitTimeout

func (nc *NodeConfig) GetEthereumContextReadWaitTimeout() time.Duration

GetEthereumContextReadWaitTimeout refer the interface

func (*NodeConfig) GetEthereumContextWaitTimeout

func (nc *NodeConfig) GetEthereumContextWaitTimeout() time.Duration

GetEthereumContextWaitTimeout refer the interface

func (*NodeConfig) GetEthereumDefaultAccountName

func (nc *NodeConfig) GetEthereumDefaultAccountName() string

GetEthereumDefaultAccountName refer the interface

func (*NodeConfig) GetEthereumGasLimit

func (nc *NodeConfig) GetEthereumGasLimit(op config.ContractOp) uint64

GetEthereumGasLimit refer the interface

func (*NodeConfig) GetEthereumGasMultiplier added in v1.2.0

func (nc *NodeConfig) GetEthereumGasMultiplier() float64

GetEthereumGasMultiplier refer the interface

func (*NodeConfig) GetEthereumIntervalRetry

func (nc *NodeConfig) GetEthereumIntervalRetry() time.Duration

GetEthereumIntervalRetry refer the interface

func (*NodeConfig) GetEthereumMaxGasPrice

func (nc *NodeConfig) GetEthereumMaxGasPrice() *big.Int

GetEthereumMaxGasPrice refer the interface

func (*NodeConfig) GetEthereumMaxRetries

func (nc *NodeConfig) GetEthereumMaxRetries() int

GetEthereumMaxRetries refer the interface

func (*NodeConfig) GetEthereumNodeURL

func (nc *NodeConfig) GetEthereumNodeURL() string

GetEthereumNodeURL refer the interface

func (*NodeConfig) GetFloat added in v1.2.0

func (nc *NodeConfig) GetFloat(key string) float64

GetFloat refer the interface

func (*NodeConfig) GetIdentityID

func (nc *NodeConfig) GetIdentityID() ([]byte, error)

GetIdentityID refer the interface

func (*NodeConfig) GetInt

func (nc *NodeConfig) GetInt(key string) int

GetInt refer the interface

func (*NodeConfig) GetNetworkID

func (nc *NodeConfig) GetNetworkID() uint32

GetNetworkID refer the interface

func (*NodeConfig) GetNetworkKey

func (nc *NodeConfig) GetNetworkKey(k string) string

GetNetworkKey refer the interface

func (*NodeConfig) GetNetworkString

func (nc *NodeConfig) GetNetworkString() string

GetNetworkString refer the interface

func (*NodeConfig) GetNumWorkers

func (nc *NodeConfig) GetNumWorkers() int

GetNumWorkers refer the interface

func (*NodeConfig) GetP2PConnectionTimeout

func (nc *NodeConfig) GetP2PConnectionTimeout() time.Duration

GetP2PConnectionTimeout refer the interface

func (*NodeConfig) GetP2PExternalIP

func (nc *NodeConfig) GetP2PExternalIP() string

GetP2PExternalIP refer the interface

func (*NodeConfig) GetP2PKeyPair

func (nc *NodeConfig) GetP2PKeyPair() (pub, priv string)

GetP2PKeyPair refer the interface

func (*NodeConfig) GetP2PPort

func (nc *NodeConfig) GetP2PPort() int

GetP2PPort refer the interface

func (*NodeConfig) GetP2PResponseDelay added in v1.0.0

func (nc *NodeConfig) GetP2PResponseDelay() time.Duration

GetP2PResponseDelay refer the interface

func (*NodeConfig) GetPrecommitEnabled

func (nc *NodeConfig) GetPrecommitEnabled() bool

GetPrecommitEnabled refer the interface

func (*NodeConfig) GetReceiveEventNotificationEndpoint

func (nc *NodeConfig) GetReceiveEventNotificationEndpoint() string

GetReceiveEventNotificationEndpoint refer the interface

func (*NodeConfig) GetServerAddress

func (nc *NodeConfig) GetServerAddress() string

GetServerAddress refer the interface

func (*NodeConfig) GetServerPort

func (nc *NodeConfig) GetServerPort() int

GetServerPort refer the interface

func (*NodeConfig) GetSigningKeyPair

func (nc *NodeConfig) GetSigningKeyPair() (pub, priv string)

GetSigningKeyPair refer the interface

func (*NodeConfig) GetStoragePath

func (nc *NodeConfig) GetStoragePath() string

GetStoragePath refer the interface

func (*NodeConfig) GetString

func (nc *NodeConfig) GetString(key string) string

GetString refer the interface

func (*NodeConfig) GetTaskValidDuration added in v1.0.0

func (nc *NodeConfig) GetTaskValidDuration() time.Duration

GetTaskValidDuration returns the time duration until which task is valid

func (*NodeConfig) GetWorkerWaitTimeMS

func (nc *NodeConfig) GetWorkerWaitTimeMS() int

GetWorkerWaitTimeMS refer the interface

func (*NodeConfig) ID

func (nc *NodeConfig) ID() ([]byte, error)

ID Gets the ID of the document represented by this model

func (*NodeConfig) IsDebugLogEnabled added in v1.0.0

func (nc *NodeConfig) IsDebugLogEnabled() bool

IsDebugLogEnabled refer the interface

func (*NodeConfig) IsPProfEnabled

func (nc *NodeConfig) IsPProfEnabled() bool

IsPProfEnabled refer the interface

func (*NodeConfig) IsSet

func (nc *NodeConfig) IsSet(key string) bool

IsSet refer the interface

func (*NodeConfig) JSON

func (nc *NodeConfig) JSON() ([]byte, error)

JSON return the json representation of the model

func (*NodeConfig) Set

func (nc *NodeConfig) Set(key string, value interface{})

Set refer the interface

func (*NodeConfig) SetDefault

func (nc *NodeConfig) SetDefault(key string, value interface{})

SetDefault refer the interface

func (*NodeConfig) SetupSmartContractAddresses

func (nc *NodeConfig) SetupSmartContractAddresses(network string, smartContractAddresses *config.SmartContractAddresses)

SetupSmartContractAddresses refer the interface

func (*NodeConfig) Type

func (nc *NodeConfig) Type() reflect.Type

Type Returns the underlying type of the NodeConfig

type ProtocolSetter

type ProtocolSetter interface {
	InitProtocolForDID(identity.DID)
}

ProtocolSetter sets the protocol on host for the centID

type Repository added in v1.0.0

type Repository interface {
	// RegisterAccount registers account in DB
	RegisterAccount(config config.Account)

	// RegisterConfig registers node config in DB
	RegisterConfig(config config.Configuration)

	// GetAccount returns the Account associated with account ID
	GetAccount(id []byte) (config.Account, error)

	// GetConfig returns the node config model
	GetConfig() (config.Configuration, error)

	// GetAccounts returns a list of all account models in the config DB
	GetAllAccounts() ([]config.Account, error)

	// Create creates the account model if not present in the DB.
	// should error out if the config exists.
	CreateAccount(id []byte, account config.Account) error

	// Create creates the node config model if not present in the DB.
	// should error out if the config exists.
	CreateConfig(config config.Configuration) error

	// Update strictly updates the account model.
	// Will error out when the account model doesn't exist in the DB.
	UpdateAccount(id []byte, account config.Account) error

	// Update strictly updates the node config model.
	// Will error out when the config model doesn't exist in the DB.
	UpdateConfig(nodeConfig config.Configuration) error

	// Delete deletes account config
	// Will not error out when account model doesn't exists in DB
	DeleteAccount(id []byte) error

	// Delete deletes node config
	// Will not error out when config model doesn't exists in DB
	DeleteConfig() error
}

Repository defines the required methods for the config repository.

func NewDBRepository added in v1.0.0

func NewDBRepository(db storage.Repository) Repository

NewDBRepository creates instance of Config repository

Jump to

Keyboard shortcuts

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