Documentation ¶
Index ¶
- func GenerateHasValidProof(proofVerifier func(proof *gossip.Proof) (bool, error)) chaintree.BlockValidatorFunc
- func HasBurnGenerator(ctx context.Context, ng *NotaryGroup) (chaintree.BlockValidatorFunc, error)
- func IsOwner(tree *dag.Dag, blockWithHeaders *chaintree.BlockWithHeaders) (bool, chaintree.CodedError)
- func IsTokenRecipient(tree *dag.Dag, blockWithHeaders *chaintree.BlockWithHeaders) (bool, chaintree.CodedError)
- func RegisterTransactor(name string, fn chaintree.TransactorFunc) error
- func RegisterValidatorGenerator(name string, fn ValidatorGenerator) error
- type CheckpointWrapper
- type Config
- type NotaryGroup
- func (ng *NotaryGroup) AddSigner(signer *Signer)
- func (ng *NotaryGroup) AllSigners() []*Signer
- func (ng *NotaryGroup) BlockValidators(ctx context.Context) ([]chaintree.BlockValidatorFunc, error)
- func (ng *NotaryGroup) Config() *Config
- func (ng *NotaryGroup) GetMajorityCount() int64
- func (ng *NotaryGroup) GetRandomSigner() *Signer
- func (ng *NotaryGroup) GetRandomSyncer() *actor.PID
- func (ng *NotaryGroup) IndexOfSigner(signer *Signer) uint64
- func (ng *NotaryGroup) QuorumCount() uint64
- func (ng *NotaryGroup) SetupAllRemoteActors(localKey *ecdsa.PublicKey)
- func (ng *NotaryGroup) SignerAtIndex(idx int) *Signer
- func (ng *NotaryGroup) Size() uint64
- type PublicKeySet
- type RoundConfirmationWrapper
- func (rc *RoundConfirmationWrapper) Data() []byte
- func (rc *RoundConfirmationWrapper) FetchCompletedRound(ctx context.Context) (*RoundWrapper, error)
- func (rc *RoundConfirmationWrapper) Height() uint64
- func (rc *RoundConfirmationWrapper) SetStore(store nodestore.DagStore)
- func (rc *RoundConfirmationWrapper) Value() *gossip.RoundConfirmation
- func (rc *RoundConfirmationWrapper) Wrapped() *cbornode.Node
- type RoundWrapper
- func (r *RoundWrapper) CID() cid.Cid
- func (r *RoundWrapper) FetchCheckpoint(ctx context.Context) (*CheckpointWrapper, error)
- func (r *RoundWrapper) FetchHamt(ctx context.Context) (*hamt.Node, error)
- func (r *RoundWrapper) Height() uint64
- func (r *RoundWrapper) SetStore(store nodestore.DagStore)
- func (r *RoundWrapper) Value() *gossip.Round
- func (r *RoundWrapper) Wrapped() *cbornode.Node
- type RoutableAddress
- type Signer
- type TomlConfig
- type TomlPublicKeySet
- type ValidatorGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateHasValidProof ¶
func GenerateHasValidProof(proofVerifier func(proof *gossip.Proof) (bool, error)) chaintree.BlockValidatorFunc
GenerateHasValidProof is a higher-order function that takes a proof verifier function arg and returns a proof validator function (see below) that calls the given proof verifier with the Proof and Tip it receives and uses its return values to indicate validity.
func HasBurnGenerator ¶
func HasBurnGenerator(ctx context.Context, ng *NotaryGroup) (chaintree.BlockValidatorFunc, error)
HasBurnGenerator is a higher-order generator (because we need notary group config for the token name) that returns a ChainTree validator that looks for the precense of a token burn in a block of transactions if the block has a transaction which has a SendToken with the config TransactionToken name, a value > 0 and a "" destination, it is considered a burn.
func IsOwner ¶
func IsOwner(tree *dag.Dag, blockWithHeaders *chaintree.BlockWithHeaders) (bool, chaintree.CodedError)
IsOwner is a chaintree BlockValidator that looks at the block headers and makes sure an authorized owner (in the consensus.TreePathForAuthentications path) has signed this block.
func IsTokenRecipient ¶
func IsTokenRecipient(tree *dag.Dag, blockWithHeaders *chaintree.BlockWithHeaders) (bool, chaintree.CodedError)
IsTokenRecipient is only applicable to RECEIVE_TOKEN transactions it checks whether the destination chaintree id matches our id or not
func RegisterTransactor ¶
func RegisterTransactor(name string, fn chaintree.TransactorFunc) error
RegisterTransactor is used to make transactors available for the human-readable configs
func RegisterValidatorGenerator ¶
func RegisterValidatorGenerator(name string, fn ValidatorGenerator) error
RegisterValidatorGenerator registers your validator generator with a human-readable name so that it can be specified in the on-disk configs.
Types ¶
type CheckpointWrapper ¶
type CheckpointWrapper struct {
// contains filtered or unexported fields
}
func WrapCheckpoint ¶
func WrapCheckpoint(c *gossip.Checkpoint) *CheckpointWrapper
func (*CheckpointWrapper) AddBlockRequests ¶
func (c *CheckpointWrapper) AddBlockRequests() [][]byte
func (*CheckpointWrapper) CID ¶
func (c *CheckpointWrapper) CID() cid.Cid
func (*CheckpointWrapper) Length ¶
func (c *CheckpointWrapper) Length() int
func (*CheckpointWrapper) Value ¶
func (c *CheckpointWrapper) Value() *gossip.Checkpoint
func (*CheckpointWrapper) Wrapped ¶
func (c *CheckpointWrapper) Wrapped() *cbornode.Node
type Config ¶
type Config struct { // ID of the notary group (generally a DID) ID string // TransactionToken is the token used for transaction fees (in the form <did>/<tokenName>) TransactionToken string // BurnAmount is the amount of TransactionToken that must be burned for the HasBurn block validator to pass BurnAmount uint64 // TransactionTopic is the topic used to send AddBlockRequests to the notary group TransactionTopic string // CommitTopic is the topic used to spread the CurrentStates (to both signers and clients) CommitTopic string // ValidatorGenerators is a slice of generators for chaintree.BlockValidatorFuncs (see ValidatorGenerator) ValidatorGenerators []ValidatorGenerator // Transactions is the map of all supported transactions by this notary group. Transactions map[transactions.Transaction_Type]chaintree.TransactorFunc // Signers is the set of VerKey and DestKey necessary to validate and reach a signer Signers []PublicKeySet //BootstrapAddresses is a slice of PeerIDs to use for bootstrapping this notary group BootstrapAddresses []string }
Config is the simplest thing that could work for now it is just an in-memory only configuration for the notary group.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns what we (as of this commit) use for our block validators GenerateHasValidProof is ommitted in this first round because it is a higher-order function that needs information from a closure not known to the notary group. it will be special cased over in tupelo and then migrated to this format.
func HumanConfigToConfig ¶
func HumanConfigToConfig(hc *config.NotaryGroup) (*Config, error)
func TomlToConfig ¶
TomlToConfig will load a notary group config from a toml string Generally these configs are nested and so you will rarely need to use this function, it's more to validate example files and to use in tests.
func (*Config) NotaryGroup ¶
func (c *Config) NotaryGroup(local *Signer) (*NotaryGroup, error)
type NotaryGroup ¶
type NotaryGroup struct { ID string Signers map[string]*Signer // contains filtered or unexported fields }
NotaryGroup represents a notary group.
func NewNotaryGroup ¶
func NewNotaryGroup(id string) *NotaryGroup
NewNotaryGroup instantiates a new NotaryGroup.
func NewNotaryGroupFromConfig ¶
func NewNotaryGroupFromConfig(c *Config) *NotaryGroup
func (*NotaryGroup) AddSigner ¶
func (ng *NotaryGroup) AddSigner(signer *Signer)
AddSigner adds a signer to group.
func (*NotaryGroup) AllSigners ¶
func (ng *NotaryGroup) AllSigners() []*Signer
func (*NotaryGroup) BlockValidators ¶
func (ng *NotaryGroup) BlockValidators(ctx context.Context) ([]chaintree.BlockValidatorFunc, error)
func (*NotaryGroup) Config ¶
func (ng *NotaryGroup) Config() *Config
func (*NotaryGroup) GetMajorityCount ¶
func (ng *NotaryGroup) GetMajorityCount() int64
func (*NotaryGroup) GetRandomSigner ¶
func (ng *NotaryGroup) GetRandomSigner() *Signer
func (*NotaryGroup) GetRandomSyncer ¶
func (ng *NotaryGroup) GetRandomSyncer() *actor.PID
func (*NotaryGroup) IndexOfSigner ¶
func (ng *NotaryGroup) IndexOfSigner(signer *Signer) uint64
func (*NotaryGroup) QuorumCount ¶
func (ng *NotaryGroup) QuorumCount() uint64
func (*NotaryGroup) SetupAllRemoteActors ¶
func (ng *NotaryGroup) SetupAllRemoteActors(localKey *ecdsa.PublicKey)
func (*NotaryGroup) SignerAtIndex ¶
func (ng *NotaryGroup) SignerAtIndex(idx int) *Signer
func (*NotaryGroup) Size ¶
func (ng *NotaryGroup) Size() uint64
type RoundConfirmationWrapper ¶
type RoundConfirmationWrapper struct {
// contains filtered or unexported fields
}
func WrapRoundConfirmation ¶
func WrapRoundConfirmation(conf *gossip.RoundConfirmation) *RoundConfirmationWrapper
func (*RoundConfirmationWrapper) Data ¶
func (rc *RoundConfirmationWrapper) Data() []byte
func (*RoundConfirmationWrapper) FetchCompletedRound ¶
func (rc *RoundConfirmationWrapper) FetchCompletedRound(ctx context.Context) (*RoundWrapper, error)
func (*RoundConfirmationWrapper) Height ¶
func (rc *RoundConfirmationWrapper) Height() uint64
func (*RoundConfirmationWrapper) SetStore ¶
func (rc *RoundConfirmationWrapper) SetStore(store nodestore.DagStore)
func (*RoundConfirmationWrapper) Value ¶
func (rc *RoundConfirmationWrapper) Value() *gossip.RoundConfirmation
func (*RoundConfirmationWrapper) Wrapped ¶
func (rc *RoundConfirmationWrapper) Wrapped() *cbornode.Node
type RoundWrapper ¶
type RoundWrapper struct {
// contains filtered or unexported fields
}
func WrapRound ¶
func WrapRound(round *gossip.Round) *RoundWrapper
func (*RoundWrapper) CID ¶
func (r *RoundWrapper) CID() cid.Cid
func (*RoundWrapper) FetchCheckpoint ¶
func (r *RoundWrapper) FetchCheckpoint(ctx context.Context) (*CheckpointWrapper, error)
func (*RoundWrapper) FetchHamt ¶
func (r *RoundWrapper) FetchHamt(ctx context.Context) (*hamt.Node, error)
func (*RoundWrapper) Height ¶
func (r *RoundWrapper) Height() uint64
func (*RoundWrapper) SetStore ¶
func (r *RoundWrapper) SetStore(store nodestore.DagStore)
func (*RoundWrapper) Value ¶
func (r *RoundWrapper) Value() *gossip.Round
func (*RoundWrapper) Wrapped ¶
func (r *RoundWrapper) Wrapped() *cbornode.Node
type RoutableAddress ¶
type RoutableAddress string
func NewRoutableAddress ¶
func NewRoutableAddress(from, to string) RoutableAddress
func (RoutableAddress) From ¶
func (ra RoutableAddress) From() string
func (RoutableAddress) String ¶
func (ra RoutableAddress) String() string
func (RoutableAddress) Swap ¶
func (ra RoutableAddress) Swap() RoutableAddress
func (RoutableAddress) To ¶
func (ra RoutableAddress) To() string
type Signer ¶
type TomlConfig ¶
type TomlConfig struct { *config.NotaryGroup Signers []TomlPublicKeySet }
type TomlPublicKeySet ¶
type ValidatorGenerator ¶
type ValidatorGenerator func(ctx context.Context, notaryGroup *NotaryGroup) (chaintree.BlockValidatorFunc, error)
ValidatorGenerator is a higher order function that is used to generate a chaintree.BlockValidator that knows about the context it's being executed in. Specifically this is useful when the BlockValidator needs to know things about the notary group (like the signers) or a config (like a token necessary for transactions) the config stores these generators and the notary group exposes a BlockValidators function in order to generate validators based on the current state of the notary group.
func WrapStatelessValidator ¶
func WrapStatelessValidator(fn chaintree.BlockValidatorFunc) ValidatorGenerator
WrapStatelessValidator is a convenience function when your BlockValidatorFunc does not need any state from the notary group or config. Currently IsOwner and IsTokenRecipient do not need any state and so this lets one easily wrap them.