blockchain

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(element IElement)

Add Add element

func Clear

func Clear()

Clear Initialize

func Iter

func Iter() func() IElement

Iter Iter, not thread safe

func IterElement

func IterElement(function func(element IElement) bool)

IterElement Iter, thread safe

func Len

func Len() int

Len Len of elements

func Remove

func Remove(element IElement)

Remove Remove element

func Removes

func Removes(elements []IElement)

Removes Remove element

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

func (bc *Blockchain) GetBalanceNonce(addr accounts.Address) (*big.Int, uint32)

GetBalanceNonce returns balance and nonce

func (*Blockchain) GetBlockchainInfo

func (bc *Blockchain) GetBlockchainInfo() *consensus.BlockchainInfo

func (*Blockchain) GetNextBlockHash

func (bc *Blockchain) GetNextBlockHash(h crypto.Hash) (crypto.Hash, error)

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) Start

func (bc *Blockchain) Start()

Start starts blockchain services

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 Get

func Get(n int) (elements []IElement)

Get Get num elements from head

func Has

func Has(key string) IElement

Has Contains

func RemoveAll

func RemoveAll() (elements []IElement)

RemoveAll Remove all elements

func RemoveBefore

func RemoveBefore(element IElement) (elements []IElement)

RemoveBefore Remove elements before element

type LinkedList

type LinkedList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LinkedList Define LinkedList struct

func NewLinkedList

func NewLinkedList() *LinkedList

NewLinkedList Create LinkedList instance

func (*LinkedList) Add

func (lst *LinkedList) Add(element IElement)

Add Add element

func (*LinkedList) Clear

func (lst *LinkedList) Clear()

Clear Initialize

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) Has

func (lst *LinkedList) Has(key string) IElement

Has Contains

func (*LinkedList) Iter

func (lst *LinkedList) Iter() func() IElement

Iter Iter, not thread safe

func (*LinkedList) IterElement

func (lst *LinkedList) IterElement(function func(element IElement) bool)

IterElement Iter, thread safe

func (*LinkedList) Len

func (lst *LinkedList) Len() int

Len Len of elements

func (*LinkedList) Remove

func (lst *LinkedList) Remove(element IElement)

Remove Remove element

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

type Validator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(ledger *ledger.Ledger) *Validator

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) Loop

func (vr *Validator) Loop()

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

Jump to

Keyboard shortcuts

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