Documentation ¶
Index ¶
- Variables
- func CalNonce(block *Block)
- func CalPriority(hash common.Hash, reputation uint64) (uint64, error)
- func CalReputation(nonce uint64, stake *big.Int, performance uint64) (uint64, error)
- func CheckAddressIsCurrentVerifier(address common.Address, verifiers []common.Address) bool
- func CheckAddressIsVerifierBootNode(address common.Address) bool
- func CreateKey() (*ecdsa.PrivateKey, *ecdsa.PrivateKey)
- func DeriveSha(list DerivableList) common.Hash
- func Elem(x float64, epsilon1 float64, epsilon2 float64, epsilon3 float64) (float64, error)
- func HashLevel(hash common.Hash, maxHash common.Hash) int
- func IsIgnoreDifficultyValidation() bool
- func LastPeriodBlockNum(curBlockNum uint64) uint64
- func NewCalNewWorkDiff(preSpanBlock, lastNormalBlock AbstractBlock, currentBlockNumber uint64) common.Difficulty
- func RunWorkMap(task iblt.Operation, txs []*Transaction) error
- func SetBlockJsonHandler(h BlockJsonHandler)
- func SetBlockRlpHandler(h BlockRlpHandler)
- type AbsTransactions
- type AbstractBlock
- type AbstractBody
- type AbstractHeader
- type AbstractTransaction
- type AbstractVerification
- type BftBlockBody
- type Block
- func (b *Block) Body() AbstractBody
- func (b *Block) CoinBase() *big.Int
- func (b *Block) CoinBaseAddress() common.Address
- func (b *Block) DecodeRLP(s *rlp.Stream) error
- func (b *Block) Difficulty() common.Difficulty
- func (b *Block) EncodeRLP(w io.Writer) error
- func (b *Block) EncodeRlpToBytes() ([]byte, error)
- func (b *Block) EncodeToIBLT() *iblt.Graphene
- func (b *Block) FormatForRpc() interface{}
- func (b *Block) GetAbsTransactions() []AbstractTransaction
- func (b *Block) GetBlockTxsBloom() *iblt.Bloom
- func (b *Block) GetBloom() iblt.Bloom
- func (b Block) GetCoinbase() *big.Int
- func (b *Block) GetEiBloomBlockData(reqEstimator *iblt.HybridEstimator) *BloomBlockData
- func (b *Block) GetHeader() AbstractHeader
- func (b *Block) GetInterLinkRoot() (root common.Hash)
- func (b *Block) GetInterlinks() InterLink
- func (b *Block) GetRegisterRoot() common.Hash
- func (b Block) GetTransactionFees() *big.Int
- func (b *Block) GetTransactions() []*Transaction
- func (b *Block) GetVerifications() (result []AbstractVerification)
- func (b *Block) Hash() common.Hash
- func (b *Block) Header() AbstractHeader
- func (b *Block) IsSpecial() bool
- func (b Block) MarshalJSON() ([]byte, error)
- func (b *Block) Nonce() common.BlockNonce
- func (b *Block) Number() uint64
- func (b *Block) PreHash() common.Hash
- func (b *Block) RefreshHashCache() common.Hash
- func (b *Block) Seed() common.Hash
- func (b *Block) SetDifficulty(diff common.Difficulty)
- func (b *Block) SetInterLinkRoot(root common.Hash)
- func (b *Block) SetInterLinks(inter InterLink)
- func (b *Block) SetNonce(nonce common.BlockNonce)
- func (b *Block) SetRegisterRoot(root common.Hash)
- func (b *Block) SetStateRoot(root common.Hash)
- func (b *Block) SetTimeStamp(timeStamp *big.Int)
- func (b *Block) SetVerifications(vs []AbstractVerification)
- func (b *Block) StateRoot() common.Hash
- func (b *Block) String() string
- func (b *Block) Timestamp() *big.Int
- func (b *Block) Transaction(hash common.Hash) *Transaction
- func (b *Block) TxCount() int
- func (b Block) TxIterator(cb func(int, AbstractTransaction) error) error
- func (b *Block) TxRoot() common.Hash
- func (b *Block) UnmarshalJSON(input []byte) error
- func (b *Block) VerificationRoot() common.Hash
- func (b *Block) Verifications() []AbstractVerification
- func (b Block) VersIterator(cb func(int, AbstractVerification, AbstractBlock) error) error
- func (b *Block) Version() uint64
- type BlockBy
- type BlockDecoder
- type BlockJsonHandler
- type BlockRlpHandler
- type Blocks
- type BloomBlockData
- type Body
- type DerivableList
- type DeriveShaInterface
- type Header
- func (h *Header) CoinBaseAddress() common.Address
- func (h *Header) DuplicateHeader() AbstractHeader
- func (h *Header) EncodeRlpToBytes() ([]byte, error)
- func (bh *Header) GetDifficulty() common.Difficulty
- func (h *Header) GetInterLinkRoot() common.Hash
- func (h *Header) GetMinerPubKey() *ecdsa.PublicKey
- func (h *Header) GetNumber() uint64
- func (h *Header) GetPreHash() common.Hash
- func (h *Header) GetProof() []byte
- func (h *Header) GetRegisterRoot() common.Hash
- func (h *Header) GetSeed() common.Hash
- func (h *Header) GetStateRoot() common.Hash
- func (h *Header) Hash() common.Hash
- func (h *Header) HashWithoutNonce() common.Hash
- func (h *Header) IsEqual(header AbstractHeader) bool
- func (h Header) MarshalJSON() ([]byte, error)
- func (h Header) RlpBlockWithoutNonce() (rb []byte)
- func (h *Header) SetRegisterRoot(root common.Hash)
- func (h *Header) SetVerificationRoot(newRoot common.Hash)
- func (h *Header) Size() common.StorageSize
- func (h *Header) String() string
- func (h *Header) UnmarshalJSON(input []byte) error
- type InterLink
- type MapWorkHybridEstimator
- type MapWorkInvBloom
- type MercurySigner
- func (fs MercurySigner) Equal(s2 Signer) bool
- func (fs MercurySigner) GetSender(tx *Transaction) (common.Address, error)
- func (fs MercurySigner) GetSenderPublicKey(tx *Transaction) (*ecdsa.PublicKey, error)
- func (fs MercurySigner) GetSignHash(rtx *Transaction) (common.Hash, error)
- func (fs MercurySigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
- type PBFTBlockJsonHandler
- type PBFTBlockRlpHandler
- type PBFTBody
- type PriofityCalculator
- type Proofs
- type RpcTransaction
- type SignHashFunc
- type Signer
- type TestCalculator
- type Transaction
- func CreateRawClaimTx(nonce uint64, key []byte, amount *big.Int, fee *big.Int, alice common.Address, ...) *Transaction
- func CreateRawLockTx(nonce uint64, lock common.Hash, time *big.Int, amount *big.Int, fee *big.Int, ...) *Transaction
- func CreateRawRefundTx(nonce uint64, amount *big.Int, fee *big.Int, alice common.Address, ...) *Transaction
- func CreateSignedTx(nonce uint64, amount *big.Int) *Transaction
- func CreateSignedTxList(n int) []*Transaction
- func NewCancelTransaction(nonce uint64, fee *big.Int) *Transaction
- func NewContractCreation(nonce uint64, amount *big.Int, fee *big.Int, data []byte) *Transaction
- func NewEvidenceTransaction(nonce uint64, fee *big.Int, target *common.Address, voteA *VoteMsg, ...) *Transaction
- func NewRegisterTransaction(nonce uint64, amount *big.Int, fee *big.Int) *Transaction
- func NewTransaction(nonce uint64, to common.Address, amount *big.Int, fee *big.Int, data []byte) *Transaction
- func NewUnNormalTransaction(nonce uint64, amount *big.Int, fee *big.Int) *Transaction
- func NewUnStakeTransaction(nonce uint64, fee *big.Int) *Transaction
- func (tx *Transaction) Amount() *big.Int
- func (tx *Transaction) CalTxId() common.Hash
- func (tx Transaction) ChainId() *big.Int
- func (tx *Transaction) Cost() *big.Int
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) EncodeRlpToBytes() ([]byte, error)
- func (tx *Transaction) EstimateFee() *big.Int
- func (tx *Transaction) ExtraData() []byte
- func (tx *Transaction) Fee() *big.Int
- func (tx Transaction) GetSigner() Signer
- func (tx Transaction) GetType() common.TxType
- func (tx *Transaction) HashKey() []byte
- func (tx *Transaction) HashLock() *common.Hash
- func (tx Transaction) IsEqual(tempTx Transaction) bool
- func (tx Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int)
- func (tx *Transaction) Sender(signer Signer) (common.Address, error)
- func (tx *Transaction) SenderPublicKey(signer Signer) (*ecdsa.PublicKey, error)
- func (tx *Transaction) SignTx(priKey *ecdsa.PrivateKey, s Signer) (*Transaction, error)
- func (tx *Transaction) Size() common.StorageSize
- func (tx Transaction) String() string
- func (tx *Transaction) TimeLock() *big.Int
- func (tx *Transaction) To() *common.Address
- func (tx *Transaction) UnmarshalJSON(input []byte) error
- type TransactionBuilder
- type TransactionBy
- type TransactionJSON
- type TransactionRLP
- type Transactions
- type TransactionsByFeeAndNonce
- type TxByFee
- type TxCacher
- type TxCacherRequest
- type Verifications
- type VoteMsg
- func (v VoteMsg) GetAddress() common.Address
- func (v VoteMsg) GetBlockHash() string
- func (v VoteMsg) GetBlockId() common.Hash
- func (v VoteMsg) GetHeight() uint64
- func (v VoteMsg) GetRound() uint64
- func (v VoteMsg) GetType() VoteMsgType
- func (v VoteMsg) GetViewID() uint64
- func (v VoteMsg) HaltedVoteValid(verifiers []common.Address) error
- func (v VoteMsg) Hash() common.Hash
- func (v VoteMsg) String() string
- func (v VoteMsg) Valid() error
- type VoteMsgType
- type WitMsg
Constants ¶
This section is empty.
Variables ¶
var ( EmptyTxRoot = DeriveSha(Transactions{}) EmptyVerfRoot = DeriveSha(Verifications{}) EmptyInterRoot = DeriveSha(InterLink{}) )
var ( DefaultBlockBloomConfig = iblt.NewBloomConfig(8, 4) DefaultInvBloomConfig = iblt.NewInvBloomConfig(1<<12, 4) DefaultTxs = 100 )
var ( DefaultPriorityCalculator = getCalculator() StakeValMin = float64(100) )
var ( AddressIsNotVerifierBootNode = errors.New("the Address isn't verifier boot node") VoteRecoverAddrError = errors.New("the aliveVerifierVote recover Address is invalid") AddressIsNotCurrentVerifier = errors.New("the recover Address isn't current verifier") WrongVoteType = errors.New("wrong vote type") )
var ( // 4096 blocks in a cycle , if the cycle is too short, // will lead to occasional large deviations which will affect the whole too much. BlockCountOfPeriod uint64 )
var (
ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
var IgnoreDifficultyValidation = false
Whether the tag skips the difficulty value validation in the case of unit testing is not skipped by default. Validation must be performed under non-test conditions. The variable needs to be changed to true in the test to skip validation
Functions ¶
func CalReputation ¶
func CreateKey ¶
func CreateKey() (*ecdsa.PrivateKey, *ecdsa.PrivateKey)
func DeriveSha ¶
func DeriveSha(list DerivableList) common.Hash
func IsIgnoreDifficultyValidation ¶
func IsIgnoreDifficultyValidation() bool
func LastPeriodBlockNum ¶
Getting the latest cycle's block num, Return the same num in the same cycle to ensure that caching is available new block num - 1 = cur block num
func NewCalNewWorkDiff ¶
func NewCalNewWorkDiff(preSpanBlock, lastNormalBlock AbstractBlock, currentBlockNumber uint64) common.Difficulty
there are empty blocks in a Recent block, so we need to consider empty blocks and use a new method.
func RunWorkMap ¶
func RunWorkMap(task iblt.Operation, txs []*Transaction) error
Input TXs-list and Algorithms for Goroutine
func SetBlockJsonHandler ¶
func SetBlockJsonHandler(h BlockJsonHandler)
Types ¶
type AbsTransactions ¶
type AbsTransactions []AbstractTransaction
merkle root for AbstractTransaction
func (AbsTransactions) GetKey ¶
func (verf AbsTransactions) GetKey(i int) []byte
func (AbsTransactions) GetRlp ¶
func (verf AbsTransactions) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp.
type AbstractBlock ¶
type AbstractBlock interface { Version() uint64 Number() uint64 IsSpecial() bool Difficulty() common.Difficulty PreHash() common.Hash Seed() common.Hash RefreshHashCache() common.Hash Hash() common.Hash EncodeRlpToBytes() ([]byte, error) TxIterator(cb func(int, AbstractTransaction) error) error TxRoot() common.Hash Timestamp() *big.Int Nonce() common.BlockNonce StateRoot() common.Hash SetStateRoot(root common.Hash) GetRegisterRoot() common.Hash SetRegisterRoot(root common.Hash) FormatForRpc() interface{} SetNonce(nonce common.BlockNonce) CoinBaseAddress() common.Address GetTransactionFees() *big.Int CoinBase() *big.Int GetTransactions() []*Transaction GetInterlinks() InterLink SetInterLinkRoot(root common.Hash) GetInterLinkRoot() (root common.Hash) SetInterLinks(inter InterLink) GetAbsTransactions() []AbstractTransaction GetBloom() iblt.Bloom Header() AbstractHeader Body() AbstractBody TxCount() int GetEiBloomBlockData(reqEstimator *iblt.HybridEstimator) *BloomBlockData GetBlockTxsBloom() *iblt.Bloom VerificationRoot() common.Hash SetVerifications(vs []AbstractVerification) VersIterator(func(int, AbstractVerification, AbstractBlock) error) error GetVerifications() []AbstractVerification }
type AbstractBody ¶
type AbstractHeader ¶
type AbstractHeader interface { GetNumber() uint64 Hash() common.Hash GetPreHash() common.Hash EncodeRlpToBytes() ([]byte, error) GetStateRoot() common.Hash CoinBaseAddress() common.Address DuplicateHeader() AbstractHeader IsEqual(header AbstractHeader) bool SetVerificationRoot(newRoot common.Hash) GetSeed() common.Hash GetProof() []byte GetMinerPubKey() *ecdsa.PublicKey GetInterLinkRoot() common.Hash GetDifficulty() common.Difficulty GetRegisterRoot() common.Hash SetRegisterRoot(root common.Hash) }
type AbstractTransaction ¶
type AbstractTransaction interface { Size() common.StorageSize Amount() *big.Int CalTxId() common.Hash Fee() *big.Int Nonce() uint64 To() *common.Address Sender(singer Signer) (common.Address, error) SenderPublicKey(signer Signer) (*ecdsa.PublicKey, error) EncodeRlpToBytes() ([]byte, error) GetSigner() Signer GetType() common.TxType ExtraData() []byte Cost() *big.Int EstimateFee() *big.Int }
func TxDifference ¶
func TxDifference(a, b []AbstractTransaction) []AbstractTransaction
TxDifference returns a new set which is the difference between a and b.
type AbstractVerification ¶
type BftBlockBody ¶
type BftBlockBody struct { Txs []*Transaction `json:"transactions"` Vers []*VoteMsg `json:"commit_msg"` Inters InterLink `json:"interlinks"` }
Check whether the signature is correct and match the corresponding address to exclude the case that one person votes twice
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func NewBlock ¶
func NewBlock(header *Header, txs []*Transaction, msgs []AbstractVerification) *Block
func NewBlockWithLink ¶
func NewBlockWithLink(header *Header, txs []*Transaction, msgs []AbstractVerification, preLink InterLink) *Block
func (*Block) Body ¶
func (b *Block) Body() AbstractBody
func (*Block) CoinBaseAddress ¶
func (*Block) Difficulty ¶
func (b *Block) Difficulty() common.Difficulty
func (*Block) EncodeRlpToBytes ¶
func (*Block) EncodeToIBLT ¶
func (b *Block) EncodeToIBLT() *iblt.Graphene
EncodeToIBLT returns an Invertible Bloom LookUp Table from the block's all transactions
func (*Block) FormatForRpc ¶
func (b *Block) FormatForRpc() interface{}
func (*Block) GetAbsTransactions ¶
func (b *Block) GetAbsTransactions() []AbstractTransaction
func (Block) GetCoinbase ¶
func (*Block) GetEiBloomBlockData ¶
func (b *Block) GetEiBloomBlockData(reqEstimator *iblt.HybridEstimator) *BloomBlockData
func (*Block) GetHeader ¶
func (b *Block) GetHeader() AbstractHeader
func (*Block) GetInterLinkRoot ¶
func (*Block) GetInterlinks ¶
func (*Block) GetRegisterRoot ¶
func (Block) GetTransactionFees ¶
func (*Block) GetTransactions ¶
func (b *Block) GetTransactions() []*Transaction
func (*Block) GetVerifications ¶
func (b *Block) GetVerifications() (result []AbstractVerification)
func (*Block) Header ¶
func (b *Block) Header() AbstractHeader
func (Block) MarshalJSON ¶
func (*Block) Nonce ¶
func (b *Block) Nonce() common.BlockNonce
func (*Block) RefreshHashCache ¶
func (*Block) SetDifficulty ¶
func (b *Block) SetDifficulty(diff common.Difficulty)
func (*Block) SetInterLinkRoot ¶
func (*Block) SetInterLinks ¶
func (*Block) SetNonce ¶
func (b *Block) SetNonce(nonce common.BlockNonce)
func (*Block) SetRegisterRoot ¶
func (*Block) SetStateRoot ¶
func (*Block) SetTimeStamp ¶
func (*Block) SetVerifications ¶
func (b *Block) SetVerifications(vs []AbstractVerification)
func (*Block) Transaction ¶
func (b *Block) Transaction(hash common.Hash) *Transaction
func (Block) TxIterator ¶
func (b Block) TxIterator(cb func(int, AbstractTransaction) error) error
func (*Block) UnmarshalJSON ¶
func (*Block) VerificationRoot ¶
func (*Block) Verifications ¶
func (b *Block) Verifications() []AbstractVerification
func (Block) VersIterator ¶
func (b Block) VersIterator(cb func(int, AbstractVerification, AbstractBlock) error) error
type BlockDecoder ¶
type BlockDecoder interface { DecodeRlpHeaderFromBytes(data []byte) (AbstractHeader, error) DecodeRlpBodyFromBytes(data []byte) (AbstractBody, error) DecodeRlpBlockFromHeaderAndBodyBytes(headerB []byte, bodyB []byte) (AbstractBlock, error) DecodeRlpBlockFromBytes(data []byte) (AbstractBlock, error) DecodeRlpTransactionFromBytes(data []byte) (AbstractTransaction, error) }
func MakeDefaultBlockDecoder ¶
func MakeDefaultBlockDecoder() BlockDecoder
type BlockJsonHandler ¶
only have interface use diff rlp handler
type BlockRlpHandler ¶
only have interface use diff rlp handler
type BloomBlockData ¶
type BloomBlockData struct { Header *Header BloomRLP []byte // pre height vs PreVerification []AbstractVerification // cur height vs CurVerification []AbstractVerification //interlins Interlinks InterLink }
func (*BloomBlockData) EiRecoverToBlock ¶
func (data *BloomBlockData) EiRecoverToBlock(txPoolMap map[common.Hash]AbstractTransaction) (block *Block, err error)
type Body ¶
type Body struct { Txs []*Transaction `json:"transactions"` Vers []AbstractVerification `json:"commit_msg"` Inters InterLink `json:"interlinks"` }
swagger:response Body
func (*Body) EncodeRlpToBytes ¶
func (*Body) GetInterLinks ¶
func (*Body) GetTxByIndex ¶
func (b *Body) GetTxByIndex(i int) AbstractTransaction
func (*Body) GetTxsSize ¶
func (*Body) UnmarshalJSON ¶
type DerivableList ¶
type DeriveShaInterface ¶
type DeriveShaInterface interface {
DeriveSha(list DerivableList) common.Hash
}
type Header ¶
type Header struct { // version of this block generated Version uint64 `json:"version" gencodec:"required"` // the height of the block Number uint64 `json:"number" gencodec:"required"` // used for VRF Seed common.Hash `json:"seed" gencodec:"required"` // seed proof Proof []byte `json:"proof" gencodec:"required"` // miner public key MinerPubKey []byte `json:"miner_pub_key" gencodec:"required"` //Previous block hash PreHash common.Hash `json:"pre_hash" gencodec:"required"` // difficulty for this block Diff common.Difficulty `json:"diff" gencodec:"required"` // timestamp for this block TimeStamp *big.Int `json:"timestamp" gencodec:"required"` // the address of the miner who mined this block CoinBase common.Address `json:"coinbase" gencodec:"required"` // nonce needed to be mined by the miner Nonce common.BlockNonce `json:"nonce" gencodec:"required"` //todo add bloom filter for logs or txs Bloom *iblt.Bloom `json:"Bloom" gencodec:"required"` // MPT trie root for transaction TransactionRoot common.Hash `json:"txs_root" gencodec:"required"` // MPT trie root for accounts state //todo if we want to put normal accounts and contract accounts into different tree we can generate two MPT trie for them StateRoot common.Hash `json:"state_root" gencodec:"required"` // MPT trie root for committed message VerificationRoot common.Hash `json:"verification_root" gencodec:"required"` // MPT trie root for interlink message InterlinkRoot common.Hash `json:"interlink_root" gencodec:"required"` // MPT trie root for register RegisterRoot common.Hash `json:"register_root" gencodec:"required"` }
func CopyHeader ¶
CopyHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func (*Header) CoinBaseAddress ¶
func (*Header) DuplicateHeader ¶
func (h *Header) DuplicateHeader() AbstractHeader
func (*Header) EncodeRlpToBytes ¶
func (*Header) GetDifficulty ¶
func (bh *Header) GetDifficulty() common.Difficulty
func (*Header) GetInterLinkRoot ¶
func (*Header) GetMinerPubKey ¶
func (*Header) GetPreHash ¶
func (*Header) GetRegisterRoot ¶
func (*Header) GetStateRoot ¶
func (*Header) HashWithoutNonce ¶
the nonce is not comprised to calculate the hash value
func (*Header) IsEqual ¶
func (h *Header) IsEqual(header AbstractHeader) bool
func (Header) MarshalJSON ¶
func (Header) RlpBlockWithoutNonce ¶
func (*Header) SetRegisterRoot ¶
func (*Header) SetVerificationRoot ¶
func (*Header) UnmarshalJSON ¶
type InterLink ¶
func NewInterLink ¶
func NewInterLink(preBlockLinks InterLink, curBlock AbstractBlock) InterLink
assuming genesis blocks level is 0,other level,relative to the paper description, move one layer as a whole.
type MapWorkHybridEstimator ¶
type MapWorkHybridEstimator struct {
// contains filtered or unexported fields
}
func (MapWorkHybridEstimator) DoTask ¶
func (estimator MapWorkHybridEstimator) DoTask(i interface{}) interface{}
type MapWorkInvBloom ¶
type MapWorkInvBloom struct {
// contains filtered or unexported fields
}
func (MapWorkInvBloom) DoTask ¶
func (bloom MapWorkInvBloom) DoTask(i interface{}) interface{}
type MercurySigner ¶
type MercurySigner struct {
// contains filtered or unexported fields
}
func NewMercurySigner ¶
func NewMercurySigner(chainId *big.Int) MercurySigner
func (MercurySigner) Equal ¶
func (fs MercurySigner) Equal(s2 Signer) bool
func (MercurySigner) GetSender ¶
func (fs MercurySigner) GetSender(tx *Transaction) (common.Address, error)
func (MercurySigner) GetSenderPublicKey ¶
func (fs MercurySigner) GetSenderPublicKey(tx *Transaction) (*ecdsa.PublicKey, error)
func (MercurySigner) GetSignHash ¶
func (fs MercurySigner) GetSignHash(rtx *Transaction) (common.Hash, error)
GetSignHash will return the VRFHash of the transaction with have the raw transaction data and chainId
func (MercurySigner) SignatureValues ¶
func (fs MercurySigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type PBFTBlockJsonHandler ¶
type PBFTBlockJsonHandler struct{}
func (*PBFTBlockJsonHandler) DecodeBody ¶
func (h *PBFTBlockJsonHandler) DecodeBody(to *Body, input []byte) error
type PBFTBlockRlpHandler ¶
type PBFTBlockRlpHandler struct{}
func (*PBFTBlockRlpHandler) DecodeBody ¶
func (h *PBFTBlockRlpHandler) DecodeBody(to *Body, s *rlp.Stream) error
type PBFTBody ¶
type PBFTBody struct { Txs []*Transaction `json:"transactions"` Vers []*VoteMsg `json:"commit_msg"` Inters InterLink `json:"interlinks"` }
type PriofityCalculator ¶
type RpcTransaction ¶
type SignHashFunc ¶
type Signer ¶
type Signer interface { // Sender returns the sender address of the transaction. GetSender(tx *Transaction) (common.Address, error) //Get Sender Public Key GetSenderPublicKey(tx *Transaction) (*ecdsa.PublicKey, error) // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) // Hash returns the VRFHash to be signed. GetSignHash(rtx *Transaction) (common.Hash, error) // Equal returns true if the given signer is the same as the receiver. Equal(Signer) bool }
signer define different kind of method handling signature
func MakeSigner ¶
todo set signer config
type TestCalculator ¶
type TestCalculator struct { }
func (TestCalculator) GetElectPriority ¶
func (tc TestCalculator) GetElectPriority(hash common.Hash, nonce uint64, stake *big.Int, performance uint64) (uint64, error)
hash means luck which calculate by block seed and address
func (TestCalculator) GetReputation ¶
func (tc TestCalculator) GetReputation(nonce uint64, stake *big.Int, performance uint64) (uint64, error)
acquire reputation value
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func CreateRawClaimTx ¶
func CreateRawLockTx ¶
func CreateRawRefundTx ¶
func CreateSignedTx ¶
func CreateSignedTx(nonce uint64, amount *big.Int) *Transaction
func CreateSignedTxList ¶
func CreateSignedTxList(n int) []*Transaction
func NewCancelTransaction ¶
func NewCancelTransaction(nonce uint64, fee *big.Int) *Transaction
func NewContractCreation ¶
func NewEvidenceTransaction ¶
func NewRegisterTransaction ¶
Name CalledBy Parameters Return
func NewTransaction ¶
func NewUnNormalTransaction ¶
func NewUnStakeTransaction ¶
func NewUnStakeTransaction(nonce uint64, fee *big.Int) *Transaction
func (*Transaction) Amount ¶
func (tx *Transaction) Amount() *big.Int
func (Transaction) ChainId ¶
func (tx Transaction) ChainId() *big.Int
func (*Transaction) DecodeRLP ¶
func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) EncodeRlpToBytes ¶
func (tx *Transaction) EncodeRlpToBytes() ([]byte, error)
func (*Transaction) EstimateFee ¶
func (tx *Transaction) EstimateFee() *big.Int
func (*Transaction) ExtraData ¶
func (tx *Transaction) ExtraData() []byte
func (*Transaction) Fee ¶
func (tx *Transaction) Fee() *big.Int
func (Transaction) GetSigner ¶
func (tx Transaction) GetSigner() Signer
todo: currently use default signer ,later need get a way to determine the signer from the tx itself.
func (Transaction) GetType ¶
func (tx Transaction) GetType() common.TxType
func (*Transaction) HashKey ¶
func (tx *Transaction) HashKey() []byte
func (*Transaction) HashLock ¶
func (tx *Transaction) HashLock() *common.Hash
func (tx *Transaction) Version() uint64 { return tx.data.Version }
func (Transaction) IsEqual ¶
func (tx Transaction) IsEqual(tempTx Transaction) bool
func (Transaction) MarshalJSON ¶
func (tx Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() uint64
func (*Transaction) RawSignatureValues ¶
func (*Transaction) SenderPublicKey ¶
func (tx *Transaction) SenderPublicKey(signer Signer) (*ecdsa.PublicKey, error)
func (*Transaction) SignTx ¶
func (tx *Transaction) SignTx(priKey *ecdsa.PrivateKey, s Signer) (*Transaction, error)
func (*Transaction) Size ¶
func (tx *Transaction) Size() common.StorageSize
func (Transaction) String ¶
func (tx Transaction) String() string
func (*Transaction) TimeLock ¶
func (tx *Transaction) TimeLock() *big.Int
func (*Transaction) To ¶
func (tx *Transaction) To() *common.Address
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(input []byte) error
type TransactionBuilder ¶
type TransactionBuilder struct {
// contains filtered or unexported fields
}
func (*TransactionBuilder) NewNormalTransaction ¶
type TransactionBy ¶
func (TransactionBy) Sort ¶
func (self TransactionBy) Sort(blocks Blocks)
type TransactionJSON ¶
type TransactionJSON struct { TxData txData Wit witness }
type TransactionRLP ¶
type TransactionRLP struct { Txdata txData Wit witness }
type Transactions ¶
type Transactions []*Transaction
Transactions is a Transaction slice type for basic sorting.
func (Transactions) GetKey ¶
func (ss Transactions) GetKey(i int) []byte
func (Transactions) GetRlp ¶
func (ss Transactions) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp.
func (Transactions) Less ¶
func (ss Transactions) Less(i, j int) bool
func (Transactions) String ¶
func (ss Transactions) String() string
func (Transactions) Swap ¶
func (ss Transactions) Swap(i, j int)
Swap swaps the i'th and the j'th element in s.
type TransactionsByFeeAndNonce ¶
type TransactionsByFeeAndNonce struct {
// contains filtered or unexported fields
}
TransactionsByPriceAndNonce represents a set of transactions that can return transactions in a profit-maximizing sorted order, while supporting removing entire batches of transactions for non-executable accounts.
func NewTransactionsByFeeAndNonce ¶
func NewTransactionsByFeeAndNonce(signer Signer, txs map[common.Address][]AbstractTransaction) *TransactionsByFeeAndNonce
NewTransactionsByPriceAndNonce creates a transaction set that can retrieve price sorted transactions in a nonce-honouring way.
Note, the input map is reowned so the caller should not interact any more with if after providing it to the constructor. TODO errors will occur if all transactions are deleted
func (*TransactionsByFeeAndNonce) Peek ¶
func (t *TransactionsByFeeAndNonce) Peek() AbstractTransaction
Peek returns the next transaction by price.
func (*TransactionsByFeeAndNonce) Pop ¶
func (t *TransactionsByFeeAndNonce) Pop()
Pop removes the best transaction, *not* replacing it with the next one from the same account. This should be used when a transaction cannot be executed and hence all subsequent ones should be discarded from the same account.
func (*TransactionsByFeeAndNonce) Shift ¶
func (t *TransactionsByFeeAndNonce) Shift()
Shift replaces the current best head with the next one from the same account.
type TxByFee ¶
type TxByFee []AbstractTransaction
TxByPrice implements both the sort and the heap interface, making it useful for all at once sorting as well as individually adding and removing elements.
type TxCacher ¶
type TxCacher struct {
// contains filtered or unexported fields
}
txCacher is a helper structure to concurrently recover transaction id from digital signatures on background threads.
func NewTxCacher ¶
NewTxCacher creates a new transaction id background cacher and starts as many processing goroutines as allowed by the GOMAXPROCS on construction.
func (*TxCacher) StopTxCacher ¶
func (cacher *TxCacher) StopTxCacher()
func (*TxCacher) TxRecover ¶
func (cacher *TxCacher) TxRecover(txs []AbstractTransaction)
TxRecover recovers the id from a batch of transactions and caches them back into the same data structures. There is no validation being done, nor any reaction to invalid signatures. That is up to calling code later.
type TxCacherRequest ¶
type TxCacherRequest struct {
// contains filtered or unexported fields
}
type Verifications ¶
type Verifications []AbstractVerification
merkle root for AbstractVerification
func (Verifications) GetKey ¶
func (verf Verifications) GetKey(i int) []byte
func (Verifications) GetRlp ¶
func (verf Verifications) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp.
type VoteMsg ¶
type VoteMsg struct { Height uint64 Round uint64 BlockID common.Hash VoteType VoteMsgType Timestamp time.Time Witness *WitMsg }
func CreateSignedVote ¶
func CreateSignedVote(height, round uint64, blockId common.Hash, voteType VoteMsgType) *VoteMsg
func NewVoteMsg ¶
func NewVoteMsg(height, round uint64, blockID common.Hash, voteType VoteMsgType) *VoteMsg
func NewVoteMsgWithSign ¶
func NewVoteMsgWithSign(height, round uint64, blockID common.Hash, voteType VoteMsgType, signFunc SignHashFunc, signAddress common.Address) (*VoteMsg, error)
Create a new signature VoteMsg
func (VoteMsg) GetAddress ¶
func (VoteMsg) GetBlockHash ¶
func (VoteMsg) GetBlockId ¶
func (VoteMsg) GetType ¶
func (v VoteMsg) GetType() VoteMsgType
type VoteMsgType ¶
type VoteMsgType byte
const ( PreVoteMessage VoteMsgType = 0 VoteMessage VoteMsgType = 1 VerBootNodeVoteMessage VoteMsgType = 2 AliveVerifierVoteMessage VoteMsgType = 3 )
func (VoteMsgType) String ¶
func (i VoteMsgType) String() string