storage

package
v0.0.7-alphanet Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PrefixPeriodPoint = byte(0)
	PrefixEpochPoint  = byte(1)
	// Total number of possible points
	NumPointTypes        = 2
	PrefixElectionResult = byte(10)
)

Variables

This section is empty.

Functions

func CreateElectionResultKey

func CreateElectionResultKey(hash types.Hash) []byte

func CreatePointKey

func CreatePointKey(prefix byte, height uint64) []byte

Types

type ConsensusPointProto

type ConsensusPointProto struct {
	PrevHash             []byte                 `protobuf:"bytes,1,opt,name=prevHash,proto3" json:"prevHash,omitempty"`
	EndHash              []byte                 `protobuf:"bytes,2,opt,name=endHash,proto3" json:"endHash,omitempty"`
	TotalWeight          []byte                 `protobuf:"bytes,3,opt,name=totalWeight,proto3" json:"totalWeight,omitempty"`
	Content              []*ProducerDetailProto `protobuf:"bytes,4,rep,name=content,proto3" json:"content,omitempty"`
	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
	XXX_unrecognized     []byte                 `json:"-"`
	XXX_sizecache        int32                  `json:"-"`
}

func (*ConsensusPointProto) Descriptor

func (*ConsensusPointProto) Descriptor() ([]byte, []int)

func (*ConsensusPointProto) GetContent

func (m *ConsensusPointProto) GetContent() []*ProducerDetailProto

func (*ConsensusPointProto) GetEndHash

func (m *ConsensusPointProto) GetEndHash() []byte

func (*ConsensusPointProto) GetPrevHash

func (m *ConsensusPointProto) GetPrevHash() []byte

func (*ConsensusPointProto) GetTotalWeight

func (m *ConsensusPointProto) GetTotalWeight() []byte

func (*ConsensusPointProto) ProtoMessage

func (*ConsensusPointProto) ProtoMessage()

func (*ConsensusPointProto) Reset

func (m *ConsensusPointProto) Reset()

func (*ConsensusPointProto) String

func (m *ConsensusPointProto) String() string

func (*ConsensusPointProto) XXX_DiscardUnknown

func (m *ConsensusPointProto) XXX_DiscardUnknown()

func (*ConsensusPointProto) XXX_Marshal

func (m *ConsensusPointProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ConsensusPointProto) XXX_Merge

func (m *ConsensusPointProto) XXX_Merge(src proto.Message)

func (*ConsensusPointProto) XXX_Size

func (m *ConsensusPointProto) XXX_Size() int

func (*ConsensusPointProto) XXX_Unmarshal

func (m *ConsensusPointProto) XXX_Unmarshal(b []byte) error

type DB

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

func NewConsensusDB

func NewConsensusDB(db db.DB, electionCacheSize int, pointCacheSize int) *DB

func (*DB) DeletePointByHeight

func (db *DB) DeletePointByHeight(prefix byte, height uint64) error

func (*DB) GetElectionResultByHash

func (db *DB) GetElectionResultByHash(hash types.Hash) (*ElectionData, error)

ElectionData

func (*DB) GetPointByHeight

func (db *DB) GetPointByHeight(prefix byte, height uint64) (*Point, error)

Point

func (*DB) StoreElectionResultByHash

func (db *DB) StoreElectionResultByHash(hash types.Hash, data *ElectionData) error

func (*DB) StorePointByHeight

func (db *DB) StorePointByHeight(prefix byte, height uint64, p *Point) error

type ElectionData

type ElectionData struct {
	Producers   []types.Address
	Delegations []*types.PillarDelegation
}

func GenElectionData

func GenElectionData(producers []types.Address, delegations []*types.PillarDelegation) *ElectionData

func (*ElectionData) Marshal

func (d *ElectionData) Marshal() ([]byte, error)

func (*ElectionData) Unmarshal

func (d *ElectionData) Unmarshal(buf []byte) error

type ElectionDataProto

type ElectionDataProto struct {
	Producers            [][]byte                 `protobuf:"bytes,1,rep,name=producers,proto3" json:"producers,omitempty"`
	Delegations          []*PillarDelegationProto `protobuf:"bytes,2,rep,name=delegations,proto3" json:"delegations,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                 `json:"-"`
	XXX_unrecognized     []byte                   `json:"-"`
	XXX_sizecache        int32                    `json:"-"`
}

func (*ElectionDataProto) Descriptor

func (*ElectionDataProto) Descriptor() ([]byte, []int)

func (*ElectionDataProto) GetDelegations

func (m *ElectionDataProto) GetDelegations() []*PillarDelegationProto

func (*ElectionDataProto) GetProducers

func (m *ElectionDataProto) GetProducers() [][]byte

func (*ElectionDataProto) ProtoMessage

func (*ElectionDataProto) ProtoMessage()

func (*ElectionDataProto) Reset

func (m *ElectionDataProto) Reset()

func (*ElectionDataProto) String

func (m *ElectionDataProto) String() string

func (*ElectionDataProto) XXX_DiscardUnknown

func (m *ElectionDataProto) XXX_DiscardUnknown()

func (*ElectionDataProto) XXX_Marshal

func (m *ElectionDataProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ElectionDataProto) XXX_Merge

func (m *ElectionDataProto) XXX_Merge(src proto.Message)

func (*ElectionDataProto) XXX_Size

func (m *ElectionDataProto) XXX_Size() int

func (*ElectionDataProto) XXX_Unmarshal

func (m *ElectionDataProto) XXX_Unmarshal(b []byte) error

type PillarDelegationProto

type PillarDelegationProto struct {
	ProducingAddress     []byte   `protobuf:"bytes,1,opt,name=producingAddress,proto3" json:"producingAddress,omitempty"`
	Name                 string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Weight               []byte   `protobuf:"bytes,3,opt,name=weight,proto3" json:"weight,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PillarDelegationProto) Descriptor

func (*PillarDelegationProto) Descriptor() ([]byte, []int)

func (*PillarDelegationProto) GetName

func (m *PillarDelegationProto) GetName() string

func (*PillarDelegationProto) GetProducingAddress

func (m *PillarDelegationProto) GetProducingAddress() []byte

func (*PillarDelegationProto) GetWeight

func (m *PillarDelegationProto) GetWeight() []byte

func (*PillarDelegationProto) ProtoMessage

func (*PillarDelegationProto) ProtoMessage()

func (*PillarDelegationProto) Reset

func (m *PillarDelegationProto) Reset()

func (*PillarDelegationProto) String

func (m *PillarDelegationProto) String() string

func (*PillarDelegationProto) XXX_DiscardUnknown

func (m *PillarDelegationProto) XXX_DiscardUnknown()

func (*PillarDelegationProto) XXX_Marshal

func (m *PillarDelegationProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PillarDelegationProto) XXX_Merge

func (m *PillarDelegationProto) XXX_Merge(src proto.Message)

func (*PillarDelegationProto) XXX_Size

func (m *PillarDelegationProto) XXX_Size() int

func (*PillarDelegationProto) XXX_Unmarshal

func (m *PillarDelegationProto) XXX_Unmarshal(b []byte) error

type Point

type Point struct {
	// Last hash that is not in this point
	PrevHash types.Hash
	// Last hash that is in this point
	EndHash     types.Hash
	Pillars     map[string]*ProducerDetail
	TotalWeight *big.Int
}

func NewEmptyPoint

func NewEmptyPoint(proofHash types.Hash) *Point

func (*Point) IsEmpty

func (p *Point) IsEmpty() bool

func (*Point) Json

func (p *Point) Json() string

func (*Point) LeftAppend

func (p *Point) LeftAppend(left *Point) error

func (*Point) Marshal

func (p *Point) Marshal() ([]byte, error)

func (*Point) Unmarshal

func (p *Point) Unmarshal(buf []byte) error

type ProducerDetail

type ProducerDetail struct {
	ExpectedNum uint32
	FactualNum  uint32
	Weight      *big.Int
}

func (*ProducerDetail) AddNum

func (detail *ProducerDetail) AddNum(ExpectedNum uint32, FactualNum uint32)

func (ProducerDetail) Copy

func (detail ProducerDetail) Copy() *ProducerDetail

func (*ProducerDetail) Merge

func (detail *ProducerDetail) Merge(c *ProducerDetail)

type ProducerDetailProto

type ProducerDetailProto struct {
	Name                 string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	FactualNum           uint32   `protobuf:"fixed32,2,opt,name=factualNum,proto3" json:"factualNum,omitempty"`
	ExpectedNum          uint32   `protobuf:"fixed32,3,opt,name=expectedNum,proto3" json:"expectedNum,omitempty"`
	Weight               []byte   `protobuf:"bytes,4,opt,name=weight,proto3" json:"weight,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ProducerDetailProto) Descriptor

func (*ProducerDetailProto) Descriptor() ([]byte, []int)

func (*ProducerDetailProto) GetExpectedNum

func (m *ProducerDetailProto) GetExpectedNum() uint32

func (*ProducerDetailProto) GetFactualNum

func (m *ProducerDetailProto) GetFactualNum() uint32

func (*ProducerDetailProto) GetName

func (m *ProducerDetailProto) GetName() string

func (*ProducerDetailProto) GetWeight

func (m *ProducerDetailProto) GetWeight() []byte

func (*ProducerDetailProto) ProtoMessage

func (*ProducerDetailProto) ProtoMessage()

func (*ProducerDetailProto) Reset

func (m *ProducerDetailProto) Reset()

func (*ProducerDetailProto) String

func (m *ProducerDetailProto) String() string

func (*ProducerDetailProto) XXX_DiscardUnknown

func (m *ProducerDetailProto) XXX_DiscardUnknown()

func (*ProducerDetailProto) XXX_Marshal

func (m *ProducerDetailProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ProducerDetailProto) XXX_Merge

func (m *ProducerDetailProto) XXX_Merge(src proto.Message)

func (*ProducerDetailProto) XXX_Size

func (m *ProducerDetailProto) XXX_Size() int

func (*ProducerDetailProto) XXX_Unmarshal

func (m *ProducerDetailProto) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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