gitbe

package
v0.0.0-...-db4ab52 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: ISC Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Following are what should be well-known interface hooks
	PluginPostHookEdit = "postedit" // Hook Post Edit

	// Authorize vote actions
	AuthVoteActionAuthorize = "authorize" // Authorize a proposal vote
	AuthVoteActionRevoke    = "revoke"    // Revoke a proposal vote authorization
)
View Source
const (
	// LockDuration is the maximum lock time duration allowed.  15 seconds
	// is ~3x of anchoring without internet delay.
	LockDuration = 15 * time.Second

	// defaultUnvettedPath is the landing zone for unvetted content.
	DefaultUnvettedPath = "unvetted"

	// defaultVettedPath is the publicly visible git vetted record repo.
	DefaultVettedPath = "vetted"

	// defaultJournalsPath is the path where data is journaled and/or
	// cached.
	DefaultJournalsPath = "journals" // XXX it looks like this belongs in plugins

)

Variables

View Source
var (
	ErrBusy     = fmt.Errorf("busy")
	ErrNotFound = fmt.Errorf("not found")
	ErrSameFile = fmt.Errorf("source same as destination")
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func New

func New(anp *chaincfg.Params, root string, fnotimeHost string, gitPath string, id *identity.FullIdentity, gitTrace bool) (*gitBackEnd, error)

New returns a gitBackEnd context. It verifies that git is installed.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type Anchor

type Anchor struct {
	Type     AnchorType // Type of anchor this record represents
	Time     int64      // OS time when record was created
	Digests  [][]byte   // All digests that were merkled to get to key of record
	Messages []string   // All one-line Commit messages

}

type AnchorType

type AnchorType uint32

AnchorType discriminates between the various Anchor record types.

const (
	AnchorInvalid    AnchorType = 0 // Invalid anchor
	AnchorUnverified AnchorType = 1 // Unverified anchor
	AnchorVerified   AnchorType = 2 // Verified anchor
)

type CastVoteJournal

type CastVoteJournal struct {
	CastVote foneroplugin.CastVote `json:"castvote"` // Client side vote
	Receipt  string                `json:"receipt"`  // Signature of CastVote.Signature
}

type FlushRecord

type FlushRecord struct {
	Version   string `json:"version"`   // Version
	Timestamp string `json:"timestamp"` // Timestamp
}

FlushRecord is a structure that is stored on disk when a journal has been flushed.

type GitCommit

type GitCommit struct {
	Hash    string
	Time    int64
	Message []string
	Error   error
}

type Journal

type Journal struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Journal is a generic 1:N file journaler. It uses an in memory mutex to coordinate all actions on disk. The journaler assumes text files that are "\n" delineated.

func NewJournal

func NewJournal() *Journal

NewJournal creates a new Journal context. One can use a single journal context for many journals.

func (*Journal) Close

func (j *Journal) Close(filename string) error

Close closes the underlying journal file. If the journal file is not found the function returns ErrNotFound.

func (*Journal) Copy

func (j *Journal) Copy(source, destination string) (err error)

Copy copies a journal file from source to destination. During the copy process the source file remains locked. This call has the same error semantics as the Open call.

func (*Journal) Journal

func (j *Journal) Journal(filename, content string) error

Journal writes content to a journal file. Note that content should not be bigger than bufio.Scanner can read per line. If the user does not provide "\n" at the end of content string, this function appends it.

func (*Journal) Open

func (j *Journal) Open(filename string) error

Open opens a journal file ready for replay. Once done replaying the journal the journal file needs to be closed. Note that if the journal is open writes return ErrBusy.

func (*Journal) Replay

func (j *Journal) Replay(filename string, replay func(string) error) error

Replay reads a single line from the journal file and calls the replay function that was provided. If the scanner encounters EOF it returns EOF, unlike the scanner API.

type JournalAction

type JournalAction struct {
	Version string `json:"version"` // Version
	Action  string `json:"action"`  // Add/Del
}

JournalAction prefixes and determines what the next structure is in the JSON journal. Version is used to determine what version of the comment journal structure follows. journalActionAdd -> Add entry journalActionDel -> Delete entry journalActionAddLike -> Add comment like structure (comments only)

type LastAnchor

type LastAnchor struct {
	Last   []byte // Last git digest that was anchored
	Time   int64  // OS time when record was created
	Merkle []byte // Merkle root that points to Anchor record, if valid
}

LastAnchor stores the last commit anchored in fnotime.

type UnconfirmedAnchor

type UnconfirmedAnchor struct {
	Merkles [][]byte // List of Merkle root that points to Anchor records
}

UnconfirmedAnchor stores Merkle roots of anchors that have not been confirmed yet by fnotime.

Jump to

Keyboard shortcuts

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