Documentation ¶
Index ¶
- Constants
- func BytesToString(b []byte) string
- func BytesToUint64(bys []byte) uint64
- func CalculateBatchHash(pBatch *protos.PartialOrderBatch) string
- func CalculateFault(n int) int
- func CalculateListHash(list []string, timestamp int64) string
- func CalculateMD5Hash(payload []byte, timestamp int64) []byte
- func CalculateOneCorrect(n int) int
- func CalculatePayloadHash(payload []byte, timestamp int64) string
- func CalculateQuorum(n int) int
- func GenerateCommand(author uint64, seqNo uint64, txs []*protos.Transaction) *protos.Command
- func GenerateRandCommand(author uint64, seqNo uint64, count, size int) *protos.Command
- func GenerateRandTransaction(size int) *protos.Transaction
- func GenerateTransaction(payload []byte) *protos.Transaction
- func GetHash(tx *protos.Transaction) string
- func NanoToMillisecond(nano int64) float64
- func NanoToSecond(nano int64) float64
- func NewRawLogger() *logrus.Logger
- func NewRawLoggerFile(path string) *logrus.Logger
- func StringToBytes(str string) []byte
- func Uint64MapToList(m map[uint64]bool) []uint64
- func Uint64ToBytes(num uint64) []byte
- type ByzCommandSet
- type CommandIndex
- type CommandInfo
- func (ci *CommandInfo) AppendLow(info *CommandInfo)
- func (ci *CommandInfo) Format() string
- func (ci *CommandInfo) OrderAppend(oInfo OrderInfo)
- func (ci *CommandInfo) OrderCount() int
- func (ci *CommandInfo) PrioriCommit(commandD string)
- func (ci *CommandInfo) PrioriFinished() bool
- func (ci *CommandInfo) PrioriRecord(priInfo *CommandInfo)
- func (ci *CommandInfo) TransitiveLow(parentInfo *CommandInfo)
- type CommandSet
- type CommandStream
- type FrontStream
- type Hash
- type Identifier
- type InnerBlock
- type MetricsInfo
- type OrderInfo
- type OrderStream
- type QueryIndex
- type QueryStream
- type Signature
- type SortableInnerBlocks
Constants ¶
const ( // DefaultTimeDuration is the default time duration for proposal generation. DefaultTimeDuration = 50 * time.Millisecond // DefaultLogRotation is the default log rotation for proposal generation. DefaultLogRotation int = 10000 // SingleCommandSize is used for phalanx test network for size 1. SingleCommandSize int = 1 // DefaultCommandSize is the default batch size for command transactions. DefaultCommandSize int = 500 // DefaultMulti is the default multi proposers for tx manager. DefaultMulti int = 4 // DefaultLogCount int = 5 // DefaultMemSize int = 50000 // DefaultInterval int = 10 )
const ( COUNT = 512 // Supported signing algorithms BLS_BLS12381 = "BLS_BLS12381" ECDSA_P256 = "ECDSA_P256" ECDSA_SECp256k1 = "ECDSA_SECp256k1" )
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
func BytesToUint64 ¶
func CalculateBatchHash ¶
func CalculateBatchHash(pBatch *protos.PartialOrderBatch) string
func CalculateFault ¶
CalculateFault calculates the upper fault amount in byzantine system with n nodes.
func CalculateListHash ¶
func CalculateMD5Hash ¶
func CalculateOneCorrect ¶
CalculateOneCorrect calculates the lowest amount for set with at least one trusted node in byzantine system.
func CalculatePayloadHash ¶
func CalculateQuorum ¶
CalculateQuorum calculates the quorum legal committee for byzantine system.
func GenerateCommand ¶
GenerateCommand generates command with given transaction list.
func GenerateRandCommand ¶
func GenerateRandTransaction ¶
func GenerateRandTransaction(size int) *protos.Transaction
func GenerateTransaction ¶
func GenerateTransaction(payload []byte) *protos.Transaction
func NanoToMillisecond ¶
func NanoToSecond ¶
func NewRawLogger ¶
NewRawLogger provides a Logger instance to print logs in console.
func NewRawLoggerFile ¶
NewRawLoggerFile provides a Logger instance to print logs in files.
func StringToBytes ¶
func Uint64MapToList ¶
func Uint64ToBytes ¶
Types ¶
type ByzCommandSet ¶
type ByzCommandSet []*CommandIndex
func (ByzCommandSet) Len ¶
func (set ByzCommandSet) Len() int
func (ByzCommandSet) Less ¶
func (set ByzCommandSet) Less(i, j int) bool
func (ByzCommandSet) Swap ¶
func (set ByzCommandSet) Swap(i, j int)
type CommandIndex ¶
type CommandIndex struct { // Author indicates the generator of current command. Author uint64 // SeqNo indicates command sequence number assigned by generator. SeqNo uint64 // Digest indicates the identifier of current command. Digest string // RTime is the receiving time for current command. RTime int64 // OTime is the timestamp to order current command. OTime int64 }
CommandIndex is used to record the essential messages for commands we have received.
func NewCommandIndex ¶
func NewCommandIndex(command *protos.Command) *CommandIndex
func (*CommandIndex) Format ¶
func (index *CommandIndex) Format() string
type CommandInfo ¶
type CommandInfo struct { // CurCmd is used to record the digest of current command. CurCmd string // PriCmd is used to track the digests of the command which should be executed before current command. PriCmd map[string]bool // LowCmd is used to record the lowest commands which could be regarded as the first priority command for us. LowCmd map[string]*CommandInfo // Orders is used to record the partial-order generated by phalanx replicas. Orders map[uint64]OrderInfo // Timestamps is used to record the timestamp of partial orders. Timestamps sortableTimestamps // Trust indicates if we have checked the potential priori command for it. Trust bool // GTime is the timestamp to generate current command info. GTime int64 // MediumTSet sortableTimestamps }
func NewCmdInfo ¶
func NewCmdInfo(commandD string) *CommandInfo
func (*CommandInfo) AppendLow ¶
func (ci *CommandInfo) AppendLow(info *CommandInfo)
func (*CommandInfo) Format ¶
func (ci *CommandInfo) Format() string
func (*CommandInfo) OrderAppend ¶
func (ci *CommandInfo) OrderAppend(oInfo OrderInfo)
func (*CommandInfo) OrderCount ¶
func (ci *CommandInfo) OrderCount() int
func (*CommandInfo) PrioriCommit ¶
func (ci *CommandInfo) PrioriCommit(commandD string)
func (*CommandInfo) PrioriFinished ¶
func (ci *CommandInfo) PrioriFinished() bool
func (*CommandInfo) PrioriRecord ¶
func (ci *CommandInfo) PrioriRecord(priInfo *CommandInfo)
func (*CommandInfo) TransitiveLow ¶
func (ci *CommandInfo) TransitiveLow(parentInfo *CommandInfo)
TransitiveLow update current node's lowest map. <x,y> && <y,z> -> <x,z>
type CommandSet ¶
type CommandSet []*CommandIndex
func (CommandSet) Len ¶
func (set CommandSet) Len() int
func (CommandSet) Less ¶
func (set CommandSet) Less(i, j int) bool
func (CommandSet) Swap ¶
func (set CommandSet) Swap(i, j int)
type CommandStream ¶
type CommandStream []*CommandInfo
type FrontStream ¶
type FrontStream struct { // Safe indicates if current front stream is generated by safe path or not. Safe bool // Stream is the content of front stream. Stream CommandStream }
FrontStream is the minimal unit for front-order-fairness.
type Hash ¶
type Hash []byte
Hash is the hash algorithms output types
type InnerBlock ¶
type InnerBlock struct { // FrontNo is the sequential number for current inner block. FrontNo uint64 // Safe indicates the front set current block belongs to is generated with safe path or not. Safe bool // SeqNo is the order to commit current block. SeqNo uint64 // Command is the content of current block. Command *protos.Command // Timestamp is the trusted time for current block generation. Timestamp int64 // MediumT int64 }
InnerBlock is an executed block for phalanx.
func NewInnerBlock ¶
func NewInnerBlock(frontNo uint64, safe bool, command *protos.Command, timestamp int64, mediumT int64) InnerBlock
NewInnerBlock generates the phalanx inner block to commit.
func (InnerBlock) Format ¶
func (block InnerBlock) Format() string
type MetricsInfo ¶
type MetricsInfo struct { // AvePackOrderLatency indicates interval since receive command to generate pre-order. AvePackOrderLatency float64 // CurPackOrderLatency float64 // AveOrderLatency indicates interval since receive command to generate partial order. AveOrderLatency float64 // CurOrderLatency float64 // AveOrderSize int // AveLogLatency indicates interval since generate partial order to commit partial order. AveLogLatency float64 // CurLogLatency float64 // AveCommandInfoLatency indicates since generate command info to commit command. AveCommandInfoLatency float64 // CurCommandInfoLatency float64 // AveCommitStreamLatency float64 // CurCommitStreamLatency float64 // SafeCommandCount indicates the number of command committed from safe path. SafeCommandCount int // RiskCommandCount indicates the number of command committed from risk path. RiskCommandCount int // FrontAttackFromRisk records the front attacked command requests from risk path. FrontAttackFromRisk int // FrontAttackFromSafe records the front attacked command requests from safe path. FrontAttackFromSafe int // FrontAttackIntervalRisk records the front attacked command requests of interval relationship from risk path. FrontAttackIntervalRisk int // FrontAttackIntervalSafe records the front attacked command requests of interval relationship from safe path. FrontAttackIntervalSafe int //======= // MSafeCommandCount indicates the number of command committed from safe path. MSafeCommandCount int // MRiskCommandCount indicates the number of command committed from risk path. MRiskCommandCount int // MFrontAttackFromRisk records the front attacked command requests from risk path. MFrontAttackFromRisk int // MFrontAttackFromSafe records the front attacked command requests from safe path. MFrontAttackFromSafe int // MFrontAttackIntervalRisk records the front attacked command requests of interval relationship from risk path. MFrontAttackIntervalRisk int // MFrontAttackIntervalSafe records the front attacked command requests of interval relationship from safe path. MFrontAttackIntervalSafe int // CommandPS float64 // LogPS float64 // GenLogPS float64 }
MetricsInfo tracks the metrics info of phalanx.
type OrderInfo ¶
type OrderInfo struct { // Author indicates the generator of current order. Author uint64 // Sequence indicates the sequential indicator. Sequence uint64 // Command indicates the digest of command which current info is ordered for. Command string // Timestamp indicates the time when current order is generated. Timestamp int64 // AfterQuorum bool }
func NewOrderInfos ¶
func NewOrderInfos(seqNo uint64, pOrder *protos.PartialOrder) ([]OrderInfo, uint64)
type OrderStream ¶
type OrderStream []OrderInfo
func (OrderStream) Len ¶
func (os OrderStream) Len() int
func (OrderStream) Less ¶
func (os OrderStream) Less(i, j int) bool
func (OrderStream) Swap ¶
func (os OrderStream) Swap(i, j int)
type QueryIndex ¶
type QueryIndex struct { // Author indicates the generator of one partial order. Author uint64 // SeqNo indicates the partial order sequence assigned by generator. SeqNo uint64 }
QueryIndex indicates the query identifier for the scanner of partial orders.
func NewQueryIndex ¶
func NewQueryIndex(author uint64, seqNo uint64) QueryIndex
func (QueryIndex) Format ¶
func (idx QueryIndex) Format() string
type QueryStream ¶
type QueryStream []QueryIndex
QueryStream is a series of query index for partial orders.
func (QueryStream) Len ¶
func (qs QueryStream) Len() int
func (QueryStream) Less ¶
func (qs QueryStream) Less(i, j int) bool
func (QueryStream) Swap ¶
func (qs QueryStream) Swap(i, j int)
type SortableInnerBlocks ¶
type SortableInnerBlocks []InnerBlock
SortableInnerBlocks is a slice of inner block to sort.
func (SortableInnerBlocks) Len ¶
func (s SortableInnerBlocks) Len() int
func (SortableInnerBlocks) Less ¶
func (s SortableInnerBlocks) Less(i, j int) bool
func (SortableInnerBlocks) Swap ¶
func (s SortableInnerBlocks) Swap(i, j int)