admission

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: GPL-3.0 Imports: 27 Imported by: 8

Documentation

Index

Constants

View Source
const (

	// AcIdle status done.
	AcIdle workStatus = iota + 1
	// AcRunning status running.
	AcRunning

	Cpu    = "cpu"
	Memory = "memory"
)

Variables

View Source
var (
	ErrPowAbort   = errors.New("proof work aborts")
	ErrPowTimeout = errors.New("proof work timeout")
)

Functions

func ValidateCpu

func ValidateCpu(sender common.Address, blockHash []byte, nonce uint64, difficulty uint64) bool

func ValidateMemory

func ValidateMemory(sender common.Address, blockHash []byte, nonce uint64, difficulty uint64) bool

Types

type AdmissionApiBackend

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

func (*AdmissionApiBackend) Abort

func (b *AdmissionApiBackend) Abort()

func (*AdmissionApiBackend) AdmissionKey

func (b *AdmissionApiBackend) AdmissionKey() *keystore.Key

func (*AdmissionApiBackend) Apis

func (b *AdmissionApiBackend) Apis() []rpc.API

APIs returns the collection of RPC services the admission package offers.

func (*AdmissionApiBackend) Campaign

func (b *AdmissionApiBackend) Campaign(terms uint64) error

func (*AdmissionApiBackend) CheckNetworkStatus

func (b *AdmissionApiBackend) CheckNetworkStatus() bool

func (*AdmissionApiBackend) FundForRNode

func (b *AdmissionApiBackend) FundForRNode() error

func (*AdmissionApiBackend) GetResult

func (b *AdmissionApiBackend) GetResult() map[string]Result

func (*AdmissionApiBackend) GetStatus

func (b *AdmissionApiBackend) GetStatus() (workStatus, error)

func (*AdmissionApiBackend) IgnoreNetworkCheck

func (b *AdmissionApiBackend) IgnoreNetworkCheck()

func (*AdmissionApiBackend) IsRNode

func (b *AdmissionApiBackend) IsRNode() (bool, error)

func (*AdmissionApiBackend) RegisterInProcHandler

func (b *AdmissionApiBackend) RegisterInProcHandler(localRPCServer *rpc.Server)

RegisterInProcHandler registers the rpc.Server, handles RPC request to process the API requests in process

func (*AdmissionApiBackend) SetAdmissionKey

func (b *AdmissionApiBackend) SetAdmissionKey(key *keystore.Key)

func (*AdmissionApiBackend) SetContractBackend

func (b *AdmissionApiBackend) SetContractBackend(contractBackend contracts.Backend)

type AdmissionControl

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

AdmissionControl implements admission control functionality.

func NewAdmissionControl

func NewAdmissionControl(chain consensus.ChainReader, address common.Address, admissionContractAddr common.Address,
	campaignContractAddr common.Address, rNodeContractAddr common.Address, networkContractAddr common.Address) *AdmissionControl

NewAdmissionControl returns a new Control instance.

func (*AdmissionControl) Abort

func (ac *AdmissionControl) Abort()

Abort cancels all the proof work associated to the workType.

func (*AdmissionControl) Campaign

func (ac *AdmissionControl) Campaign(terms uint64) error

Campaign starts running all the proof work to generate the campaign information and waits all proof work done, send msg

func (*AdmissionControl) CheckNetworkStatus

func (ac *AdmissionControl) CheckNetworkStatus() bool

func (*AdmissionControl) DoneCh

func (ac *AdmissionControl) DoneCh() <-chan interface{}

func (*AdmissionControl) FundForRNode

func (ac *AdmissionControl) FundForRNode() error

func (*AdmissionControl) GetResult

func (ac *AdmissionControl) GetResult() map[string]Result

GetResult gets all work proofInfo

func (*AdmissionControl) GetStatus

func (ac *AdmissionControl) GetStatus() (workStatus, error)

GetStatus gets status of campaign

func (*AdmissionControl) IgnoreNetworkCheck

func (ac *AdmissionControl) IgnoreNetworkCheck()

func (*AdmissionControl) IsRNode

func (ac *AdmissionControl) IsRNode() (bool, error)

IsRNode returns true or false indicating whether the node is RNode which is able to participate campaign

func (*AdmissionControl) SetAdmissionKey

func (ac *AdmissionControl) SetAdmissionKey(key *keystore.Key)

SetAdmissionKey sets the key for admission control to participate campaign

func (*AdmissionControl) SetSimulateBackend

func (ac *AdmissionControl) SetSimulateBackend(contractBackend contracts.Backend)

type ApiBackend

type ApiBackend interface {
	// APIs returns the collection of RPC services the admission package offers.
	Apis() []rpc.API

	// IsRNode returns true or false indicate whether the node is RNode
	IsRNode() (bool, error)

	// FundForRNode sends money to reward contract to become RNode
	FundForRNode() error

	// Campaign starts running all the proof work to generate the campaign information and waits all proof work done, send msg
	Campaign(times uint64) error

	// Abort cancels all the proof work associated to the workType.
	Abort()

	// GetStatus gets status of campaign
	GetStatus() (workStatus, error)

	// getResult returns the work proof result
	GetResult() map[string]Result

	// SetAdmissionKey sets the key for admission control to participate campaign
	SetAdmissionKey(key *keystore.Key)

	// AdmissionKey returns keystore key
	AdmissionKey() *keystore.Key

	// RegisterInProcHandler registers the rpc.Server, handles RPC request to process the API requests in process
	RegisterInProcHandler(localRPCServer *rpc.Server)

	SetContractBackend(contractBackend contracts.Backend)

	// IgnoreNetworkCheck tells ac backend to ignore network status check
	IgnoreNetworkCheck()
}

ApiBackend interface provides the common JSON-RPC API.

func NewAdmissionApiBackend

func NewAdmissionApiBackend(chain consensus.ChainReader, address common.Address, admissionContractAddr common.Address,
	campaignContractAddr common.Address, rNodeContractAddr common.Address, networkContractAddr common.Address) ApiBackend

type ProofWork

type ProofWork interface {
	// contains filtered or unexported methods
}

ProofWork represent a proof work

type Result

type Result struct {
	BlockNumber int64  `json:"block_number"`
	Nonce       uint64 `json:"nonce"`
	Success     bool   `json:"success"`
}

Result is admission control examination result

Jump to

Keyboard shortcuts

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