types

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndorsedReference

type EndorsedReference struct {
	Hash []byte `json:"hash" msgpack:"hash,omitempty" mapstructure:"hash"`
}

EndorsedReference describes the current state of a reference endorsed by a host

type EndorsedReferences

type EndorsedReferences []*EndorsedReference

EndorsedReferences is a collection of EndorsedReference

func (*EndorsedReferences) ID

ID returns the id of the collection

type Endorsement

type Endorsement interface {
	// ID returns the hash of the object
	ID() util.Bytes32
	// Bytes returns a serialized version of the object
	Bytes() []byte
	// BytesAndID returns the serialized version of the tx and the id
	BytesAndID() ([]byte, util.Bytes32)
}

Endorsement represents a push endorsement

type Handler added in v0.0.29

type Handler interface {

	// WaitForPushTx waits for the final push transaction to be created and added to the mempool.
	//  - It will return error if the tx was rejected.
	//  - An error is returned if the tx was not successfully added to the pool after 15 minutes.
	WaitForPushTx() chan interface{}

	// HandleStream starts the process of handling a pushed packfile.
	//
	// It reads the pushed updates from the packfile, extracts useful
	// information and writes the update to gitReceive which is the
	// git-receive-pack process.
	//
	// Access the git-receive-pack process using gitReceiveCmd.
	//
	// pktEnc provides access to the git output encoder.
	HandleStream(packfile io.Reader, gitReceive io.WriteCloser, gitRcvCmd util.Cmd, pktEnc *pktline.Encoder) error

	// EnsureReferencesHaveTxDetail checks that each pushed reference
	// have a transaction detail that provide more information about
	// the transaction.
	EnsureReferencesHaveTxDetail() error

	// DoAuth performs authorization checks on the specified target reference.
	// If targetRef is unset, all references are checked. If ignorePostRefs is
	// true, post references like issue and merge references are not checked.
	DoAuth(ur *packp.ReferenceUpdateRequest, targetRef string, ignorePostRefs bool) error

	// HandleAuthorization performs authorization checks on all pushed references.
	HandleAuthorization(ur *packp.ReferenceUpdateRequest) error

	// HandleReferences process pushed references.
	HandleReferences() error

	// HandleGCAndSizeCheck  performs garbage collection and repo size validation.
	//
	// It will return error if repo size exceeds the allowed maximum.
	//
	// It will also reload the repository handle since GC makes
	// go-git internal state stale.
	HandleGCAndSizeCheck() error

	// HandleUpdate creates a push note to represent the push operation and
	// adds it to the push pool and then have it broadcast to peers.
	HandleUpdate(targetNote PushNote) error

	// HandleReference performs validation and update reversion for a single pushed reference.
	// // When revertOnly is true, only reversion operation is performed.
	HandleReference(ref string) []error

	// HandleReversion reverts the pushed references back to their pre-push state.
	HandleReversion() []error

	// HandlePushNote implements Handler by handing incoming push note
	HandlePushNote(note PushNote) (err error)
}

Handler describes an interface for handling incoming push updates.

type Note

type Note struct {
	util.CodecUtil       `json:"-" msgpack:"-" mapstructure:"-"`
	*coretypes.BasicMeta `json:"-" msgpack:"-" mapstructure:"-"`

	// TargetRepo is the target repo local instance
	TargetRepo types.LocalRepo `json:",flatten,omitempty" msgpack:"-" mapstructure:"-"`

	// RepoName is the name of the repo. If Namespace is set, it will be the
	// domain pointing to the actual repository.
	RepoName string `json:"repo,omitempty" msgpack:"repo,omitempty"`

	// Namespace is the namespace which the pusher is targeting.
	Namespace string `json:"namespace,omitempty" msgpack:"namespace,omitempty"`

	// References contains all references pushed
	References PushedReferences `json:"references,omitempty" msgpack:"references,omitempty"`

	// PushKeyID is the push key ID of the pusher
	PushKeyID util.Bytes `json:"pusherKeyId,omitempty" msgpack:"pusherKeyId,omitempty"`

	// PusherAddress is the Address of the pusher
	PusherAddress identifier.Address `json:"pusherAddr,omitempty" msgpack:"pusherAddr,omitempty"`

	// Size is the size of all objects pushed
	Size uint64 `json:"size,omitempty" msgpack:"size,omitempty"`

	// Timestamp is the unix timestamp
	Timestamp int64 `json:"timestamp,omitempty" msgpack:"timestamp,omitempty"`

	// PusherAcctNonce is the next nonce of the pusher's account
	PusherAcctNonce uint64 `json:"accountNonce,omitempty" msgpack:"accountNonce,omitempty"`

	// RemoteNodeSig is the signature of the note creator
	RemoteNodeSig util.Bytes `json:"creatorSig,omitempty" msgpack:"creatorSig,omitempty"`

	// RemotePubKey is the public key of the note creator/signer
	CreatorPubKey util.Bytes32 `json:"creatorPubKey,omitempty" msgpack:"creatorPubKey,omitempty"`

	// FromPeer indicates that the note was received from a remote
	// peer and not created by the local node
	FromRemotePeer bool `json:"-" msgpack:"-"`
	// contains filtered or unexported fields
}

Note PushNote implements types.PushNote

func (*Note) Bytes

func (pt *Note) Bytes(recompute ...bool) []byte

Bytes returns a serialized version of the object. If this function was previously called, the cached output from the previous call is returned instead of re-serializing the object. Set recompute to true to force re-serialization.

func (*Note) BytesAndID

func (pt *Note) BytesAndID(recompute ...bool) ([]byte, util.Bytes32)

BytesAndID returns the serialized version of the tx and the id

func (*Note) BytesNoCache

func (pt *Note) BytesNoCache() []byte

BytesNoCache returns the serialized version of the object but does not cache it.

func (*Note) BytesNoSig

func (pt *Note) BytesNoSig() []byte

BytesNoSig returns a serialized version of the object without the signature

func (*Note) DecodeMsgpack

func (pt *Note) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements msgpack.CustomDecoder

func (*Note) EncodeMsgpack

func (pt *Note) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements msgpack.CustomEncoder

func (*Note) GetCreatorPubKey

func (pt *Note) GetCreatorPubKey() util.Bytes32

GetCreatorPubKey returns the note creator's public key

func (*Note) GetEcoSize

func (pt *Note) GetEcoSize() uint64

GetEcoSize returns a size of the push note used for economics calculation.

func (*Note) GetFee

func (pt *Note) GetFee() util.String

GetFee returns the total push fee

func (*Note) GetNamespace

func (pt *Note) GetNamespace() string

GetNamespace returns the target namespace

func (*Note) GetNodeSignature

func (pt *Note) GetNodeSignature() []byte

GetNodeSignature returns the push note signature

func (*Note) GetPushedReferences

func (pt *Note) GetPushedReferences() PushedReferences

GetPushedReferences returns the pushed references

func (*Note) GetPusherAccountNonce

func (pt *Note) GetPusherAccountNonce() uint64

GetPusherAccountNonce returns the pusher account nonce

func (*Note) GetPusherAddress

func (pt *Note) GetPusherAddress() identifier.Address

GetPusherAddress returns the pusher's address

func (*Note) GetPusherKeyID

func (pt *Note) GetPusherKeyID() []byte

GetPusherKeyID returns the pusher key ID

func (*Note) GetPusherKeyIDString

func (pt *Note) GetPusherKeyIDString() string

GetPusherKeyIDString is like GetPusherKeyID but returns hex string, prefixed with 0x

func (*Note) GetRepoName

func (pt *Note) GetRepoName() string

GetRepoName returns the name of the repo receiving the push

func (*Note) GetSize

func (pt *Note) GetSize() uint64

GetSize returns the total pushed objects size

func (*Note) GetTargetRepo

func (pt *Note) GetTargetRepo() types.LocalRepo

GetTargetRepo returns the target repository

func (*Note) GetTimestamp

func (pt *Note) GetTimestamp() int64

GetTimestamp returns the timestamp

func (*Note) GetValue

func (pt *Note) GetValue() util.String

GetValue returns the total value

func (*Note) ID

func (pt *Note) ID(recompute ...bool) util.Bytes32

ID returns the hash of the push note

func (*Note) IsFromRemotePeer

func (pt *Note) IsFromRemotePeer() bool

IsFromRemotePeer checks whether the note was sent by a remote peer

func (*Note) Len

func (pt *Note) Len() uint64

Len returns the length of the serialized tx

func (*Note) SetTargetRepo

func (pt *Note) SetTargetRepo(repo types.LocalRepo)

SetTargetRepo returns the target repository

func (*Note) SizeForFeeCal

func (pt *Note) SizeForFeeCal() uint64

SizeForFeeCal is the size of the transaction + pushed objects

func (*Note) ToMap

func (pt *Note) ToMap() map[string]interface{}

ToMap returns the map equivalent of the note

func (*Note) TxSize

func (pt *Note) TxSize() uint

TxSize is the size of the transaction

type PushEndorsement

type PushEndorsement struct {
	util.CodecUtil `json:"-" msgpack:"-" mapstructure:"-"`

	// NoteID is the ID of the push note to be endorsed.
	NoteID util.Bytes `json:"noteID" msgpack:"noteID,omitempty" mapstructure:"noteID"`

	// References contains the current hash of the push references
	References EndorsedReferences `json:"refs" msgpack:"refs,omitempty" mapstructure:"refs"`

	// EndorserPubKey is the public key of the endorser
	EndorserPubKey util.Bytes32 `json:"pubKey" msgpack:"pubKey,omitempty" mapstructure:"pubKey"`

	// SigBLS is a 64 bytes BLS signature created using the BLS key of the endorser.
	SigBLS []byte `json:"sigBLS" msgpack:"sigBLS,omitempty" mapstructure:"sigBLS"`
}

PushEndorsement Endorsement is used to endorse a push note

func (*PushEndorsement) Bytes

func (e *PushEndorsement) Bytes() []byte

Bytes returns a serialized version of the object

func (*PushEndorsement) BytesAndID

func (e *PushEndorsement) BytesAndID() ([]byte, util.Bytes32)

BytesAndID returns the serialized version of the tx and the id

func (*PushEndorsement) BytesForBLSSig

func (e *PushEndorsement) BytesForBLSSig() []byte

BytesForBLSSig returns the serialized version of the endorsement for creating BLS signature. It will not include the following fields: SigBLS and EndorserPubKey.

func (*PushEndorsement) BytesForSig

func (e *PushEndorsement) BytesForSig() []byte

BytesForSig returns the serialized version of the endorsement for creating BLS signature. It will not include the following fields: SigBLS

func (*PushEndorsement) Clone

func (e *PushEndorsement) Clone() *PushEndorsement

Clone clones the object

func (*PushEndorsement) DecodeMsgpack

func (e *PushEndorsement) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements msgpack.CustomDecoder

func (*PushEndorsement) EncodeMsgpack

func (e *PushEndorsement) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements msgpack.CustomEncoder

func (*PushEndorsement) ID

func (e *PushEndorsement) ID() util.Bytes32

ID returns the hash of the object

type PushNote

type PushNote interface {
	coretypes.Meta
	GetTargetRepo() types.LocalRepo
	SetTargetRepo(repo types.LocalRepo)
	GetPusherKeyID() []byte
	GetPusherAddress() identifier.Address
	GetPusherAccountNonce() uint64
	GetPusherKeyIDString() string
	EncodeMsgpack(enc *msgpack.Encoder) error
	DecodeMsgpack(dec *msgpack.Decoder) error
	Bytes(recompute ...bool) []byte
	BytesNoCache() []byte
	BytesNoSig() []byte
	GetEcoSize() uint64
	GetCreatorPubKey() util.Bytes32
	GetNodeSignature() []byte
	GetRepoName() string
	GetNamespace() string
	GetTimestamp() int64
	GetPushedReferences() PushedReferences
	Len() uint64
	ID(recompute ...bool) util.Bytes32
	BytesAndID(recompute ...bool) ([]byte, util.Bytes32)
	TxSize() uint
	SizeForFeeCal() uint64
	GetSize() uint64
	GetFee() util.String
	GetValue() util.String
	IsFromRemotePeer() bool
}

type PushPool

type PushPool interface {

	// Add Register a push transaction to the pool.
	//
	// Check all the references to ensure there are no identical (same repo,
	// reference and nonce) references with same nonce in the pool. A valid
	// reference is one which has no identical reference with a higher fee rate in
	// the pool. If an identical reference exist in the pool with an inferior fee
	// rate, the existing tx holding the reference is eligible for replacable by tx
	// holding the reference with a superior fee rate. In cases where more than one
	// reference of tx is superior to multiple references in multiple transactions,
	// replacement will only happen if the fee rate of tx is higher than the
	// combined fee rate of the replaceable transactions.
	//
	// noValidation disables tx validation
	Add(note PushNote) error

	// Full returns true if the pool is full
	Full() bool

	// Get finds and returns a push note
	Get(noteID string) *Note

	// Len returns the number of items in the pool
	Len() int

	// Remove removes a push note
	Remove(pushNote PushNote)

	// HasSeen checks whether a note with the given ID was recently added
	HasSeen(noteID string) bool
}

PushPool represents a pool for ordering git push transactions

type PushedReference

type PushedReference struct {
	util.CodecUtil  `json:"-" msgpack:"-" mapstructure:"-"`
	Name            string               `json:"name,omitempty" msgpack:"name,omitempty"`       // The full name of the reference
	OldHash         string               `json:"oldHash,omitempty" msgpack:"oldHash,omitempty"` // The hash of the reference before the push
	NewHash         string               `json:"newHash,omitempty" msgpack:"newHash,omitempty"` // The hash of the reference after the push
	Nonce           uint64               `json:"nonce,omitempty" msgpack:"nonce,omitempty"`     // The next repo nonce of the reference
	MergeProposalID string               `json:"mergeID,omitempty" msgpack:"mergeID,omitempty"` // The merge proposal ID the reference is compliant with.
	Fee             util.String          `json:"fee,omitempty" msgpack:"fee,omitempty"`         // The network fee to pay for pushing the reference
	Value           util.String          `json:"value,omitempty" msgpack:"value,omitempty"`     // Additional fee to pay for special operation
	PushSig         util.Bytes           `json:"pushSig,omitempty" msgpack:"pushSig,omitempty"` // The signature of from the push request token
	Data            *types.ReferenceData `json:"data,omitempty" msgpack:"data,omitempty"`       // Contains updates to the reference data
}

PushedReference represents a reference that was pushed by git client

func (*PushedReference) DecodeMsgpack

func (pr *PushedReference) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements msgpack.CustomDecoder

func (*PushedReference) EncodeMsgpack

func (pr *PushedReference) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements msgpack.CustomEncoder

func (*PushedReference) IsDeletable

func (pr *PushedReference) IsDeletable() bool

IsDeletable checks whether the pushed reference can be deleted

type PushedReferences

type PushedReferences []*PushedReference

PushedReferences represents a collection of pushed references

func (*PushedReferences) GetByName

func (pf *PushedReferences) GetByName(name string) *PushedReference

GetByName finds a pushed reference by name

func (*PushedReferences) Names

func (pf *PushedReferences) Names() (names []string)

Names returns the names of the references

Jump to

Keyboard shortcuts

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