anchors

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AnchorIDLength is the length in bytes of the AnchorID
	AnchorIDLength = 32

	// DocumentRootLength is the length in bytes of the DocumentRoot
	DocumentRootLength = 32
)
View Source
const (
	// BootstrappedAnchorService is used as a key to map the configured anchor service through context.
	BootstrappedAnchorService string = "BootstrappedAnchorService"

	// ErrAnchorRepoNotInitialised is a sentinel error when repository is not initialised
	ErrAnchorRepoNotInitialised = errors.Error("anchor repository not initialised")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnchorData added in v1.0.0

type AnchorData struct {
	AnchorID     types.Hash `json:"id"`
	DocumentRoot types.Hash `json:"doc_root"`
	BlockNumber  uint32     `json:"anchored_block"`
}

AnchorData holds data returned from previously anchored data against centchain

type AnchorID

type AnchorID [AnchorIDLength]byte

AnchorID type is byte array of length AnchorIDLength

func ToAnchorID

func ToAnchorID(bytes []byte) (AnchorID, error)

ToAnchorID convert the bytes into AnchorID type returns an error if the bytes length != AnchorIDLength

func (*AnchorID) BigInt

func (a *AnchorID) BigInt() *big.Int

BigInt returns anchorID in bigInt form

func (*AnchorID) String

func (a *AnchorID) String() string

String returns anchorID in string form

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrapper.Bootstrapper for package requirement initialisations.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error

Bootstrap initializes the anchorRepositoryContract as well as the anchorConfirmationTask that depends on it. the anchorConfirmationTask is added to be registered on the Queue at queue.Bootstrapper.

type Config

type Config interface {
	GetEthereumContextWaitTimeout() time.Duration
	GetEthereumGasLimit(op config.ContractOp) uint64
	GetCentChainAnchorLifespan() time.Duration
}

Config defines required functions for the package Anchors

type DocumentRoot

type DocumentRoot [DocumentRootLength]byte

DocumentRoot type is byte array of length DocumentRootLength

func ToDocumentRoot

func ToDocumentRoot(bytes []byte) (DocumentRoot, error)

ToDocumentRoot converts bytes to DocumentRoot returns error if the bytes length != DocumentRootLength

type Service added in v1.0.0

type Service interface {

	// PreCommitAnchor takes a lock to write the next anchorID using signingRoot as a proof
	PreCommitAnchor(ctx context.Context, anchorID AnchorID, signingRoot DocumentRoot) (err error)

	// CommitAnchor commits the document with given anchorID. If there is a precommit for this anchorID,
	// proof is used to verify before committing the anchor
	CommitAnchor(ctx context.Context, anchorID AnchorID, documentRoot DocumentRoot, proof [32]byte) error

	// GetAnchorData takes an anchorID and returns the corresponding documentRoot from the chain.
	GetAnchorData(anchorID AnchorID) (docRoot DocumentRoot, anchoredTime time.Time, err error)
}

Service defines a set of functions that can be implemented by any type that stores and retrieves the anchoring, and pre anchoring details.

Jump to

Keyboard shortcuts

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