onchain

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 26 Imported by: 6

Documentation

Index

Constants

View Source
const (
	//TrafficSystemRandom is a request type to build a corresponding pipeline
	TrafficSystemRandom = iota // 0
	//TrafficUserRandom is a request type to build a corresponding pipeline
	TrafficUserRandom
	//TrafficUserQuery is a request type to build a corresponding pipeline
	TrafficUserQuery
)
View Source
const (
	//SubscribeLogUpdateRandom is a log type to subscribe the event LogUpdateRandom
	SubscribeLogUpdateRandom = iota
	//SubscribeLogRequestUserRandom is a log type to subscribe the event LogRequestUserRandom
	SubscribeLogRequestUserRandom
	//SubscribeLogUrl is a log type to subscribe the event LogUrl
	SubscribeLogUrl
	//SubscribeLogValidationResult is a log type to subscribe the event LogValidationResult
	SubscribeLogValidationResult
	//SubscribeLogGrouping is a log type to subscribe the event LogGrouping
	SubscribeLogGrouping
	//SubscribeLogPublicKeyAccepted is a log type to subscribe the event LogPublicKeyAccepted
	SubscribeLogPublicKeyAccepted
	//SubscribeLogPublicKeySuggested is a log type to subscribe the event LogPublicKeySuggested
	SubscribeLogPublicKeySuggested
	//SubscribeLogGroupDissolve is a log type to subscribe the event LogGroupDissolve
	SubscribeLogGroupDissolve
	//SubscribeLogInsufficientPendingNode is a log type to subscribe the event LogInsufficientPendingNode
	SubscribeLogInsufficientPendingNode
	//SubscribeLogInsufficientWorkingGroup is a log type to subscribe the event LogInsufficientWorkingGroup
	SubscribeLogInsufficientWorkingGroup
	//SubscribeLogNoWorkingGroup is a log type to subscribe the event LogNoWorkingGroup
	SubscribeLogNoWorkingGroup
	//SubscribeLogGroupingInitiated is a log type to subscribe the event GroupingInitiated
	SubscribeLogGroupingInitiated
	//SubscribeDosproxyUpdateBootstrapGroups is a log type to subscribe the event UpdateGroupToPick
	SubscribeDosproxyUpdateBootstrapGroups
	//SubscribeDosproxyUpdateGroupSize is a log type to subscribe the event UpdateGroupSize
	SubscribeDosproxyUpdateGroupSize
	//SubscribeCommitrevealLogStartCommitreveal is a log type to subscribe the event StartCommitreveal
	SubscribeCommitrevealLogStartCommitreveal
	//SubscribeCommitrevealLogCommit is a log type to subscribe the event LogCommit
	SubscribeCommitrevealLogCommit
	//SubscribeCommitrevealLogReveal is a log type to subscribe the event LogReveal
	SubscribeCommitrevealLogReveal
	//SubscribeCommitrevealLogRandom is a log type to subscribe the event LogRandom
	SubscribeCommitrevealLogRandom
)
View Source
const (
	//ETH represents the type of blockchain
	ETH = "ETH"
)

Variables

This section is empty.

Functions

func CheckSync

func CheckSync(ctx context.Context, cs chan *ethclient.Client) chan *ethclient.Client

CheckSync is a utility function to check sync state

func CheckTransaction

func CheckTransaction(client *ethclient.Client, tx *types.Transaction) (err error)

CheckTransaction return an error if the transaction is failed

func DialToEth

func DialToEth(ctx context.Context, urlPool []string) (out chan DialResult)

DialToEth is a utility function to dial to Ethereum

func GenEthkey

func GenEthkey(credentialPath, passPhrase string) (err error)

func GetBalance

func GetBalance(client *ethclient.Client, key *keystore.Key) (balance *big.Float, err error)

GetBalance returns the wei balance of the given account.

func GetCurrentBlock

func GetCurrentBlock(client *ethclient.Client) (blknum uint64, err error)

GetCurrentBlock returns a block number of latest known header from the current canonical chain.

func NewEthAdaptor

func NewEthAdaptor(key *keystore.Key, config *configuration.Config, l logger) (adaptor *ethAdaptor, err error)

NewEthAdaptor creates an eth implemention of ProxyAdapter

func NumOfAccounts

func NumOfAccounts(credentialPath string) (n int)

func ReadEthKey

func ReadEthKey(credentialPath, passphrase string) (key *keystore.Key, err error)

ReadEthKey is a utility function to read a keystore file

Types

type DialResult

type DialResult struct {
	Client *ethclient.Client
	Url    string
	Err    error
}

type LogCommit

type LogCommit struct {
	Cid        *big.Int
	From       common.Address
	Commitment [32]byte
}

LogCommit is an onchain event that means a secret is committed

type LogCommon

type LogCommon struct {
	Tx      string
	BlockN  uint64
	Removed bool
	Raw     types.Log
	// contains filtered or unexported fields
}

type LogGroupDissolve

type LogGroupDissolve struct {
	GroupId *big.Int
}

LogGroupDissolve is an onchain event that DOSProxy requests to dissolve a specified group

type LogGrouping

type LogGrouping struct {
	GroupId *big.Int
	NodeId  [][]byte
}

LogGrouping is an onchain event that DOSProxy requests the specified nodes to start DKG to generate a new pubkey

type LogGroupingInitiated

type LogGroupingInitiated struct {
	NumPendingNodes *big.Int
	GroupSize       *big.Int
}

LogGroupingInitiated is an onchain event that DOSProxy has requested a random number to form a new group

type LogInsufficientPendingNode

type LogInsufficientPendingNode struct {
	NumPendingNodes *big.Int
}

LogInsufficientPendingNode is an onchain event that means there are no enough pending nodes to form a new group

type LogInsufficientWorkingGroup

type LogInsufficientWorkingGroup struct {
	NumWorkingGroups *big.Int
}

LogInsufficientWorkingGroup is an onchain event that means there are no enough working groups to mix with pending nodes to form a new group

type LogPublicKeyAccepted

type LogPublicKeyAccepted struct {
	GroupId          *big.Int
	WorkingGroupSize *big.Int
}

LogPublicKeyAccepted is an onchain event that DOSProxy receives enough suggested pubkey so accepts it as a new pubkey

type LogPublicKeySuggested

type LogPublicKeySuggested struct {
	GroupId   *big.Int
	Count     *big.Int
	GroupSize *big.Int
}

LogPublicKeySuggested is an onchain event that DOSProxy accepts a suggested pubkey

type LogRandom

type LogRandom struct {
	Cid    *big.Int
	Random *big.Int
}

LogRandom is an onchain event that means a new random is generated by a commit-reveal process with Cid

type LogRequestUserRandom

type LogRequestUserRandom struct {
	RequestId            *big.Int
	LastSystemRandomness *big.Int
	UserSeed             *big.Int
	DispatchedGroupId    *big.Int
}

LogRequestUserRandom is an onchain event that DOSProxy requests a random number with RequestID

type LogReveal

type LogReveal struct {
	Cid    *big.Int
	From   common.Address
	Secret *big.Int
}

LogReveal is an onchain event that means a secret is revealed

type LogStartCommitReveal

type LogStartCommitReveal struct {
	Cid             *big.Int
	StartBlock      *big.Int
	CommitDuration  *big.Int
	RevealDuration  *big.Int
	RevealThreshold *big.Int
}

LogStartCommitReveal is an onchain event that means DOSProxy starts a new commit-revel process

type LogUpdateGroupSize

type LogUpdateGroupSize struct {
	OldSize *big.Int
	NewSize *big.Int
}

LogUpdateGroupSize is an onchain event that means GroupSize is updated

type LogUpdateGroupToPick

type LogUpdateGroupToPick struct {
	OldNum *big.Int
	NewNum *big.Int
}

LogUpdateGroupToPick is an onchain event that means GroupToPick is updated

type LogUpdateRandom

type LogUpdateRandom struct {
	LastRandomness    *big.Int
	DispatchedGroupId *big.Int
}

LogUpdateRandom is an onchain event that DOSProxy requests a system random number

type LogUrl

type LogUrl struct {
	QueryId           *big.Int
	Timeout           *big.Int
	DataSource        string
	Selector          string
	Randomness        *big.Int
	DispatchedGroupId *big.Int
}

LogUrl is an onchain event that DOSProxy requests a query result from the specified URL

type LogValidationResult

type LogValidationResult struct {
	TrafficType uint8
	TrafficId   *big.Int
	Message     []byte
	Signature   [2]*big.Int
	PubKey      [4]*big.Int
	Pass        bool
	Version     uint8
}

LogValidationResult is an onchain event that shows a quesry result

type OnchainError

type OnchainError struct {
	Idx int
	// contains filtered or unexported fields
}

func (*OnchainError) Error

func (e *OnchainError) Error() string

func (*OnchainError) Format

func (e *OnchainError) Format(f fmt.State, c rune)

func (*OnchainError) FormatError

func (e *OnchainError) FormatError(p errors.Printer) error

func (*OnchainError) Unwrap

func (e *OnchainError) Unwrap() error

type ProxyAdapter

type ProxyAdapter interface {
	Connect(urls []string, deadline time.Time) (err error)
	DisconnectAll()
	Disconnect(idx int)
	SubscribeEvent(subscribeTypes []int) (chan interface{}, chan error)
	//Set functions
	SetGroupSize(g uint64) (err error)
	UpdateRandomness(signatures *vss.Signature) (err error)
	DataReturn(signatures *vss.Signature) (err error)
	RegisterGroupPubKey(IdWithPubKeys [5]*big.Int) (err error)
	RegisterNewNode() (err error)
	UnRegisterNode() (err error)
	SignalRandom() (err error)
	SignalGroupFormation() (err error)
	SignalGroupDissolve() (err error)
	SignalBootstrap(cid *big.Int) (err error)
	SignalUnregister(addr common.Address) (err error)
	StartCommitReveal(startBlock int64, commitDuration int64, revealDuration int64, revealThreshold int64) (err error)
	Commit(cid *big.Int, commitment [32]byte) (err error)
	Reveal(cid *big.Int, secret *big.Int) (err error)
	//Get functions
	GroupToPick() (result uint64, err error)
	PendingNonce() (result uint64, err error)
	GetExpiredWorkingGroupSize() (r uint64, err error)
	GroupSize() (r uint64, err error)
	GetWorkingGroupSize() (r uint64, err error)
	LastGroupFormationRequestId() (r uint64, err error)
	LastUpdatedBlock() (r uint64, err error)
	NumPendingGroups() (r uint64, err error)
	NumPendingNodes() (r uint64, err error)
	BootstrapEndBlk() (result uint64, err error)
	BootstrapRound() (result uint64, err error)
	Balance() (balance *big.Float, err error)
	Address() (addr common.Address)
	CurrentBlock() (r uint64, err error)
	RefreshSystemRandomHardLimit() (limit uint64, err error)
	BootstrapStartThreshold() (result uint64, err error)
	GroupPubKey(idx int) (groupPubKeys [4]*big.Int, err error)
	IsPendingNode(id []byte) (bool, error)
	BootStrapUrl() string
}

ProxyAdapter represents an unified adapter interface for different blockchain

func NewProxyAdapter

func NewProxyAdapter(key *keystore.Key, config *configuration.Config) (ProxyAdapter, error)

NewProxyAdapter constructs a new ProxyAdapter with the given type of blockchain and contract addresses

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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