snapshot

package
v0.0.0-...-4502c18 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

func BalanceByAccount(acc *account.Account) Balance

func (Balance) GetBytes

func (b Balance) GetBytes() []byte

type BalanceProcessor

type BalanceProcessor interface {
	Validate(b Balance) error
}

type DefaultSnapShotProcessor

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

func (*DefaultSnapShotProcessor) Balance

func (*DefaultSnapShotProcessor) Vote

type Signature

type Signature struct {
	PublicKey types.Hash
	Signature types.Hash
}

Signature is type for compare signature and publickey for multisigns.

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

func (s *SnapShot) AddBalance(b Balance)

AddVote supplements the unissued balance for further release.

func (*SnapShot) AddVote

func (s *SnapShot) AddVote(v Vote)

AddVote supplements the unissued vote for further release.

func (*SnapShot) GetBytes

func (s *SnapShot) GetBytes() []byte

GetBytes is a implementation interface Byter.

func (*SnapShot) GetId

func (s *SnapShot) GetId() types.Hash

func (*SnapShot) Mine

func (s *SnapShot) Mine()

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

func (sm *SnapShotManager) CreateVote(kp *types.KeyPair,
	delegate types.Hash) Vote

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
}

type Vote

type Vote struct {
	Voter     types.Hash `json:"voter"`
	Delegate  types.Hash `json:"delegate"`
	Timestamp int64      `json:"timestamp"`
	Signature types.Hash `json:"signature"`
}

func (Vote) GetBytes

func (v Vote) GetBytes() []byte

type VoteProcessor

type VoteProcessor interface {
	Validate(v Vote) error
	Process(v Vote, am *account.AccountManager) error
	Commit() error
}

Jump to

Keyboard shortcuts

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