types

package
v0.26.8-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: LGPL-3.0 Imports: 14 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
	DeployContractTx     uint16 = 0xF
	CallContractTx       uint16 = 0x10
	TerminateContractTx  uint16 = 0x11
	DelegateTx           uint16 = 0x12
	UndelegateTx         uint16 = 0x13
	KillDelegatorTx      uint16 = 0x14
	StoreToIpfsTx        uint16 = 0x15
)
View Source
const (
	ReductionOne = 253
	ReductionTwo = 254
	Final        = 255

	MaxBlockGas = 3000 * 1024
)

Variables

View Source
var CeremonialTxs map[uint16]struct{}

Functions

func BlockProposalPubKey added in v0.21.0

func BlockProposalPubKey(proposal *BlockProposal) ([]byte, error)

func DeriveSha

func DeriveSha(list DerivableList) common.Hash

func IsValidLongSessionAnswers added in v0.26.7

func IsValidLongSessionAnswers(tx *Transaction) bool

func MarkAsValidLongSessionAnswers added in v0.26.7

func MarkAsValidLongSessionAnswers(tx *Transaction)

func ProofProposalPubKey added in v0.21.0

func ProofProposalPubKey(proposal *ProofProposal) ([]byte, error)

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 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
}

func (*ActivityMonitor) FromBytes added in v0.21.0

func (s *ActivityMonitor) FromBytes(data []byte) error

func (*ActivityMonitor) ToBytes added in v0.21.0

func (s *ActivityMonitor) ToBytes() ([]byte, error)

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
)

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, grade Grade)

func (*Answers) Bytes

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

func (*Answers) Grade added in v0.22.0

func (a *Answers) Grade(flipIndex uint, grade Grade)

func (*Answers) Left

func (a *Answers) Left(flipIndex uint)

func (*Answers) Right

func (a *Answers) Right(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) FromBytes added in v0.21.0

func (b *Block) FromBytes(data []byte) error

func (*Block) Hash

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

func (*Block) Hash128 added in v0.21.0

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

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) IsValid added in v0.21.0

func (b *Block) IsValid() bool

func (*Block) Root

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

func (*Block) Seed

func (b *Block) Seed() Seed

func (*Block) ToBytes added in v0.21.0

func (b *Block) ToBytes() ([]byte, error)

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

func (*BlockCert) FromBytes added in v0.21.0

func (s *BlockCert) FromBytes(data []byte) error

func (*BlockCert) FromProto added in v0.21.0

func (s *BlockCert) FromProto(protoObj *models.ProtoBlockCert) *BlockCert

func (*BlockCert) ToBytes added in v0.21.0

func (s *BlockCert) ToBytes() ([]byte, error)

func (*BlockCert) ToProto added in v0.21.0

func (s *BlockCert) ToProto() *models.ProtoBlockCert

type BlockCertSignature

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

type BlockFlag

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

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
	Proof     []byte
	// contains filtered or unexported fields
}

func (*BlockProposal) FromBytes added in v0.21.0

func (p *BlockProposal) FromBytes(data []byte) error

func (*BlockProposal) IsValid

func (p *BlockProposal) IsValid() bool

func (*BlockProposal) ToBytes added in v0.21.0

func (p *BlockProposal) ToBytes() ([]byte, error)

func (*BlockProposal) ToSignatureBytes added in v0.21.0

func (p *BlockProposal) ToSignatureBytes() ([]byte, error)

type Body

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

func (*Body) FromBytes

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

func (*Body) FromProto added in v0.21.0

func (b *Body) FromProto(protoBody *models.ProtoBlockBody) *Body

func (*Body) IsValid added in v0.21.0

func (b *Body) IsValid() bool

func (*Body) ToBytes added in v0.21.0

func (b *Body) ToBytes() []byte

func (*Body) ToProto added in v0.21.0

func (b *Body) ToProto() *models.ProtoBlockBody

type BurntCoins

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

func (*BurntCoins) FromBytes added in v0.21.0

func (s *BurntCoins) FromBytes(data []byte) error

func (*BurntCoins) ToBytes added in v0.21.0

func (s *BurntCoins) ToBytes() ([]byte, error)

type Candidate added in v0.22.0

type Candidate struct {
	Address          common.Address
	NewIdentityState uint8
}

type DerivableList

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

type EmptyBlockHeader

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

func (*EmptyBlockHeader) Hash

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

func (*EmptyBlockHeader) ToProto added in v0.21.0

type Flip

type Flip struct {
	Tx          *Transaction
	PublicPart  []byte
	PrivatePart []byte
	// contains filtered or unexported fields
}

func (*Flip) FromBytes added in v0.21.0

func (f *Flip) FromBytes(data []byte) error

func (*Flip) Hash128 added in v0.21.0

func (f *Flip) Hash128() common.Hash128

func (*Flip) IsValid added in v0.21.0

func (f *Flip) IsValid() bool

func (*Flip) ToBytes added in v0.21.0

func (f *Flip) ToBytes() ([]byte, error)

type FlipToReward added in v0.22.0

type FlipToReward struct {
	Cid   []byte
	Grade Grade
}

type FullBlockCert

type FullBlockCert struct {
	Votes []*Vote
}

func (*FullBlockCert) Compress

func (s *FullBlockCert) Compress() *BlockCert

type GenesisInfo added in v0.23.0

type GenesisInfo struct {
	// the genesis with highest height
	Genesis *Header
	// previous genesis or empty
	OldGenesis *Header
}

func (*GenesisInfo) EqualAny added in v0.23.0

func (gi *GenesisInfo) EqualAny(genesis common.Hash, oldGenesis *common.Hash) bool

type Grade added in v0.22.0

type Grade byte
const (
	GradeNone     Grade = 0
	GradeReported Grade = 1
	GradeD        Grade = 2
	GradeC        Grade = 3
	GradeB        Grade = 4
	GradeA        Grade = 5
)
type Header struct {
	EmptyBlockHeader *EmptyBlockHeader `rlp:"nil"`
	ProposedHeader   *ProposedHeader   `rlp:"nil"`
}

func (*Header) Coinbase

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

func (*Header) FeePerGas added in v0.22.0

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

func (*Header) Flags

func (h *Header) Flags() BlockFlag

func (*Header) FromBytes added in v0.21.0

func (h *Header) FromBytes(data []byte) error

func (*Header) FromProto added in v0.21.0

func (h *Header) FromProto(protoHeader *models.ProtoBlockHeader) *Header

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) IsValid added in v0.21.0

func (h *Header) IsValid() bool

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() int64

func (*Header) ToBytes added in v0.21.0

func (h *Header) ToBytes() ([]byte, error)

func (*Header) ToProto added in v0.21.0

func (h *Header) ToProto() *models.ProtoBlockHeader

type InviterValidationResult added in v0.20.0

type InviterValidationResult struct {
	SuccessfulInvites   []*SuccessfulInvite
	SavedInvites        uint8
	NewIdentityState    uint8
	PayInvitationReward bool
}

type Network

type Network = uint32

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) FromBytes added in v0.21.0

func (k *PrivateFlipKeysPackage) FromBytes(data []byte) error

func (*PrivateFlipKeysPackage) Hash128

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

func (*PrivateFlipKeysPackage) ToBytes added in v0.21.0

func (k *PrivateFlipKeysPackage) ToBytes() ([]byte, error)

func (*PrivateFlipKeysPackage) ToSignatureBytes added in v0.21.0

func (k *PrivateFlipKeysPackage) ToSignatureBytes() ([]byte, error)

type ProofProposal added in v0.21.0

type ProofProposal struct {
	Proof []byte
	Round uint64

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

func (*ProofProposal) FromBytes added in v0.21.0

func (p *ProofProposal) FromBytes(data []byte) error

func (*ProofProposal) Hash128 added in v0.21.0

func (p *ProofProposal) Hash128() common.Hash128

func (*ProofProposal) ToBytes added in v0.21.0

func (p *ProofProposal) ToBytes() ([]byte, error)

func (*ProofProposal) ToSignatureBytes added in v0.21.0

func (p *ProofProposal) ToSignatureBytes() ([]byte, error)

type ProposedHeader

type ProposedHeader struct {
	ParentHash     common.Hash
	Height         uint64
	Time           int64
	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
	FeePerGas      *big.Int
	Upgrade        uint32
	SeedProof      []byte
	TxReceiptsCid  []byte
}

func (*ProposedHeader) Hash

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

func (*ProposedHeader) ToProto added in v0.21.0

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) FromBytes added in v0.21.0

func (k *PublicFlipKey) FromBytes(data []byte) error

func (*PublicFlipKey) Hash

func (k *PublicFlipKey) Hash() common.Hash

func (*PublicFlipKey) ToBytes added in v0.21.0

func (k *PublicFlipKey) ToBytes() ([]byte, error)

func (*PublicFlipKey) ToSignatureBytes added in v0.21.0

func (k *PublicFlipKey) ToSignatureBytes() ([]byte, error)

type SavedEvent added in v0.22.0

type SavedEvent struct {
	Contract common.Address
	Event    string
	Args     [][]byte
}

func (*SavedEvent) FromBytes added in v0.22.0

func (i *SavedEvent) FromBytes(data []byte) error

func (*SavedEvent) ToBytes added in v0.22.0

func (i *SavedEvent) ToBytes() ([]byte, error)

type SavedTransaction

type SavedTransaction struct {
	Tx        *Transaction
	FeePerGas *big.Int
	BlockHash common.Hash
	Timestamp int64
}

func (*SavedTransaction) FromBytes added in v0.21.0

func (s *SavedTransaction) FromBytes(data []byte) error

func (*SavedTransaction) ToBytes added in v0.21.0

func (s *SavedTransaction) ToBytes() ([]byte, error)

type Seed

type Seed [32]byte

func BytesToSeed added in v0.21.0

func BytesToSeed(b []byte) Seed

func (Seed) Bytes

func (h Seed) Bytes() []byte

func (*Seed) SetBytes added in v0.21.0

func (h *Seed) SetBytes(b []byte)

type SuccessfulInvite

type SuccessfulInvite struct {
	Age         uint16
	TxHash      common.Hash
	EpochHeight uint32
}

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

	UseRlp bool `rlp:"-"`
	// 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) FromBytes added in v0.21.0

func (tx *Transaction) FromBytes(data []byte) error

func (*Transaction) FromProto added in v0.21.0

func (tx *Transaction) FromProto(protoTx *models.ProtoTransaction) *Transaction

func (*Transaction) Hash

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

func (*Transaction) Hash128 added in v0.21.0

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

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

func (*Transaction) ToBytes added in v0.21.0

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

func (*Transaction) ToProto added in v0.21.0

func (tx *Transaction) ToProto() *models.ProtoTransaction

func (*Transaction) ToSignatureBytes added in v0.21.0

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

type TransactionIndex

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

func (*TransactionIndex) FromBytes added in v0.21.0

func (i *TransactionIndex) FromBytes(data []byte) error

func (*TransactionIndex) ToBytes added in v0.21.0

func (i *TransactionIndex) ToBytes() ([]byte, error)

type Transactions

type Transactions []*Transaction

Transactions is a Transaction slice type for basic sorting.

func (Transactions) GetBytes added in v0.21.0

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

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 TxEvent added in v0.22.0

type TxEvent struct {
	EventName string
	Data      [][]byte
}

type TxReceipt added in v0.22.0

type TxReceipt struct {
	ContractAddress common.Address
	Success         bool
	GasUsed         uint64
	GasCost         *big.Int
	From            common.Address
	TxHash          common.Hash
	Error           error
	Events          []*TxEvent
	Method          string
}

func (*TxReceipt) FromBytes added in v0.22.0

func (r *TxReceipt) FromBytes(data []byte) error

func (*TxReceipt) FromProto added in v0.22.0

func (r *TxReceipt) FromProto(protoObj *models.ProtoTxReceipts_ProtoTxReceipt)

func (*TxReceipt) ToBytes added in v0.22.0

func (r *TxReceipt) ToBytes() ([]byte, error)

func (*TxReceipt) ToProto added in v0.22.0

type TxReceiptIndex added in v0.22.0

type TxReceiptIndex struct {
	ReceiptCid []byte
	// tx index in receipts
	Idx uint32
}

func (*TxReceiptIndex) FromBytes added in v0.22.0

func (i *TxReceiptIndex) FromBytes(data []byte) error

func (*TxReceiptIndex) ToBytes added in v0.22.0

func (i *TxReceiptIndex) ToBytes() ([]byte, error)

type TxReceipts added in v0.22.0

type TxReceipts []*TxReceipt

func (TxReceipts) FromBytes added in v0.22.0

func (txrs TxReceipts) FromBytes(data []byte) TxReceipts

func (TxReceipts) FromProto added in v0.22.0

func (txrs TxReceipts) FromProto(protoObj *models.ProtoTxReceipts) TxReceipts

func (TxReceipts) ToBytes added in v0.22.0

func (txrs TxReceipts) ToBytes() ([]byte, error)

type TxType

type TxType = uint16

type UpgradeVote added in v0.23.0

type UpgradeVote struct {
	Voter   common.Address
	Upgrade uint32
}

type UpgradeVotes added in v0.23.0

type UpgradeVotes struct {
	Dict map[common.Address]uint32
}

func NewUpgradeVotes added in v0.23.0

func NewUpgradeVotes() *UpgradeVotes

func (*UpgradeVotes) Add added in v0.23.0

func (uv *UpgradeVotes) Add(voter common.Address, upgrade uint32)

func (*UpgradeVotes) FromBytes added in v0.23.0

func (uv *UpgradeVotes) FromBytes(data []byte) error

func (*UpgradeVotes) Remove added in v0.23.0

func (uv *UpgradeVotes) Remove(addr common.Address)

func (*UpgradeVotes) ToBytes added in v0.23.0

func (uv *UpgradeVotes) ToBytes() ([]byte, error)

type ValidationResult

type ValidationResult struct {
	FlipsToReward    []*FlipToReward
	Missed           bool
	NewIdentityState uint8
}

type ValidationResults added in v0.20.0

type ValidationResults struct {
	BadAuthors              map[common.Address]BadAuthorReason
	GoodAuthors             map[common.Address]*ValidationResult
	AuthorResults           map[common.Address]*AuthorResults
	GoodInviters            map[common.Address]*InviterValidationResult
	ReportersToRewardByFlip map[int]map[common.Address]*Candidate
}

type Vote

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

func (*Vote) FromBytes added in v0.21.0

func (v *Vote) FromBytes(data []byte) error

func (*Vote) Hash

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

func (*Vote) Hash128 added in v0.21.0

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

func (*Vote) IsValid added in v0.21.0

func (v *Vote) IsValid() bool

func (*Vote) PubKey added in v0.26.6

func (v *Vote) PubKey() ([]byte, error)

func (*Vote) ToBytes added in v0.21.0

func (v *Vote) ToBytes() ([]byte, error)

func (*Vote) ToSignatureBytes added in v0.21.0

func (v *Vote) ToSignatureBytes() ([]byte, error)

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     uint32
}

Jump to

Keyboard shortcuts

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