Documentation ¶
Index ¶
- Variables
- type Balance
- type BalanceProcessor
- type DefaultSnapShotProcessor
- type Signature
- type SnapShot
- type SnapShotFactory
- type SnapShotManager
- func (sm *SnapShotManager) AddBalance(b Balance)
- func (sm *SnapShotManager) AddVote(v Vote)
- func (sm *SnapShotManager) Clear() *SnapShotManager
- func (sm *SnapShotManager) Commit() error
- func (sm *SnapShotManager) CreateVote(kp *types.KeyPair, delegate types.Hash) Vote
- func (sm *SnapShotManager) Get(id []byte) (*SnapShot, error)
- func (sm *SnapShotManager) Last() (*SnapShot, error)
- func (sm *SnapShotManager) List(offset int, limit int) []*SnapShot
- func (sm *SnapShotManager) Release(pair *types.KeyPair) (lastSnapShot, error)
- func (sm *SnapShotManager) Write(ss *SnapShot) (lastSnapShot, error)
- type SnapShotProcessor
- type Vote
- type VoteProcessor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSSnotFound returned is snapshot not found. ErrSSNotFound = errors.New("SnapShot not found") )
Functions ¶
This section is empty.
Types ¶
type Balance ¶
type Balance struct { Address types.Hash `json:"addr"` Balance types.Coin `json:"blnc"` LastTx types.Hash `json:"ltx"` }
func BalanceByAccount ¶
type BalanceProcessor ¶
type DefaultSnapShotProcessor ¶
type DefaultSnapShotProcessor struct {
// contains filtered or unexported fields
}
func NewSnapShotProcessor ¶
func NewSnapShotProcessor(v VoteProcessor, b BalanceProcessor) *DefaultSnapShotProcessor
func (*DefaultSnapShotProcessor) Balance ¶
func (sp *DefaultSnapShotProcessor) Balance() BalanceProcessor
func (*DefaultSnapShotProcessor) Vote ¶
func (sp *DefaultSnapShotProcessor) Vote() VoteProcessor
type SnapShot ¶
type SnapShot struct { Version uint `json:"version"` Id types.Hash `json:"id"` Height uint32 `json:"height"` PreviousSnapShot types.Hash `json:"previousSnapShot"` GeneratorPublicKey types.Hash `json:"generatorPublicKey"` Votes []Vote `json:"votes"` Balances []Balance `json:"balances"` Timestamp int64 `json:"timestamp"` Signatures []Signature `json:"signaturess"` Signature types.Hash `json:"signature"` Nonce uint32 `json:"nonce"` // contains filtered or unexported fields }
SnapShot is an alternative to blocks, stores only the latest balances after account changes and information on voting for delegates.
It is the only synchronous chain that must be synchronized with all network members.
func (*SnapShot) AddBalance ¶
AddVote supplements the unissued balance for further release.
type SnapShotFactory ¶
type SnapShotFactory struct {
// contains filtered or unexported fields
}
SnapShotFactory is releasing new snapshots for delegates.
func NewSnapShotFactory ¶
func NewSnapShotFactory(sm *SnapShotManager, am *account.AccountManager, ch *chain.ChainHelper, db *leveldb.Db) *SnapShotFactory
NewSnapShotFactory creates new factory. Please note that the factory needs a manager.
func (*SnapShotFactory) SetDelegate ¶
func (sf *SnapShotFactory) SetDelegate(kp *types.KeyPair)
SetDelegate sets delegate account for release new snapshots.
func (*SnapShotFactory) Start ¶
func (sf *SnapShotFactory) Start()
Start starting the factory process.
func (*SnapShotFactory) Stop ¶
func (sf *SnapShotFactory) Stop()
Start stopping the factory process.
type SnapShotManager ¶
type SnapShotManager struct {
// contains filtered or unexported fields
}
SnapShotManager controls the work of snapshots, but does not release them into the network, see the SnapShotFactory.
func NewSnapShotManager ¶
func NewSnapShotManager(db *leveldb.Db) *SnapShotManager
NewSnapShotManager creates manager and empty SnapShot.
func (*SnapShotManager) AddBalance ¶
func (sm *SnapShotManager) AddBalance(b Balance)
func (*SnapShotManager) AddVote ¶
func (sm *SnapShotManager) AddVote(v Vote)
func (*SnapShotManager) Clear ¶
func (sm *SnapShotManager) Clear() *SnapShotManager
Clear clears SnapShot data for manager.
func (*SnapShotManager) Commit ¶
func (sm *SnapShotManager) Commit() error
Commit saves any changes in unconfirmed snapshot.
func (*SnapShotManager) CreateVote ¶
AddVote creates and vote.
func (*SnapShotManager) Get ¶
func (sm *SnapShotManager) Get(id []byte) (*SnapShot, error)
Get finds snapshot in database.
func (*SnapShotManager) Last ¶
func (sm *SnapShotManager) Last() (*SnapShot, error)
Last gets last snapshot
func (*SnapShotManager) List ¶
func (sm *SnapShotManager) List(offset int, limit int) []*SnapShot
List gets snapshot list in range.
func (*SnapShotManager) Release ¶
func (sm *SnapShotManager) Release(pair *types.KeyPair) (lastSnapShot, error)
Release confirms and releases a new snapshot.
func (*SnapShotManager) Write ¶
func (sm *SnapShotManager) Write(ss *SnapShot) (lastSnapShot, error)
Write writes snapshot to the database.
type SnapShotProcessor ¶
type SnapShotProcessor interface { Vote() VoteProcessor Balance() BalanceProcessor }