refsync

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUntracked = fmt.Errorf("untracked repository")
)

Functions

func UpdateRepoUsingNote

func UpdateRepoUsingNote(
	gitBinPath string,
	refUpdateMaker push.MakeReferenceUpdateRequestPackFunc,
	note types.PushNote) error

UpdateRepoUsingNote updates a push note's target repo to match the state of the pushed references contained in it.

Types

type RefSync

type RefSync struct {
	RepoGetter          repo.GetLocalRepoFunc
	UpdateRepoUsingNote UpdateRepoUsingNoteFunc

	FinalizingRefs map[string]struct{}
	// contains filtered or unexported fields
}

RefSync implements RefSync. It provides the mechanism that synchronizes the state of a repository's reference based on push transactions in the blockchain. It reacts to newly processed push transactions, processing each references to change the state of a repository.

func New

func New(cfg *config.AppConfig,
	pool types.PushPool, fetcher fetcher.ObjectFetcherService,
	announcer dht2.AnnouncerService,
	keepers core.Keepers) *RefSync

New creates an instance of RefSync

func (*RefSync) CanSync

func (rs *RefSync) CanSync(namespace, repoName string) error

CanSync checks whether the target repository of a push transaction can be synchronized.

func (*RefSync) OnNewTx

func (rs *RefSync) OnNewTx(tx *txns.TxPush, targetRef string, txIndex int, height int64, doneCb func())

OnNewTx receives push transactions and adds non-delete pushed references to the task queue. targetRef is the pushed reference that will be queued. If unset, all references are queued. txIndex is the index of the transaction it its containing block. height is the block height that contains the transaction.

func (*RefSync) Stop

func (rs *RefSync) Stop()

Stop stops the syncer

func (*RefSync) Watch

func (rs *RefSync) Watch(repo, reference string, startHeight, endHeight uint64) error

Watch adds a repository to the watch queue

type TxHandlerFunc

type TxHandlerFunc func(*txns.TxPush, string, int, int64, func())

type UpdateRepoUsingNoteFunc

type UpdateRepoUsingNoteFunc func(
	gitBinPath string,
	refUpdateMaker push.MakeReferenceUpdateRequestPackFunc,
	note types.PushNote) error

UpdateRepoUsingNoteFunc describes a function for updating a repo using a push note

type Watcher

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

Watcher watches tracked repositories for new updates that have not been synchronized. It compares the last synced height of the tracked repository with the last network update height to tell when to start traversing the blockchain in search of updates.

func NewWatcher

func NewWatcher(cfg *config.AppConfig, txHandler TxHandlerFunc, keepers core.Keepers) *Watcher

NewWatcher creates an instance of Watcher

func (*Watcher) Do

func (w *Watcher) Do(task *rstypes.WatcherTask) error

Do finds push transactions that have not been applied to a repository.

func (*Watcher) HasTask

func (w *Watcher) HasTask() bool

HasTask checks whether there are one or more unprocessed tasks.

func (*Watcher) IsRunning

func (w *Watcher) IsRunning() bool

IsRunning checks if the watcher is running.

func (*Watcher) QueueSize

func (w *Watcher) QueueSize() int

QueueSize returns the size of the tasks queue

func (*Watcher) Start

func (w *Watcher) Start()

Start starts the workers. Panics if already started.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop stops the watcher

func (*Watcher) Watch

func (w *Watcher) Watch(repo, reference string, startHeight, endHeight uint64) error

Watch adds a repository to the watch queue. Returns ErrSkipped if same reference has been queued.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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