sebak: boscoin.io/sebak/lib/sync Index | Files

package sync

import "boscoin.io/sebak/lib/sync"

Index

Package Files

config.go fetcher.go init.go nodelist.go pool.go syncer.go try.go types.go validator.go watcher.go

Constants

const (
    SyncPoolSize             uint64 = 300
    FetchTimeout                    = 1 * time.Minute
    RetryInterval                   = 10 * time.Second
    CheckBlockHeightInterval        = 30 * time.Second
    CheckPrevBlockInterval          = 30 * time.Second
    WatchInterval                   = 5 * time.Second
)
const MaxRetries = 10

Variables

var ErrFinished = errors.New("Add: Pool is finished")

func SetLogging Uses

func SetLogging(level logging.Lvl, handler logging.Handler)

func Try Uses

func Try(maxRetries int, fn TryFunc) error

func TryForever Uses

func TryForever(fn TryFunc) error

type AfterFunc Uses

type AfterFunc = func(time.Duration) <-chan time.Time

type BlockFetcher Uses

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

func NewBlockFetcher Uses

func NewBlockFetcher(
    cm network.ConnectionManager,
    client Doer,
    st *storage.LevelDBBackend,
    localNode *node.LocalNode,
    opts ...BlockFetcherOption) *BlockFetcher

func (*BlockFetcher) Fetch Uses

func (f *BlockFetcher) Fetch(ctx context.Context, syncInfo *SyncInfo) (*SyncInfo, error)

type BlockFetcherOption Uses

type BlockFetcherOption = func(f *BlockFetcher)

type BlockValidator Uses

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

func NewBlockValidator Uses

func NewBlockValidator(ldb *storage.LevelDBBackend, tp *transaction.Pool, cfg common.Config, opts ...BlockValidatorOption) *BlockValidator

func (*BlockValidator) Validate Uses

func (v *BlockValidator) Validate(ctx context.Context, syncInfo *SyncInfo) error

type BlockValidatorOption Uses

type BlockValidatorOption func(*BlockValidator)

type Config Uses

type Config struct {
    SyncPoolSize             uint64
    FetchTimeout             time.Duration
    RetryInterval            time.Duration
    CheckBlockHeightInterval time.Duration
    CheckPrevBlockInterval   time.Duration
    WatchInterval            time.Duration
    // contains filtered or unexported fields
}

func NewConfig Uses

func NewConfig(localNode *node.LocalNode,
    st *storage.LevelDBBackend,
    cm network.ConnectionManager,
    tp *transaction.Pool,
    cfg common.Config) (*Config, error)

func (*Config) LoggingConfig Uses

func (c *Config) LoggingConfig()

func (*Config) NewFetcher Uses

func (c *Config) NewFetcher() Fetcher

func (*Config) NewHTTP2Client Uses

func (c *Config) NewHTTP2Client() *common.HTTP2Client

func (*Config) NewSyncer Uses

func (c *Config) NewSyncer() *Syncer

func (*Config) NewValidator Uses

func (c *Config) NewValidator() Validator

func (*Config) NewWatcher Uses

func (c *Config) NewWatcher(s SyncController) *Watcher

type Doer Uses

type Doer interface {
    Do(*http.Request) (*http.Response, error)
}

type Fetcher Uses

type Fetcher interface {
    Fetch(ctx context.Context, syncInfo *SyncInfo) (*SyncInfo, error)
}

type NodeList Uses

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

func (*NodeList) NodeAddrs Uses

func (l *NodeList) NodeAddrs() []string

func (*NodeList) SetLatestNodeAddrs Uses

func (l *NodeList) SetLatestNodeAddrs(addrs []string)

type Pool Uses

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

func NewPool Uses

func NewPool(n uint64) *Pool

func (*Pool) Add Uses

func (p *Pool) Add(ctx context.Context, f func()) error

func (*Pool) Finish Uses

func (p *Pool) Finish()

func (*Pool) TryAdd Uses

func (p *Pool) TryAdd(ctx context.Context, f func()) bool

type SyncController Uses

type SyncController interface {
    SetSyncTargetBlock(ctx context.Context, height uint64, nodeAddressList []string) error
}

type SyncInfo Uses

type SyncInfo struct {
    Height uint64
    Block  *block.Block
    Bts    []*block.BlockTransaction
    Ptx    *ballot.ProposerTransaction

    // Fetching target node addresses, NodeList is  the validators which
    // participated and confirmed the consensus of latest ballot.
    NodeList *NodeList
}

func (*SyncInfo) NodeAddrs Uses

func (s *SyncInfo) NodeAddrs() []string

type SyncProgress Uses

type SyncProgress struct {
    StartingBlock uint64 // Block number where sync began
    CurrentBlock  uint64 // Current block number where sync is at
    HighestBlock  uint64 // Highest alleged block number in the chain
}

type Syncer Uses

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

func NewSyncer Uses

func NewSyncer(
    f Fetcher,
    v Validator,
    st *storage.LevelDBBackend,
    opts ...SyncerOption) *Syncer

func (*Syncer) SetSyncTargetBlock Uses

func (s *Syncer) SetSyncTargetBlock(ctx context.Context, height uint64, nodeAddrs []string) error

func (*Syncer) Start Uses

func (s *Syncer) Start() error

func (*Syncer) Stop Uses

func (s *Syncer) Stop() error

func (*Syncer) SyncProgress Uses

func (s *Syncer) SyncProgress(ctx context.Context) (*SyncProgress, error)

type SyncerOption Uses

type SyncerOption func(s *Syncer)

type TryFunc Uses

type TryFunc func(attempt int) (retry bool, err error)

type Validator Uses

type Validator interface {
    Validate(context.Context, *SyncInfo) error
}

type Watcher Uses

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

func NewWatcher Uses

func NewWatcher(
    syncer SyncController,
    client Doer,
    cm network.ConnectionManager,
    st *storage.LevelDBBackend,
    ln *node.LocalNode,
    opts ...WatcherOption) *Watcher

func (*Watcher) SetLogger Uses

func (w *Watcher) SetLogger(l log15.Logger)

func (*Watcher) Start Uses

func (w *Watcher) Start() error

func (*Watcher) Stop Uses

func (w *Watcher) Stop() error

type WatcherOption Uses

type WatcherOption func(*Watcher)

Package sync imports 29 packages (graph) and is imported by 1 packages. Updated 2019-02-09. Refresh now. Tools for package owners.