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 ¶
- func NewPacketSender(chain chainReader) types.GroupPacketSender
- func NewStore(chain chainReader) types.GroupStoreReader
- type CheckerContext
- type EncryptedSharePiecePacketImpl
- type FullPacketImpl
- type Manager
- func (m *Manager) ActiveGroupCount() int
- func (m *Manager) GetActivatedGroupsAt(height uint64) []types.GroupI
- func (m *Manager) GetAllGroupSeedsByHeight(h uint64) ([]common.Hash, error)
- func (m *Manager) GetGroupBySeed(seedHash common.Hash) types.GroupI
- func (m *Manager) GetGroupHeaderBySeed(seedHash common.Hash) types.GroupHeaderI
- func (m *Manager) GetGroupPacketSender() types.GroupPacketSender
- func (m *Manager) GetGroupSkipCountsAt(h uint64, groups []types.GroupI) (map[common.Hash]uint16, error)
- func (m *Manager) GetGroupStoreReader() types.GroupStoreReader
- func (m *Manager) GetLivedGroupsAt(height uint64) []types.GroupI
- func (m *Manager) GetLivedGroupsByMember(address common.Address, height uint64) []types.GroupI
- func (m *Manager) GroupKey() []byte
- func (m *Manager) GroupsAfter(height uint64) []types.GroupI
- func (m *Manager) Height() uint64
- func (m *Manager) InitGenesis(db types.AccountDB, genesisInfo *types.GenesisInfo)
- func (m *Manager) InitManager(punishment minerPunishment, gen *types.GenesisInfo)
- func (m *Manager) MinerJoinedLivedGroupCountFilter(maxCount int, height uint64) func(addr common.Address) bool
- func (m *Manager) NewOperation(db types.AccountDB, tx types.TxMessage, height uint64) Operation
- func (m *Manager) OnBlockRemove(bh *types.BlockHeader)
- func (m *Manager) RegisterGroupCreateChecker(checker types.GroupCreateChecker)
- func (m *Manager) RegularCheck(db types.AccountDB, bh *types.BlockHeader)
- func (m *Manager) UpdateGroupSkipCounts(db types.AccountDB, bh *types.BlockHeader)
- type MpkPacketImpl
- type Operation
- type OriginSharePiecePacketImpl
- type PacketSender
- type Store
- func (s *Store) GetEncryptedPiecePackets(seed types.SeedI) ([]types.EncryptedSharePiecePacket, error)
- func (s *Store) GetMpkPackets(seed types.SeedI) ([]types.MpkPacket, error)
- func (s *Store) GetOriginPiecePackets(seed types.SeedI) ([]types.OriginSharePiecePacket, error)
- func (s *Store) HasSentEncryptedPiecePacket(sender []byte, seed types.SeedI) bool
- func (s *Store) HasSentMpkPacket(sender []byte, seed types.SeedI) bool
- func (s *Store) HasSentOriginPiecePacket(sender []byte, seed types.SeedI) bool
- func (s *Store) IsOriginPieceRequired(seed types.SeedI) bool
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 {}
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 (e *EncryptedSharePiecePacketImpl) Seed() common.Hash
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 ¶
func (s *FullPacketImpl) Pieces() []types.EncryptedSharePiecePacket
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 ¶
Height returns count of current group number
func (*Manager) GetActivatedGroupsAt ¶
func (*Manager) GetAllGroupSeedsByHeight ¶
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 ¶
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 (*Manager) GetGroupStoreReader ¶
func (m *Manager) GetGroupStoreReader() types.GroupStoreReader
func (*Manager) GetLivedGroupsByMember ¶
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 ¶
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 {}
OriginSharePiecePacket implements types.OriginSharePiecePacket.
func (*OriginSharePiecePacketImpl) EncSeckey ¶
func (e *OriginSharePiecePacketImpl) EncSeckey() []byte
func (*OriginSharePiecePacketImpl) Pieces ¶
func (e *OriginSharePiecePacketImpl) Pieces() []byte
func (*OriginSharePiecePacketImpl) Seed ¶
func (e *OriginSharePiecePacketImpl) Seed() common.Hash
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 ¶
GetMpkPackets return all mpk with given Seed
func (*Store) GetOriginPiecePackets ¶
GetOriginPiecePackets returns all origin pieces with given Seed
func (*Store) HasSentEncryptedPiecePacket ¶
HasSentEncryptedPiecePacket checks if sender sent the encrypted piece to chain
func (*Store) HasSentMpkPacket ¶
HasSentEncryptedPiecePacket checks if sender sent the mpk to chain
func (*Store) HasSentOriginPiecePacket ¶
HasSentOriginPiecePacket checks if sender sent the origin piece to chain