types

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: LGPL-3.0 Imports: 11 Imported by: 13

Documentation

Index

Constants

View Source
const (
	SendTx               uint16 = 0x0
	ActivationTx         uint16 = 0x1
	InviteTx             uint16 = 0x2
	KillTx               uint16 = 0x3
	SubmitFlipTx         uint16 = 0x4
	SubmitAnswersHashTx  uint16 = 0x5
	SubmitShortAnswersTx uint16 = 0x6
	SubmitLongAnswersTx  uint16 = 0x7
	EvidenceTx           uint16 = 0x8
	OnlineStatusTx       uint16 = 0x9
	KillInviteeTx        uint16 = 0xA
	ChangeGodAddressTx   uint16 = 0xB
	BurnTx               uint16 = 0xC
	ChangeProfileTx      uint16 = 0xD
	DeleteFlipTx         uint16 = 0xE
)
View Source
const (
	ReductionOne = 253
	ReductionTwo = 254
	Final        = 255
)

Variables

This section is empty.

Functions

func DeriveSha

func DeriveSha(list DerivableList) common.Hash

func Sender

func Sender(tx *Transaction) (common.Address, error)

Sender may cache the address, allowing it to be used regardless of signing method.

func SenderFlipKey

func SenderFlipKey(fk *PublicFlipKey) (common.Address, error)

Sender may cache the address, allowing it to be used regardless of signing method.

func SenderFlipKeyPubKey

func SenderFlipKeyPubKey(fk *PublicFlipKey) ([]byte, error)

func SenderFlipKeysPackage

func SenderFlipKeysPackage(fk *PrivateFlipKeysPackage) (common.Address, error)

Sender may cache the address, allowing it to be used regardless of signing method.

func SenderPubKey

func SenderPubKey(tx *Transaction) ([]byte, error)

Sender may cache the address, allowing it to be used regardless of signing method.

Types

type ActivityMonitor

type ActivityMonitor struct {
	UpdateDt time.Time
	Data     []*AddrActivity
}

type AddrActivity

type AddrActivity struct {
	Addr common.Address
	Time time.Time
}

type Answer

type Answer byte
const (
	None          Answer = 0
	Left          Answer = 1
	Right         Answer = 2
	Inappropriate Answer = 3
)

type Answers

type Answers struct {
	Bits       *big.Int
	FlipsCount uint
}

func NewAnswers

func NewAnswers(flipsCount uint) *Answers

func NewAnswersFromBits

func NewAnswersFromBits(flipsCount uint, bits []byte) *Answers

func (*Answers) Answer

func (a *Answers) Answer(flipIndex uint) (answer Answer, wrongWords bool)

func (*Answers) Bytes

func (a *Answers) Bytes() []byte

func (*Answers) Inappropriate

func (a *Answers) Inappropriate(flipIndex uint)

func (*Answers) Left

func (a *Answers) Left(flipIndex uint)

func (*Answers) Right

func (a *Answers) Right(flipIndex uint)

func (*Answers) WrongWords

func (a *Answers) WrongWords(flipIndex uint)

type AuthorResults

type AuthorResults struct {
	HasOneReportedFlip     bool
	HasOneNotQualifiedFlip bool
	AllFlipsNotQualified   bool
}

type BadAuthorReason

type BadAuthorReason = byte
const (
	NoQualifiedFlipsBadAuthor BadAuthorReason = 0
	QualifiedByNoneBadAuthor  BadAuthorReason = 1
	WrongWordsBadAuthor       BadAuthorReason = 2
)

type Block

type Block struct {
	Header *Header

	Body *Body
	// contains filtered or unexported fields
}

func (*Block) Hash

func (b *Block) Hash() common.Hash

func (*Block) Height

func (b *Block) Height() uint64

func (*Block) IdentityRoot

func (b *Block) IdentityRoot() common.Hash

func (*Block) IsEmpty

func (b *Block) IsEmpty() bool

func (*Block) Root

func (b *Block) Root() common.Hash

func (*Block) Seed

func (b *Block) Seed() Seed

type BlockBundle

type BlockBundle struct {
	Block *Block
	Cert  *BlockCert
}

type BlockCert

type BlockCert struct {
	Round      uint64
	Step       uint8
	VotedHash  common.Hash
	Signatures []*BlockCertSignature
}

func (*BlockCert) Empty

func (s *BlockCert) Empty() bool

type BlockCertSignature

type BlockCertSignature struct {
	TurnOffline bool
	Upgrade     uint16
	Signature   []byte
}

type BlockFlag

type BlockFlag uint32
const (
	IdentityUpdate BlockFlag = 1 << iota
	FlipLotteryStarted
	ShortSessionStarted
	LongSessionStarted
	AfterLongSessionStarted
	ValidationFinished
	Snapshot
	OfflinePropose
	OfflineCommit
)

func (BlockFlag) HasFlag

func (f BlockFlag) HasFlag(flag BlockFlag) bool

func (BlockFlag) UnsetFlag

func (f BlockFlag) UnsetFlag(flag BlockFlag) BlockFlag

type BlockProposal

type BlockProposal struct {
	*Block
	Signature []byte
}

func (*BlockProposal) IsValid

func (p *BlockProposal) IsValid() bool

type Body

type Body struct {
	Transactions []*Transaction `rlp:"nil"`
}

func (Body) Bytes

func (b Body) Bytes() []byte

func (*Body) FromBytes

func (b *Body) FromBytes(data []byte)

func (Body) IsEmpty

func (b Body) IsEmpty() bool

type BurntCoins

type BurntCoins struct {
	Address common.Address
	Key     string
	Amount  *big.Int
}

type DerivableList

type DerivableList interface {
	Len() int
	GetRlp(i int) []byte
}

type EmptyBlockHeader

type EmptyBlockHeader struct {
	ParentHash   common.Hash
	Height       uint64
	Root         common.Hash
	IdentityRoot common.Hash
	BlockSeed    Seed
	Time         *big.Int
	Flags        BlockFlag
}

func (*EmptyBlockHeader) Hash

func (h *EmptyBlockHeader) Hash() common.Hash

type Flip

type Flip struct {
	Tx          *Transaction
	PublicPart  []byte
	PrivatePart []byte
}

type FullBlockCert

type FullBlockCert struct {
	Votes []*Vote
}

func (*FullBlockCert) Compress

func (s *FullBlockCert) Compress() *BlockCert
type Header struct {
	EmptyBlockHeader *EmptyBlockHeader `rlp:"nil"`
	ProposedHeader   *ProposedHeader   `rlp:"nil"`
}

func (*Header) Coinbase

func (h *Header) Coinbase() common.Address

func (*Header) FeePerByte

func (h *Header) FeePerByte() *big.Int

func (*Header) Flags

func (h *Header) Flags() BlockFlag

func (*Header) Hash

func (h *Header) Hash() common.Hash

func (*Header) Height

func (h *Header) Height() uint64

func (*Header) IdentityRoot

func (h *Header) IdentityRoot() common.Hash

func (*Header) IpfsHash

func (h *Header) IpfsHash() []byte

func (*Header) OfflineAddr

func (h *Header) OfflineAddr() *common.Address

func (*Header) ParentHash

func (h *Header) ParentHash() common.Hash

func (*Header) Root

func (h *Header) Root() common.Hash

func (*Header) Seed

func (h *Header) Seed() Seed

func (*Header) Time

func (h *Header) Time() *big.Int

type Network

type Network = uint32

type NewEpochPayload

type NewEpochPayload struct {
	Identities []common.Address
}

func (NewEpochPayload) Bytes

func (p NewEpochPayload) Bytes() []byte

type PrivateFlipKeysPackage

type PrivateFlipKeysPackage struct {
	Data      []byte
	Epoch     uint16
	Signature []byte
	// contains filtered or unexported fields
}

func SignFlipKeysPackage

func SignFlipKeysPackage(fk *PrivateFlipKeysPackage, prv *ecdsa.PrivateKey) (*PrivateFlipKeysPackage, error)

SignFlipKey returns flip key signed with given private key

func (*PrivateFlipKeysPackage) Hash

func (*PrivateFlipKeysPackage) Hash128

func (k *PrivateFlipKeysPackage) Hash128() common.Hash128

type ProposedHeader

type ProposedHeader struct {
	ParentHash     common.Hash
	Height         uint64
	Time           *big.Int    `json:"timestamp"`
	TxHash         common.Hash // hash of tx hashes
	ProposerPubKey []byte
	Root           common.Hash // root of state tree
	IdentityRoot   common.Hash // root of approved identities tree
	Flags          BlockFlag
	IpfsHash       []byte          // ipfs hash of block body
	OfflineAddr    *common.Address `rlp:"nil"`
	TxBloom        []byte
	BlockSeed      Seed
	FeePerByte     *big.Int
	Upgrade        uint16
	SeedProof      []byte
}

func (*ProposedHeader) Hash

func (h *ProposedHeader) Hash() common.Hash

type PublicFlipKey

type PublicFlipKey struct {
	Key       []byte
	Signature []byte
	Epoch     uint16
	// contains filtered or unexported fields
}

func SignFlipKey

func SignFlipKey(fk *PublicFlipKey, prv *ecdsa.PrivateKey) (*PublicFlipKey, error)

SignFlipKey returns flip key signed with given private key

func (PublicFlipKey) Hash

func (k PublicFlipKey) Hash() common.Hash

type SavedTransaction

type SavedTransaction struct {
	Tx         *Transaction
	FeePerByte *big.Int
	BlockHash  common.Hash
	Timestamp  uint64
}

type Seed

type Seed [32]byte

func (Seed) Bytes

func (h Seed) Bytes() []byte

type SuccessfulInvite

type SuccessfulInvite struct {
	Age    uint16
	TxHash common.Hash
}

type Transaction

type Transaction struct {
	AccountNonce uint32
	Epoch        uint16
	Type         TxType
	To           *common.Address `rlp:"nil"`
	Amount       *big.Int        `json:"value"`
	MaxFee       *big.Int
	Tips         *big.Int
	Payload      []byte `rlp:"nil"       json:"input"`

	Signature []byte
	// contains filtered or unexported fields
}

func SignTx

func SignTx(tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error)

SignTx returns transaction signed with given private key

func (*Transaction) AmountOrZero

func (tx *Transaction) AmountOrZero() *big.Int

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Hash

func (*Transaction) MaxFeeOrZero

func (tx *Transaction) MaxFeeOrZero() *big.Int

func (*Transaction) Size

func (tx *Transaction) Size() int

func (*Transaction) TipsOrZero

func (tx *Transaction) TipsOrZero() *big.Int

type TransactionIndex

type TransactionIndex struct {
	BlockHash common.Hash
	// tx index in block's body
	Idx uint16
}

type Transactions

type Transactions []*Transaction

Transactions is a Transaction slice type for basic sorting.

func (Transactions) GetRlp

func (s Transactions) GetRlp(i int) []byte

GetRlp implements Rlpable and returns the i'th element of s in rlp.

func (Transactions) Len

func (s Transactions) Len() int

Len returns the length of s.

func (Transactions) Swap

func (s Transactions) Swap(i, j int)

Swap swaps the i'th and the j'th element in s.

type TxType

type TxType = uint16

type ValidationAuthors

type ValidationAuthors struct {
	BadAuthors    map[common.Address]BadAuthorReason
	GoodAuthors   map[common.Address]*ValidationResult
	AuthorResults map[common.Address]*AuthorResults
}

type ValidationResult

type ValidationResult struct {
	StrongFlipCids      [][]byte
	WeakFlipCids        [][]byte
	SuccessfulInvites   []*SuccessfulInvite
	PayInvitationReward bool
	Missed              bool
	SavedInvites        uint8
	NewIdentityState    uint8
}

type Vote

type Vote struct {
	Header    *VoteHeader
	Signature []byte
	// contains filtered or unexported fields
}

func (*Vote) Hash

func (v *Vote) Hash() common.Hash

func (*Vote) VoterAddr

func (v *Vote) VoterAddr() common.Address

type VoteHeader

type VoteHeader struct {
	Round       uint64
	Step        uint8
	ParentHash  common.Hash
	VotedHash   common.Hash
	TurnOffline bool
	Upgrade     uint16
}

func (*VoteHeader) SignatureHash

func (h *VoteHeader) SignatureHash() common.Hash

Jump to

Keyboard shortcuts

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