shard

package
v0.0.0-...-d0e3281 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const RoleLeader = 0

RoleLeader role is leader

View Source
const RoleMember = 1

RoleMember role is member

Variables

View Source
var GlobalGroupMems []MemShard

GlobalGroupMems global memshard

View Source
var NumMems int

NumMems number of members within one shard

View Source
var PrevFinalBlockHash [][32]byte

PreviousSyncBlockHash the hash array of previous final block from all the shards

View Source
var PreviousSyncBlockHash [][32]byte

PreviousSyncBlockHash the hash array of previous sync block from all the shards

View Source
var ShardToGlobal [][]int

ShardToGlobal shard ind+in shard ind -> global index

View Source
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 GetRBData

func GetRBData()

GetRBData get all the data from reputation block for sharding

func ReturnRepData

func ReturnRepData(shardID uint32) *[]int64

ReturnRepData gets the rep data of a specific shard

func SortRep

func SortRep(a *[]sortType, l int, r int) error

SortRep sorts all miners based on their reputation

Types

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance is the struct for sharding

func (*Instance) GenerateSeed

func (c *Instance) GenerateSeed(a *[][32]byte) error

GenerateSeed come out the seed used in random number

func (*Instance) LeaderSort

func (c *Instance) LeaderSort(a *[]MemShard, b *[][]int, xx uint32)

LeaderSort give the priority of being leader in this round

func (*Instance) Sharding

func (c *Instance) Sharding(a *[]MemShard, b *[][]int)

Sharding do the shards given reputations

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

func (ms *MemShard) AddRep(value int64)

AddRep add a reputation value

func (*MemShard) CalTotalRep

func (ms *MemShard) CalTotalRep() int64

CalTotalRep cal total rep over epoches

func (*MemShard) ClearRep

func (ms *MemShard) ClearRep()

ClearRep clear rep

func (*MemShard) ClearTotalRep

func (ms *MemShard) ClearTotalRep()

ClearTotalRep is clear total rep

func (*MemShard) CopyTotalRepFromSB

func (ms *MemShard) CopyTotalRepFromSB(value []int64)

CopyTotalRepFromSB copy total rep from sync bock

func (*MemShard) NewMemShard

func (ms *MemShard) NewMemShard(acc *account.RcAcc, addr string, band int)

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

func (ms *MemShard) Print()

Print prints the sharding information

func (*MemShard) SetTotalRep

func (ms *MemShard) SetTotalRep(value int64)

SetTotalRep set totalrep

Jump to

Keyboard shortcuts

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