Documentation ¶
Index ¶
- Constants
- Variables
- func CompareRep(a *sortType, b *sortType) int
- func GetRBData()
- func ReturnRepData(shardID uint32) *[]int64
- func SortRep(a *[]sortType, l int, r int) error
- type Instance
- type MemShard
- func (ms *MemShard) AddRep(value int64)
- func (ms *MemShard) CalTotalRep() int64
- func (ms *MemShard) ClearRep()
- func (ms *MemShard) ClearTotalRep()
- func (ms *MemShard) CopyTotalRepFromSB(value []int64)
- func (ms *MemShard) NewMemShard(acc *account.RcAcc, addr string, band int)
- func (ms *MemShard) NewTotalRep()
- func (ms *MemShard) Print()
- func (ms *MemShard) SetTotalRep(value int64)
Constants ¶
const RoleLeader = 0
RoleLeader role is leader
const RoleMember = 1
RoleMember role is member
Variables ¶
var GlobalGroupMems []MemShard
GlobalGroupMems global memshard
var NumMems int
NumMems number of members within one shard
var PrevFinalBlockHash [][32]byte
PreviousSyncBlockHash the hash array of previous final block from all the shards
var PreviousSyncBlockHash [][32]byte
PreviousSyncBlockHash the hash array of previous sync block from all the shards
var ShardToGlobal [][]int
ShardToGlobal shard ind+in shard ind -> global index
var StartFlag bool
StartFlag indicate whether it is the first block generated in this epoch
Functions ¶
func CompareRep ¶
func CompareRep(a *sortType, b *sortType) int
CompareRep returns whether a has a great reputation than b
func ReturnRepData ¶
ReturnRepData gets the rep data of a specific shard
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is the struct for sharding
func (*Instance) GenerateSeed ¶
GenerateSeed come out the seed used in random number
func (*Instance) LeaderSort ¶
LeaderSort give the priority of being leader in this round
type MemShard ¶
type MemShard struct { //TCPAddress *net.TCPAddr Address string //ip+port PrivateAddress string PublicAddress string Rep int64 //rep this epoch TotalRep []int64 //rep over several epoch CosiPub ed25519.PublicKey Shard int InShardId int Role byte //1 - member, 0 - leader Legal byte //0 - legal, 1 - kickout RealAccount *account.RcAcc PreShard int Bandwidth int }
MemShard is the struct of miners for sharding and leader selection
var MyMenShard *MemShard
MyMenShard my
func (*MemShard) CalTotalRep ¶
CalTotalRep cal total rep over epoches
func (*MemShard) ClearTotalRep ¶
func (ms *MemShard) ClearTotalRep()
ClearTotalRep is clear total rep
func (*MemShard) CopyTotalRepFromSB ¶
CopyTotalRepFromSB copy total rep from sync bock
func (*MemShard) NewMemShard ¶
NewMemShard new a mem shard, addr - ip + port
func (*MemShard) NewTotalRep ¶
func (ms *MemShard) NewTotalRep()
NewTotalRep set a new total rep to 0
func (*MemShard) SetTotalRep ¶
SetTotalRep set totalrep