group

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright (C) 2019 ZVChain

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPacketSender

func NewPacketSender(chain chainReader) types.GroupPacketSender

func NewStore

func NewStore(chain chainReader) types.GroupStoreReader

Types

type CheckerContext

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

func (*CheckerContext) Height

func (c *CheckerContext) Height() uint64

type EncryptedSharePiecePacketImpl

type EncryptedSharePiecePacketImpl struct {
	SeedD    common.Hash `msgpack:"se"`           // Seed
	SenderD  []byte      `msgpack:"sr,omitempty"` // sender's address. will set from transaction source
	Pubkey0D []byte      `msgpack:"pb"`           // the gpk share of the miner
	PiecesD  []byte      `msgpack:"pi"`           // array of encrypted piece for every group member
}

Round 1 tx data,implement common.EncryptedSharePiecePacket

func (*EncryptedSharePiecePacketImpl) Pieces

func (e *EncryptedSharePiecePacketImpl) Pieces() []byte

func (*EncryptedSharePiecePacketImpl) Pubkey0

func (e *EncryptedSharePiecePacketImpl) Pubkey0() []byte

func (*EncryptedSharePiecePacketImpl) Seed

func (*EncryptedSharePiecePacketImpl) Sender

func (e *EncryptedSharePiecePacketImpl) Sender() []byte

type FullPacketImpl

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

func (*FullPacketImpl) Mpks

func (s *FullPacketImpl) Mpks() []types.MpkPacket

func (*FullPacketImpl) Pieces

type Manager

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

Manager implements groupContextProvider in package consensus

func NewManager

func NewManager(chain chainReader, counter groupSkipCounter) *Manager

func (*Manager) ActiveGroupCount

func (m *Manager) ActiveGroupCount() int

Height returns count of current group number

func (*Manager) GetActivatedGroupsAt

func (m *Manager) GetActivatedGroupsAt(height uint64) []types.GroupI

func (*Manager) GetAllGroupSeedsByHeight

func (m *Manager) GetAllGroupSeedsByHeight(h uint64) ([]common.Hash, error)

GetAllGroupSeedsByHeight iterates all groups from the given block height to genesis group. It's expensive and time consuming, don't call it unless you know what you are doing! It's called by the offline tailor or verifier for pruning mode currently

func (*Manager) GetGroupBySeed

func (m *Manager) GetGroupBySeed(seedHash common.Hash) types.GroupI

GetGroupBySeed returns group with given Seed

func (*Manager) GetGroupHeaderBySeed

func (m *Manager) GetGroupHeaderBySeed(seedHash common.Hash) types.GroupHeaderI

GetGroupBySeed returns group header with given Seed

func (*Manager) GetGroupPacketSender

func (m *Manager) GetGroupPacketSender() types.GroupPacketSender

func (*Manager) GetGroupSkipCountsAt

func (m *Manager) GetGroupSkipCountsAt(h uint64, groups []types.GroupI) (map[common.Hash]uint16, error)

func (*Manager) GetGroupStoreReader

func (m *Manager) GetGroupStoreReader() types.GroupStoreReader

func (*Manager) GetLivedGroupsAt

func (m *Manager) GetLivedGroupsAt(height uint64) []types.GroupI

func (*Manager) GetLivedGroupsByMember

func (m *Manager) GetLivedGroupsByMember(address common.Address, height uint64) []types.GroupI

func (*Manager) GroupKey

func (m *Manager) GroupKey() []byte

func (*Manager) GroupsAfter

func (m *Manager) GroupsAfter(height uint64) []types.GroupI

func (*Manager) Height

func (m *Manager) Height() uint64

Height returns count of current group number

func (*Manager) InitGenesis

func (m *Manager) InitGenesis(db types.AccountDB, genesisInfo *types.GenesisInfo)

func (*Manager) InitManager

func (m *Manager) InitManager(punishment minerPunishment, gen *types.GenesisInfo)

func (*Manager) MinerJoinedLivedGroupCountFilter

func (m *Manager) MinerJoinedLivedGroupCountFilter(maxCount int, height uint64) func(addr common.Address) bool

MinerJoinedLivedGroupCountFilter returns function to check if the miners joined live group count less than the maxCount in a given block height

func (*Manager) NewOperation

func (m *Manager) NewOperation(db types.AccountDB, tx types.TxMessage, height uint64) Operation

NewOperation creates the mOperation instance base on msg type

func (*Manager) OnBlockRemove

func (m *Manager) OnBlockRemove(bh *types.BlockHeader)

OnBlockRemove resets group with top block with parameter bh

func (*Manager) RegisterGroupCreateChecker

func (m *Manager) RegisterGroupCreateChecker(checker types.GroupCreateChecker)

func (*Manager) RegularCheck

func (m *Manager) RegularCheck(db types.AccountDB, bh *types.BlockHeader)

RegularCheck try to create group, do punishment and refresh active group

func (*Manager) UpdateGroupSkipCounts

func (m *Manager) UpdateGroupSkipCounts(db types.AccountDB, bh *types.BlockHeader)

type MpkPacketImpl

type MpkPacketImpl struct {
	SeedD   common.Hash `msgpack:"se"`           // Seed
	SenderD []byte      `msgpack:"sr,omitempty"` // sender's address
	MpkD    []byte      `msgpack:"mp"`           // mpk
	SignD   []byte      `msgpack:"si"`           // byte data of Seed signed by mpk
}

Round 2 tx data. implement interface types.MpkPacket

func (*MpkPacketImpl) Mpk

func (s *MpkPacketImpl) Mpk() []byte

func (*MpkPacketImpl) Seed

func (s *MpkPacketImpl) Seed() common.Hash

func (*MpkPacketImpl) Sender

func (s *MpkPacketImpl) Sender() []byte

func (*MpkPacketImpl) Sign

func (s *MpkPacketImpl) Sign() []byte

type Operation

type Operation interface {
	ParseTransaction() error // Parse the input transaction
	Operation() error        // Do the operation
}

Operation define some functions on create create transaction

type OriginSharePiecePacketImpl

type OriginSharePiecePacketImpl struct {
	SeedD      common.Hash `msgpack:"se"`           // Seed
	SenderD    []byte      `msgpack:"sr,omitempty"` // sender's address. will set from transaction source
	EncSeckeyD []byte      `msgpack:"es"`           // the gpk share of the miner
	PiecesD    []byte      `msgpack:"pi"`           // array of origin piece for every group member
}

OriginSharePiecePacket implements types.OriginSharePiecePacket.

func (*OriginSharePiecePacketImpl) EncSeckey

func (e *OriginSharePiecePacketImpl) EncSeckey() []byte

func (*OriginSharePiecePacketImpl) Pieces

func (e *OriginSharePiecePacketImpl) Pieces() []byte

func (*OriginSharePiecePacketImpl) Seed

func (*OriginSharePiecePacketImpl) Sender

func (e *OriginSharePiecePacketImpl) Sender() []byte

type PacketSender

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

func (*PacketSender) SendEncryptedPiecePacket

func (p *PacketSender) SendEncryptedPiecePacket(packet types.EncryptedSharePiecePacket) (err error)

SendEncryptedPiecePacket send transaction the miner's encrypted piece in round one

func (*PacketSender) SendMpkPacket

func (p *PacketSender) SendMpkPacket(packet types.MpkPacket) (err error)

SendEncryptedPiecePacket send transaction the miner mpk and sign in round two

func (PacketSender) SendOriginPiecePacket

func (p PacketSender) SendOriginPiecePacket(packet types.OriginSharePiecePacket) (err error)

SendEncryptedPiecePacket send transaction the miner origin in round three

type Store

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

Store implements GroupStoreReader

func (*Store) GetEncryptedPiecePackets

func (s *Store) GetEncryptedPiecePackets(seed types.SeedI) ([]types.EncryptedSharePiecePacket, error)

GetEncryptedPiecePackets returns all uploaded encrypted share piece with given Seed

func (*Store) GetMpkPackets

func (s *Store) GetMpkPackets(seed types.SeedI) ([]types.MpkPacket, error)

GetMpkPackets return all mpk with given Seed

func (*Store) GetOriginPiecePackets

func (s *Store) GetOriginPiecePackets(seed types.SeedI) ([]types.OriginSharePiecePacket, error)

GetOriginPiecePackets returns all origin pieces with given Seed

func (*Store) HasSentEncryptedPiecePacket

func (s *Store) HasSentEncryptedPiecePacket(sender []byte, seed types.SeedI) bool

HasSentEncryptedPiecePacket checks if sender sent the encrypted piece to chain

func (*Store) HasSentMpkPacket

func (s *Store) HasSentMpkPacket(sender []byte, seed types.SeedI) bool

HasSentEncryptedPiecePacket checks if sender sent the mpk to chain

func (*Store) HasSentOriginPiecePacket

func (s *Store) HasSentOriginPiecePacket(sender []byte, seed types.SeedI) bool

HasSentOriginPiecePacket checks if sender sent the origin piece to chain

func (*Store) IsOriginPieceRequired

func (s *Store) IsOriginPieceRequired(seed types.SeedI) bool

IsOriginPieceRequired checks if group members should upload origin piece

Jump to

Keyboard shortcuts

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