Documentation ¶
Index ¶
- Constants
- Variables
- func BlockLogTableNameForBlockHeight(num uint64) string
- type BlockLogRecord
- type IConsensus
- type IDailyStats
- type IDatabaseBatch
- type IDatabasePatch
- type IDatabaseRW
- type IDatabaseService
- type IDatabaseServiceId
- type IGlobalPropRW
- type IGlobalPropReader
- type IGlobalPropWriter
- type IP2P
- type IPrinter
- type IRPCServer
- type ITimer
- type ITrxPool
Constants ¶
View Source
const BlockLogProcessServiceName = "block_log_proc_svc"
View Source
const BlockLogServiceName = "block_log_svc"
View Source
const BlockLogSplitSizeInMillion = 5
table splitting size in million records, set to 0 for no-splitting.
View Source
const BlockLogTable = "blocklogs"
Variables ¶
View Source
var ConsensusServerName = "consensus"
View Source
var DailyStatisticServiceName = "dailystatservice"
View Source
var DbServerName = "db"
View Source
var DbTrunk = ""
View Source
var P2PServerName = "p2p"
View Source
var RpcServerName = "rpc"
View Source
var TxPoolServerName = "ctrl"
Functions ¶
func BlockLogTableNameForBlockHeight ¶ added in v1.0.2
Types ¶
type BlockLogRecord ¶ added in v1.0.2
type BlockLogRecord struct { ID uint64 `gorm:"primary_key;auto_increment"` BlockId string `gorm:"not null;unique_index"` BlockHeight uint64 `gorm:"not null;index"` BlockTime time.Time `gorm:"not null"` BlockProducer string `gorm:"index"` Final bool `gorm:"not null;index"` JsonLog string `gorm:"type:longtext"` }
func (*BlockLogRecord) TableName ¶ added in v1.0.2
func (log *BlockLogRecord) TableName() string
type IConsensus ¶
type IConsensus interface { // NOTE: producers should be maintained by the specific Consensus algorithm // CurrentProducer returns current producer CurrentProducer() string // ActiveProducers returns a list of accounts that actively produce blocks ActiveProducers() []string ActiveValidators() []string GetName() string // SetBootstrap determines if the current node starts a new block chain SetBootstrap(b bool) //Add transaction to pending list,the transaction will be applied when generate a block PushTransactionToPending(trx common.ISignedTransaction) error // PushBlock adds b to the block fork DB, called if ValidateBlock returns true PushBlock(b common.ISignedBlock) // Push sends a user defined msg to consensus Push(msg interface{}, p common.IPeer) // GetLastBFTCommit get the last irreversible block info. @evidence // is the information that can prove the id is indeed the last irreversible one. // e.g. if user uses bft to achieve fast ack, @evidence can simply be the collection // of the vote message GetLastBFTCommit() (evidence interface{}) GetBFTCommitInfo(num uint64) interface{} GetNextBFTCheckPoint(blockNum uint64) (evidence interface{}) // GetHeadBlockId returns the block id of the head block GetHeadBlockId() common.BlockID // GetIDs returns a list of block ids which remote peer may not have GetIDs(start, end common.BlockID) ([]common.BlockID, error) // FetchBlock returns the block whose id is the given param FetchBlock(id common.BlockID) (common.ISignedBlock, error) // HasBlock query the local blockchain whether it has the given block id HasBlock(id common.BlockID) bool // FetchBlocksSince returns blocks in the range of (id, max(headID, id+1024)) FetchBlocksSince(id common.BlockID) ([]common.ISignedBlock, error) // FetchBlocks returns blocks in the range of [from, to] FetchBlocks(from, to uint64) ([]common.ISignedBlock, error) // NOTE: the following methods are testing methods and should only be called by multinodetester2 // ResetProdTimer reset the prodTimer in dpos ResetProdTimer(t time.Duration) // ResetTicker reset the Ticker in DPoS ResetTicker(t time.Time) GetLIB() common.BlockID IsCommitted(id common.BlockID) bool // MaybeProduceBlock check whether should produce a block MaybeProduceBlock() // check whether sync progress is finished CheckSyncFinished() bool // check whether the given id's signed block is on the main branch IsOnMainBranch(id common.BlockID) (bool, error) SetHook(key string, f func(args ...interface{})) // for test only EnableMockSignal() MockMaliciousBehaviour(b bool) }
type IDailyStats ¶ added in v1.0.2
type IDatabaseBatch ¶
type IDatabaseBatch interface { // insert a new key-value pair, or update the value if the given key already exists Put(key []byte, value []byte) error // delete the given key and its value // if the given key does not exist, just return nil, indicating a successful deletion without doing anything. Delete(key []byte) error // execute all batched operations Write() error // reset the batch to empty Reset() }
interface for transaction executor methods must be thread safe write operations must be executed atomically
type IDatabasePatch ¶ added in v1.0.2
type IDatabasePatch interface { IDatabaseRW // apply the patch Apply() error // patch on patch NewPatch(branchId ...string) IDatabasePatch }
type IDatabaseRW ¶ added in v1.0.2
type IDatabaseRW interface { IDatabaseServiceId // check existence of the given key Has(key []byte) (bool, error) // query the value of the given key Get(key []byte) ([]byte, error) // insert a new key-value pair, or update the value if the given key already exists Put(key []byte, value []byte) error // delete the given key and its value // if the given key does not exist, just return nil, indicating a successful deletion without doing anything. Delete(key []byte) error // Iterate enumerates keys in range [start, limit) and calls callback with each enumerated key and its value. // If callback returns false, the enumeration stops immediately, otherwise all matched keys will be enumerated. // a nil start is the logical minimal key that is lesser than any existing keys // a nil limit is the logical maximum key that is greater than any existing keys Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool) // create a batch which can pack DatabasePutter & DatabaseDeleter operations and execute them atomically NewBatch() IDatabaseBatch // release a Batch DeleteBatch(b IDatabaseBatch) }
type IDatabaseService ¶
type IDatabaseService interface { IDatabaseRW // close a database Close() // start a new transaction session BeginTransaction() // end current transaction session, commit or discard changes EndTransaction(commit bool) error HashOfTopTransaction() uint32 // current transaction height TransactionHeight() uint BeginTransactionWithTag(tag string) Squash(tag string) error RollbackTag(tag string) error // get current revision GetRevision() uint64 // get current revision and base revision GetRevisionAndBase() (current uint64, base uint64) // revert to the given revision // you can only revert to a revision that is less than or equal to current revision. // after reverted to revision r, r will be the current revision. RevertToRevision(r uint64) error // rebase to the given revision // after rebased to revision r, r will be the minimal revision you can revert to. RebaseToRevision(r uint64) error EnableReversion(b bool) error ReversionEnabled() bool // tag a revision TagRevision(r uint64, tag string) error // get revision of a tag GetTagRevision(tag string) (uint64, error) // get tag of a revision GetRevisionTag(r uint64) string // revert to a revision by its tag RevertToTag(tag string) error // rebase to a revision by its tag RebaseToTag(tag string) error // delete everything. make all data gone and unrecoverable. // service will stop and restart if already started. // // this method is *NOT* thread safe. caller *MUST* guarantee that, // - all iterators released by DeleteIterator() before calling DeleteAll() // - no service calls before successful return of DeleteAll() DeleteAll() error // R/W locking Lock() Unlock() RLock() RUnlock() NewPatch(branchId ...string) IDatabasePatch }
Database Service
type IDatabaseServiceId ¶ added in v1.0.2
type IGlobalPropRW ¶ added in v1.0.2
type IGlobalPropRW interface { IGlobalPropReader IGlobalPropWriter }
type IGlobalPropReader ¶ added in v1.0.2
type IGlobalPropReader interface { GetProps() *prototype.DynamicProperties HeadBlockTime() *prototype.TimePointSec }
type IGlobalPropWriter ¶ added in v1.0.2
type IGlobalPropWriter interface { TransferToVest(value *prototype.Coin) TransferFromVest(value *prototype.Vest) TransferToStakeVest(value *prototype.Coin) TransferFromStakeVest(value *prototype.Vest) ModifyProps(modifier func(oldProps *prototype.DynamicProperties)) UpdateTicketIncomeAndNum(income *prototype.Vest, count uint64) }
type IP2P ¶
type IP2P interface { // Broadcast sigTrx or sigBlk msg Broadcast(message interface{}) // trigger sync request remote peer the block hashes we do not have TriggerSync(HeadId comn.BlockID) // when got one unlinked block, to fetch its previous block FetchUnlinkedBlock(prevId comn.BlockID) // Send message to a specific peer SendToPeer(p *peer.Peer, message interface{}) // Send message to a random peer RandomSend(message interface{}) // Request checkpoint batch [startNum, endNum) RequestCheckpoint(startNum, endNum uint64) // if receive a out-of-range signed block, call this method to fetch the gap signed blocks (localHeadID, targetID] FetchOutOfRange(localHeadID, targetID comn.BlockID) GetNodeNeighbours() string // for test only SetMockLatency(t int) GetMockLatency() int }
IP2P represent the net interface of p2p package which can be called by other service
type IRPCServer ¶
type IRPCServer interface { }
type ITrxPool ¶ added in v1.0.2
type ITrxPool interface { IGlobalPropRW PushTrx(trx *prototype.SignedTransaction) *prototype.TransactionReceiptWithInfo PushBlock(blk *prototype.SignedBlock, skip prototype.SkipFlag) error GenerateBlock(bpName string, pre *prototype.Sha256, timestamp uint32, priKey *prototype.PrivateKeyType, skip prototype.SkipFlag) (*prototype.SignedBlock, error) GetBlockProducerTopN(n uint32) ([]string, []*prototype.PublicKeyType) GetSigningPubKey(bpName string) *prototype.PublicKeyType SetShuffledBpList(names []string, keys []*prototype.PublicKeyType, seq uint64) GetShuffledBpList() ([]string, []*prototype.PublicKeyType, uint64) SetShuffle(s common.ShuffleFunc) // PreShuffle() must be called to notify ITrxPool that block producers shuffle is about to happen PreShuffle() error // PopBlock() rollbacks the state db to the moment just before applying block @num. PopBlock(num uint64) error // Commit() finalizes block @num. Commit(num uint64) // put trx into pending directly, no return value, so should be used by witness node to collect p2p trx PushTrxToPending(trx *prototype.SignedTransaction) error GenerateAndApplyBlock(bpName string, pre *prototype.Sha256, timestamp uint32, priKey *prototype.PrivateKeyType, skip prototype.SkipFlag) (*prototype.SignedBlock, error) VerifySig(name *prototype.AccountName, digest []byte, sig []byte) bool ValidateAddress(name string, pubKey *prototype.PublicKeyType) bool Sign(priv *prototype.PrivateKeyType, digest []byte) []byte //Fetch the latest pushed block number GetHeadBlockNum() (uint64, error) GetFinalizedNum() (uint64, error) CalculateUserMaxStamina(db IDatabaseRW, name string) uint64 CheckNetForRPC(name string, db IDatabaseRW, sizeInBytes uint64) (bool, uint64, uint64) EstimateStamina(trx *prototype.SignedTransaction) *prototype.TransactionReceiptWithInfo HardFork() uint64 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.