types

package
v0.0.0-...-83a01c7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PERMISSION_V0 = "v0"
	PERMISSION_V1 = "v1"
)

supports 2 models of permissions v1 and v0. v0 is aligned with the latest eea specs

View Source
const (
	PERMISSIONED_CONFIG     = "permissioned-nodes.json"
	BLACKLIST_CONFIG        = "disallowed-nodes.json"
	PERMISSION_MODEL_CONFIG = "permission-config.json"
	DEFAULT_NODECACHE_SIZE  = 1000
	NODE_NAME_LENGTH        = 32
)

Variables

View Source
var (
	ErrInvalidInput = errors.New("Invalid input")

	ErrInvalidNode = errors.New("Invalid enode id")

	ErrBlacklistedNode = errors.New("Blacklisted node. Operation not allowed")

	ErrNodeDoesNotExists = errors.New("Node does not exist")
	ErrOrgDoesNotExists  = errors.New("Org does not exist")

	ErrHostNameNotSupported = errors.New("Hostname not supported in the network")
	ErrNoPermissionForTxn   = errors.New("account does not have permission for the transaction")
)
View Source
var StopFeed event.Feed

broadcasting stopEvent when service is being stopped

Functions

func BindContract

func BindContract(contractInstance interface{}, bindFunc func() (interface{}, error)) error

func DisconnectNode

func DisconnectNode(node *node.Node, enodeId string, isAuthority bool) error

Disconnect the Node from the network

func GetNodeDetails

func GetNodeDetails(url string, isAuthority, useDns bool) (string, string, uint16, uint16, error)

returns the enode details

func SubscribeStopEvent

func SubscribeStopEvent() (chan StopEvent, event.Subscription)

function to subscribe to the stop event

func UpdateDisallowedNodes

func UpdateDisallowedNodes(dataDir, url string, operation NodeOperation) error

this function populates the black listed Node information into the disallowed-nodes.json file

func UpdateFile

func UpdateFile(fileName, enodeId string, operation NodeOperation, createFile bool) error

adds or deletes and entry from a given file

func UpdatePermissionedNodes

func UpdatePermissionedNodes(node *node.Node, dataDir, enodeId string, operation NodeOperation, isAuthority bool) error

updates Node information in the permissioned-nodes.json file based on Node management activities in smart contract

Types

type Backend

type Backend interface {

	// node service for node management service
	GetNodeService(transactOpts *bind.TransactOpts, nodeBackend ContractBackend) (NodeService, error)

	// control service for account management service
	GetControlService(controlBackend ContractBackend) (ControlService, error)

	// Monitors Node management events and updates cache accordingly
	ManageNodePermissions() error

	// monitors for network boot up complete event
	MonitorNetworkBootUp() error
}

type ContractBackend

type ContractBackend struct {
	EthClnt     bind.ContractBackend
	Key         *ecdsa.PrivateKey
	PermConfig  *PermissionConfig
	IsAuthority bool
	UseDns      bool
}

type ControlService

type ControlService interface {
	ConnectionAllowed(_enodeId, _ip string, _port, _raftPort uint16) (bool, error)
	TransactionAllowed(_sender common.Address, _target common.Address, _value *big.Int, _gasPrice *big.Int, _gasLimit *big.Int, _payload []byte, _transactionType core.TransactionType) error
}

Control services

type InitService

type InitService interface {
	BindContracts() error
	Init(_breadth *big.Int, _depth *big.Int) (*types.Transaction, error)
	UpdateNetworkBootStatus() (*types.Transaction, error)
	SetPolicy(_nwAdminOrg string, _nwAdminRole string, _oAdminRole string) (*types.Transaction, error)
	GetNetworkBootStatus() (bool, error)

	AddAdminNode(url string) (*types.Transaction, error)

	GetNodeDetailsFromIndex(_nodeIndex *big.Int) (string, string, *big.Int, error)
	GetNumberOfNodes() (*big.Int, error)
	GetNodeDetails(enodeId string) (string, string, *big.Int, error)
}

type InterfaceBackend

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

backend struct for interfaces

func NewInterfaceBackend

func NewInterfaceBackend(node *node.Node, isAuthority bool, dataDir string) *InterfaceBackend

func (InterfaceBackend) DataDir

func (i InterfaceBackend) DataDir() string

func (InterfaceBackend) IsAuthority

func (i InterfaceBackend) IsAuthority() bool

func (InterfaceBackend) Node

func (i InterfaceBackend) Node() *node.Node

func (*InterfaceBackend) SetIsAuthority

func (i *InterfaceBackend) SetIsAuthority(isAuthority bool)

type NodeOperation

type NodeOperation uint8
const (
	NodeAdd NodeOperation = iota
	NodeDelete
)

type NodeService

type NodeService interface {
	AddNode(_args TxArgs) (*types.Transaction, error)
	UpdateNodeStatus(_args TxArgs) (*types.Transaction, error)
	StartBlacklistedNodeRecovery(_args TxArgs) (*types.Transaction, error)
	ApproveBlacklistedNodeRecovery(_args TxArgs) (*types.Transaction, error)
}

Node services

type PermissionConfig

type PermissionConfig struct {
	PermissionsModel string         `json:"permissionModel"`
	UpgrdAddress     common.Address `json:"upgrdableAddress"`
	NodeAddress      common.Address `json:"nodeMgrAddress"`
}

permission config for bootstrapping

func ParsePermissionConfig

func ParsePermissionConfig(dir string) (PermissionConfig, error)

function reads the permissions config file passed and populates the config structure accordingly

func (*PermissionConfig) IsEmpty

func (pc *PermissionConfig) IsEmpty() bool

type StopEvent

type StopEvent struct {
}

to signal all watches when service is stopped

type TxArgs

type TxArgs struct {
	Url        string
	AcctId     common.Address
	AccessType uint8
	Action     uint8
	Txa        ethapi.SendTxArgs
}

TxArgs holds arguments required for execute functions

Jump to

Keyboard shortcuts

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