Documentation
¶
Index ¶
- func Add(element IElement)
- func Clear()
- func Iter() func() IElement
- func IterElement(function func(element IElement) bool)
- func Len() int
- func Remove(element IElement)
- func Removes(elements []IElement)
- type Blockchain
- func (bc *Blockchain) CurrentBlockHash() crypto.Hash
- func (bc *Blockchain) CurrentHeight() uint32
- func (bc *Blockchain) FetchGroupingTxsInTxPool(groupingNum, maxSizeInGrouping int) []types.Transactions
- func (bc *Blockchain) GenerateBlock(txs types.Transactions, createTime uint32) *types.Block
- func (bc *Blockchain) GetBalanceNonce(addr accounts.Address) (*big.Int, uint32)
- func (bc *Blockchain) GetBlockchainInfo() *consensus.BlockchainInfo
- func (bc *Blockchain) GetNextBlockHash(h crypto.Hash) (crypto.Hash, error)
- func (bc *Blockchain) GetTransaction(txHash crypto.Hash) (*types.Transaction, error)
- func (bc *Blockchain) ProcessBlock(blk *types.Block, flag bool) bool
- func (bc *Blockchain) ProcessTransaction(tx *types.Transaction) bool
- func (bc *Blockchain) SetBlockchainConsenter(consenter consensus.Consenter)
- func (bc *Blockchain) SetNetworkStack(pm NetworkStack)
- func (bc *Blockchain) Start()
- func (bc *Blockchain) StartConsensusService()
- func (bc *Blockchain) StartReceiveTx()
- func (bc *Blockchain) StartTxPool()
- func (bc *Blockchain) StopReceiveTx()
- func (bc *Blockchain) Synced() bool
- func (bc *Blockchain) VerifyTxsInConsensus(txs []*types.Transaction, primary bool) bool
- type IElement
- type LinkedList
- func (lst *LinkedList) Add(element IElement)
- func (lst *LinkedList) Clear()
- func (lst *LinkedList) Contains(key string) bool
- func (lst *LinkedList) Get(n int) (elements []IElement)
- func (lst *LinkedList) Has(key string) IElement
- func (lst *LinkedList) Iter() func() IElement
- func (lst *LinkedList) IterElement(function func(element IElement) bool)
- func (lst *LinkedList) Len() int
- func (lst *LinkedList) Remove(element IElement)
- func (lst *LinkedList) RemoveAll() (elements []IElement)
- func (lst *LinkedList) RemoveBefore(element IElement) (elements []IElement)
- func (lst *LinkedList) Removes(elements []IElement)
- type NetworkStack
- type Set
- type Validator
- func (vr *Validator) FetchGroupingTxsInTxPool(groupingNum, maxSizeInGrouping int) []types.Transactions
- func (vr *Validator) GetCommittedTxs(groupingTxs []*consensus.CommittedTxs) (types.Transactions, uint32)
- func (vr *Validator) Loop()
- func (vr *Validator) PushTxInTxPool(tx *types.Transaction) bool
- func (vr *Validator) RemoveTxsInTxPool(totalTxs, groupTxs, oChainTxs types.Transactions)
- func (vr *Validator) RollBackAccount(tx *types.Transaction)
- func (vr *Validator) UpdateAccount(tx *types.Transaction)
- func (vr *Validator) VerifyTxsInTxPool(txs types.Transactions, primary bool) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IterElement ¶
IterElement Iter, thread safe
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain is blockchain instance
func NewBlockchain ¶
func NewBlockchain(ledger *ledger.Ledger) *Blockchain
NewBlockchain returns a fully initialised blockchain service using input data
func (*Blockchain) CurrentBlockHash ¶
func (bc *Blockchain) CurrentBlockHash() crypto.Hash
CurrentBlockHash returns current block hash of the current block
func (*Blockchain) CurrentHeight ¶
func (bc *Blockchain) CurrentHeight() uint32
CurrentHeight returns current heigt of the current block
func (*Blockchain) FetchGroupingTxsInTxPool ¶
func (bc *Blockchain) FetchGroupingTxsInTxPool(groupingNum, maxSizeInGrouping int) []types.Transactions
func (*Blockchain) GenerateBlock ¶
func (bc *Blockchain) GenerateBlock(txs types.Transactions, createTime uint32) *types.Block
GenerateBlock gets transactions from consensus service and generates a new block
func (*Blockchain) GetBalanceNonce ¶
GetBalanceNonce returns balance and nonce
func (*Blockchain) GetBlockchainInfo ¶
func (bc *Blockchain) GetBlockchainInfo() *consensus.BlockchainInfo
func (*Blockchain) GetNextBlockHash ¶
GetNextBlockHash returns the next block hash
func (*Blockchain) GetTransaction ¶
func (bc *Blockchain) GetTransaction(txHash crypto.Hash) (*types.Transaction, error)
GetTransaction returns transaction in ledger first then txBool
func (*Blockchain) ProcessBlock ¶
func (bc *Blockchain) ProcessBlock(blk *types.Block, flag bool) bool
ProcessBlock processes new block from the network,flag = true pack up block ,flag = false sync block
func (*Blockchain) ProcessTransaction ¶
func (bc *Blockchain) ProcessTransaction(tx *types.Transaction) bool
ProcessTransaction processes new transaction from the network
func (*Blockchain) SetBlockchainConsenter ¶
func (bc *Blockchain) SetBlockchainConsenter(consenter consensus.Consenter)
SetBlockchainConsenter sets the consenter of the blockchain
func (*Blockchain) SetNetworkStack ¶
func (bc *Blockchain) SetNetworkStack(pm NetworkStack)
SetNetworkStack sets the node of the blockchain
func (*Blockchain) StartConsensusService ¶
func (bc *Blockchain) StartConsensusService()
StartConsensusService starts consensus service
func (*Blockchain) StartReceiveTx ¶
func (bc *Blockchain) StartReceiveTx()
StartReceiveTx starts validator tx services
func (*Blockchain) StartTxPool ¶
func (bc *Blockchain) StartTxPool()
StartTxPool starts txpool service
func (*Blockchain) StopReceiveTx ¶
func (bc *Blockchain) StopReceiveTx()
StopReceiveTx stops validator tx services
func (*Blockchain) Synced ¶
func (bc *Blockchain) Synced() bool
func (*Blockchain) VerifyTxsInConsensus ¶
func (bc *Blockchain) VerifyTxsInConsensus(txs []*types.Transaction, primary bool) bool
VerifyTxsInConsensus verify
type IElement ¶
type IElement interface {
Serialize() []byte
}
IElement Interface for element of LinkedList
func RemoveBefore ¶
RemoveBefore Remove elements before element
type LinkedList ¶
LinkedList Define LinkedList struct
func (*LinkedList) Contains ¶
func (lst *LinkedList) Contains(key string) bool
func (*LinkedList) Get ¶
func (lst *LinkedList) Get(n int) (elements []IElement)
Get Get num elements from head
func (*LinkedList) IterElement ¶
func (lst *LinkedList) IterElement(function func(element IElement) bool)
IterElement Iter, thread safe
func (*LinkedList) RemoveAll ¶
func (lst *LinkedList) RemoveAll() (elements []IElement)
RemoveAll Remove all elements
func (*LinkedList) RemoveBefore ¶
func (lst *LinkedList) RemoveBefore(element IElement) (elements []IElement)
RemoveBefore Remove elements before element
func (*LinkedList) Removes ¶
func (lst *LinkedList) Removes(elements []IElement)
Removes Remove element
type NetworkStack ¶
type NetworkStack interface {
Relay(inv types.IInventory)
}
NetworkStack defines the relay interface
type Set ¶
type Set interface {
// Adds an element to the set. Returns whether
// the item was added.
Add(i *types.Transaction) bool
// Returns the number of elements in the set.
Cardinality() int
// Removes all elements from the set, leaving
// the emtpy set.
Clear()
// Returns a clone of the set using the same
// implementation, duplicating all keys.
Clone() Set
// Returns whether the given items
// are all in the set.
Contains(i ...*types.Transaction) bool
// Returns the difference between this set
// and other. The returned set will contain
// all elements of this set that are not also
// elements of other.
//
// Note that the argument to Difference
// must be of the same type as the receiver
// of the method. Otherwise, Difference will
// panic.
Difference(other Set) Set
// Determines if two sets are equal to each
// other. If they have the same cardinality
// and contain the same elements, they are
// considered equal. The order in which
// the elements were added is irrelevant.
//
// Note that the argument to Equal must be
// of the same type as the receiver of the
// method. Otherwise, Equal will panic.
Equal(other Set) bool
// Returns a new set containing only the elements
// that exist only in both sets.
//
// Note that the argument to Intersect
// must be of the same type as the receiver
// of the method. Otherwise, Intersect will
// panic.
Intersect(other Set) Set
// Determines if every element in this set is in
// the other set but the two sets are not equal.
//
// Note that the argument to IsProperSubset
// must be of the same type as the receiver
// of the method. Otherwise, IsProperSubset
// will panic.
IsProperSubset(other Set) bool
// Determines if every element in the other set
// is in this set but the two sets are not
// equal.
//
// Note that the argument to IsSuperset
// must be of the same type as the receiver
// of the method. Otherwise, IsSuperset will
// panic.
IsProperSuperset(other Set) bool
// Determines if every element in this set is in
// the other set.
//
// Note that the argument to IsSubset
// must be of the same type as the receiver
// of the method. Otherwise, IsSubset will
// panic.
IsSubset(other Set) bool
// Determines if every element in the other set
// is in this set.
//
// Note that the argument to IsSuperset
// must be of the same type as the receiver
// of the method. Otherwise, IsSuperset will
// panic.
IsSuperset(other Set) bool
// Remove a single element from the set.
Remove(i *types.Transaction)
// Provides a convenient string representation
// of the current state of the set.
String() string
// Returns a new set with all elements which are
// in either this set or the other set but not in both.
//
// Note that the argument to SymmetricDifference
// must be of the same type as the receiver
// of the method. Otherwise, SymmetricDifference
// will panic.
SymmetricDifference(other Set) Set
// same type as the receiver of the method.
// Otherwise, IsSuperset will panic.
Union(other Set) Set
// Returns the members of the set as a slice.
ToSlice() types.Transactions
}
func NewThreadUnsafeSet ¶
func NewThreadUnsafeSet() Set
func NewThreadUnsafeSetFromSlice ¶
func NewThreadUnsafeSetFromSlice(s types.Transactions) Set
type Validator ¶
func NewValidator ¶
func (*Validator) FetchGroupingTxsInTxPool ¶
func (vr *Validator) FetchGroupingTxsInTxPool(groupingNum, maxSizeInGrouping int) []types.Transactions
func (*Validator) GetCommittedTxs ¶
func (vr *Validator) GetCommittedTxs(groupingTxs []*consensus.CommittedTxs) (types.Transactions, uint32)
func (*Validator) PushTxInTxPool ¶
func (vr *Validator) PushTxInTxPool(tx *types.Transaction) bool
func (*Validator) RemoveTxsInTxPool ¶
func (vr *Validator) RemoveTxsInTxPool(totalTxs, groupTxs, oChainTxs types.Transactions)
func (*Validator) RollBackAccount ¶
func (vr *Validator) RollBackAccount(tx *types.Transaction)
RollBackAccount roll back sender account balance
func (*Validator) UpdateAccount ¶
func (vr *Validator) UpdateAccount(tx *types.Transaction)
func (*Validator) VerifyTxsInTxPool ¶
func (vr *Validator) VerifyTxsInTxPool(txs types.Transactions, primary bool) bool