core

package
v21.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OrgInfoMap  *OrgCache
	NodeInfoMap *NodeCache
	RoleInfoMap *RoleCache
	AcctInfoMap *AcctCache
)
View Source
var PermissionModel = Default
View Source
var PermissionTransactionAllowedFunc func(_sender common.Address, _target common.Address, _value *big.Int, _gasPrice *big.Int, _gasLimit *big.Int, _payload []byte, _transactionType TransactionType) error

Functions

func CheckAccountPermission

func CheckAccountPermission(from common.Address, to *common.Address, value *big.Int, data []byte, gas uint64, gasPrice *big.Int) error

function checks for account access to execute the transaction

func CheckIfAdminAccount

func CheckIfAdminAccount(acctId common.Address) bool

checks if the passed account is linked to a org admin or network admin role

func GetNodeUrl

func GetNodeUrl(enodeId string, ip string, port uint16, raftport uint16, isRaft bool) string

func GetSyncStatus

func GetSyncStatus() bool

func IsNodePermissioned

func IsNodePermissioned(nodename string, currentNode string, datadir string, direction string) bool

check if a given node is permissioned to connect to the change

func IsTransactionAllowed

func IsTransactionAllowed(from common.Address, to common.Address, value *big.Int, gasPrice *big.Int, gasLimit *big.Int, payload []byte, transactionType TransactionType) error

checks if the account permission allows the transaction to be executed

func IsV2Permission

func IsV2Permission() bool

func ParsePermissionedNodes

func ParsePermissionedNodes(DataDir string) []*enode.Node

func PermissionsEnabled

func PermissionsEnabled() bool

return bool to indicate if permissions is enabled

func SetDefaults

func SetDefaults(nwRoleId, oaRoleId string, permissionV2 bool)

sets default access to readonly and initializes the values for network admin role and org admin role

func SetNetworkBootUpCompleted

func SetNetworkBootUpCompleted()

sets the network boot completed as true

func SetQIP714BlockReached

func SetQIP714BlockReached()

sets the qip714block reached as true

func SetSyncStatus

func SetSyncStatus()

func ValidateNodeForTxn

func ValidateNodeForTxn(hexnodeId string, from common.Address) bool

validates if the account can transact from the current node

Types

type AccessType

type AccessType uint8
const (
	// common access type list for both V1 and V2 model.
	// the first 4 are used by both models
	// last 3 are used by V2 in alignment with EEA specs
	ReadOnly AccessType = iota
	Transact
	ContractDeploy
	FullAccess
	// below access types are only used by V2 model
	ContractCall
	TransactAndContractCall
	TransactAndContractDeploy
	ContractCallAndDeploy
)

func GetAcctAccess

func GetAcctAccess(acctId common.Address) AccessType

Returns the access type for an account. If not found returns default access

func GetDefaults

func GetDefaults() (string, string, AccessType)

type AccountInfo

type AccountInfo struct {
	OrgId      string         `json:"orgId"`
	RoleId     string         `json:"roleId"`
	AcctId     common.Address `json:"acctId"`
	IsOrgAdmin bool           `json:"isOrgAdmin"`
	Status     AcctStatus     `json:"status"`
}

type AccountKey

type AccountKey struct {
	AcctId common.Address
}

type AcctCache

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

func NewAcctCache

func NewAcctCache(cacheSize int) *AcctCache

func (*AcctCache) GetAccount

func (a *AcctCache) GetAccount(acct common.Address) (*AccountInfo, error)

func (*AcctCache) GetAcctList

func (a *AcctCache) GetAcctList() []AccountInfo

func (*AcctCache) GetAcctListOrg

func (a *AcctCache) GetAcctListOrg(orgId string) []AccountInfo

func (*AcctCache) GetAcctListRole

func (a *AcctCache) GetAcctListRole(orgId, roleId string) []AccountInfo

func (*AcctCache) PopulateCacheFunc

func (a *AcctCache) PopulateCacheFunc(cf func(common.Address) (*AccountInfo, error))

func (*AcctCache) UpsertAccount

func (a *AcctCache) UpsertAccount(orgId string, role string, acct common.Address, orgAdmin bool, status AcctStatus)

type AcctStatus

type AcctStatus uint8
const (
	AcctPendingApproval AcctStatus = iota + 1
	AcctActive
	AcctInactive
	AcctSuspended
	AcctBlacklisted
	AdminRevoked
	AcctRecoveryInitiated
	AcctRecoveryCompleted
)

type NodeCache

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

func NewNodeCache

func NewNodeCache(cacheSize int) *NodeCache

func (*NodeCache) GetNodeByUrl

func (n *NodeCache) GetNodeByUrl(url string) (*NodeInfo, error)

func (*NodeCache) GetNodeList

func (n *NodeCache) GetNodeList() []NodeInfo

func (*NodeCache) PopulateCacheFunc

func (n *NodeCache) PopulateCacheFunc(cf func(string) (*NodeInfo, error))

func (*NodeCache) PopulateValidateFunc

func (n *NodeCache) PopulateValidateFunc(cf func(string, string) bool)

func (*NodeCache) UpsertNode

func (n *NodeCache) UpsertNode(orgId string, url string, status NodeStatus)

type NodeInfo

type NodeInfo struct {
	OrgId  string     `json:"orgId"`
	Url    string     `json:"url"`
	Status NodeStatus `json:"status"`
}

type NodeKey

type NodeKey struct {
	OrgId string
	Url   string
}

type NodeStatus

type NodeStatus uint8
const (
	NodePendingApproval NodeStatus = iota + 1
	NodeApproved
	NodeDeactivated
	NodeBlackListed
	NodeRecoveryInitiated
)

type OrgCache

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

func NewOrgCache

func NewOrgCache(cacheSize int) *OrgCache

func (*OrgCache) GetOrg

func (o *OrgCache) GetOrg(orgId string) (*OrgInfo, error)

func (*OrgCache) GetOrgList

func (o *OrgCache) GetOrgList() []OrgInfo

func (*OrgCache) PopulateCacheFunc

func (o *OrgCache) PopulateCacheFunc(cf func(string) (*OrgInfo, error))

func (*OrgCache) UpsertOrg

func (o *OrgCache) UpsertOrg(orgId, parentOrg, ultimateParent string, level *big.Int, status OrgStatus)

func (*OrgCache) UpsertOrgWithSubOrgList

func (o *OrgCache) UpsertOrgWithSubOrgList(orgRec *OrgInfo)

type OrgDetailInfo

type OrgDetailInfo struct {
	NodeList   []NodeInfo    `json:"nodeList"`
	RoleList   []RoleInfo    `json:"roleList"`
	AcctList   []AccountInfo `json:"acctList"`
	SubOrgList []string      `json:"subOrgList"`
}

type OrgInfo

type OrgInfo struct {
	OrgId          string    `json:"orgId"`
	FullOrgId      string    `json:"fullOrgId"`
	ParentOrgId    string    `json:"parentOrgId"`
	UltimateParent string    `json:"ultimateParent"`
	Level          *big.Int  `json:"level"`
	SubOrgList     []string  `json:"subOrgList"`
	Status         OrgStatus `json:"status"`
}

type OrgKey

type OrgKey struct {
	OrgId string
}

type OrgStatus

type OrgStatus uint8
const (
	OrgPendingApproval OrgStatus = iota + 1
	OrgApproved
	OrgPendingSuspension
	OrgSuspended
)

type PermissionModelType

type PermissionModelType uint8
const (
	V1 PermissionModelType = iota
	V2
	Default
)

type RoleCache

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

func NewRoleCache

func NewRoleCache(cacheSize int) *RoleCache

func (*RoleCache) GetRole

func (r *RoleCache) GetRole(orgId string, roleId string) (*RoleInfo, error)

func (*RoleCache) GetRoleList

func (r *RoleCache) GetRoleList() []RoleInfo

func (*RoleCache) PopulateCacheFunc

func (r *RoleCache) PopulateCacheFunc(cf func(*RoleKey) (*RoleInfo, error))

func (*RoleCache) UpsertRole

func (r *RoleCache) UpsertRole(orgId string, role string, voter bool, admin bool, access AccessType, active bool)

type RoleInfo

type RoleInfo struct {
	OrgId   string     `json:"orgId"`
	RoleId  string     `json:"roleId"`
	IsVoter bool       `json:"isVoter"`
	IsAdmin bool       `json:"isAdmin"`
	Access  AccessType `json:"access"`
	Active  bool       `json:"active"`
}

type RoleKey

type RoleKey struct {
	OrgId  string
	RoleId string
}

type TransactionType

type TransactionType uint8
const (
	ValueTransferTxn TransactionType = iota
	ContractCallTxn
	ContractDeployTxn
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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