cmds

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: GPL-3.0 Imports: 44 Imported by: 0

Documentation

Overview

Package cmds provides command line tools.

Index

Constants

View Source
const (
	ProcessNameDigestAPI      = "digest_api"
	ProcessNameStartDigestAPI = "start_digest_api"
	HookNameSetLocalChannel   = "set_local_channel"
)
View Source
const (
	ProcessNameDigester      = "digester"
	ProcessNameStartDigester = "start_digester"
	HookNameDigesterFollowUp = "followup_digester"
)
View Source
const ProcessNameDigestDatabase = "digest_database"

Variables

View Source
var (
	ContextValueDigestDesign   util.ContextKey = "digest_design"
	ContextValueDigestDatabase util.ContextKey = "digest_database"
	ContextValueDigestNetwork  util.ContextKey = "digest_network"
	ContextValueDigester       util.ContextKey = "digester"
	ContextValueCurrencyPool   util.ContextKey = "currency_pool"
)
View Source
var (
	Hinters []hint.Hinter
	Types   []hint.Type
)
View Source
var (
	GenesisAccountKey = "genesis_account"
	GenesisBalanceKey = "genesis_balance"
)
View Source
var (
	ProcessorDigestAPI      pm.Process
	ProcessorStartDigestAPI pm.Process
)
View Source
var (
	ProcessorDigester      pm.Process
	ProcessorStartDigester pm.Process
)
View Source
var BaseNodeCommandHooks = func(cmd *BaseNodeCommand) []pm.Hook {
	return []pm.Hook{
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameEncoders,
			process.HookNameAddHinters, process.HookAddHinters(Types, Hinters)).
			SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			"load_digest_config", cmd.hookLoadDigestConfig).
			SetOverride(true).
			SetDir(process.HookNameConfigGenesisOperations, pm.HookDirAfter),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			"validate_digest_config", cmd.hookValidateDigestConfig).
			SetOverride(true).
			SetDir(process.HookNameValidateConfig, pm.HookDirAfter),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			process.HookNameConfigVerbose, hookVerboseConfig).
			SetOverride(true),
	}
}
View Source
var InitCommandHooks = func(cmd *InitCommand) []pm.Hook {
	genesisOperationHandlers := map[string]process.HookHandlerGenesisOperations{
		"genesis-currencies": GenesisOperationsHandlerGenesisCurrencies,
	}

	for k, v := range process.DefaultHookHandlersGenesisOperations {
		genesisOperationHandlers[k] = v
	}

	return []pm.Hook{
		pm.NewHook(pm.HookPrefixPre, process.ProcessNameProposalProcessor,
			"initialize_proposal_processor", cmd.hookInitializeProposalProcessor).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			process.HookNameConfigGenesisOperations, process.HookGenesisOperationFunc(genesisOperationHandlers)).
			SetOverride(true),
	}
}
View Source
var ProcessorDigestDatabase pm.Process
View Source
var RunCommandHooks = func(cmd *RunCommand) []pm.Hook {
	return []pm.Hook{
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameDatabase,
			"set_database", HookLoadCurrencies).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameNetwork,
			"set_currency_network_handlers", cmd.hookSetNetworkHandlers).SetOverride(true),
		pm.NewHook(pm.HookPrefixPre, process.ProcessNameProposalProcessor,
			"initialize_proposal_processor", HookInitializeProposalProcessor).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, ProcessNameDigestAPI,
			"set_digest_api_handlers", cmd.hookDigestAPIHandlers).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, ProcessNameDigester,
			"set_state_handler", cmd.hookSetStateHandler).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, ProcessNameDigester,
			HookNameDigesterFollowUp, HookDigesterFollowUp).SetOverride(true),
		pm.NewHook(pm.HookPrefixPre, ProcessNameDigestAPI,
			HookNameSetLocalChannel, currencycmds.HookSetLocalChannel).SetOverride(true),
	}
}
View Source
var RunCommandProcesses []pm.Process
View Source
var SendVars = kong.Vars{
	"node_url": "quic://localhost:54321",
}

Functions

func AttachProposalProcessor

func AttachProposalProcessor(
	policy *isaac.LocalPolicy,
	nodepool *network.Nodepool,
	suffrage base.Suffrage,
	cp *currency.CurrencyPool,
) (*blocksign.OperationProcessor, error)

func GenesisOperationsHandlerGenesisCurrencies

func GenesisOperationsHandlerGenesisCurrencies(
	ctx context.Context,
	m map[string]interface{},
) (operation.Operation, error)

func HookDigesterFollowUp

func HookDigesterFollowUp(ctx context.Context) (context.Context, error)

func HookInitializeProposalProcessor

func HookInitializeProposalProcessor(ctx context.Context) (context.Context, error)

func HookLoadCurrencies

func HookLoadCurrencies(ctx context.Context) (context.Context, error)

func InitializeProposalProcessor

func InitializeProposalProcessor(ctx context.Context, opr *blocksign.OperationProcessor) (context.Context, error)

func LoadCurrencyPoolContextValue

func LoadCurrencyPoolContextValue(ctx context.Context, l **currency.CurrencyPool) error

func LoadDatabaseContextValue

func LoadDatabaseContextValue(ctx context.Context, l **mongodbstorage.Database) error

func LoadDigestDatabaseContextValue

func LoadDigestDatabaseContextValue(ctx context.Context, l **digest.Database) error

func LoadDigestDesignContextValue

func LoadDigestDesignContextValue(ctx context.Context, l *currencycmds.DigestDesign) error

func LoadDigestNetworkContextValue

func LoadDigestNetworkContextValue(ctx context.Context, l **digest.HTTP2Server) error

func LoadDigesterContextValue

func LoadDigesterContextValue(ctx context.Context, l **digest.Digester) error

func ProcessDigestAPI

func ProcessDigestAPI(ctx context.Context) (context.Context, error)

func ProcessDigestDatabase

func ProcessDigestDatabase(ctx context.Context) (context.Context, error)

func ProcessDigester

func ProcessDigester(ctx context.Context) (context.Context, error)

func ProcessStartDigestAPI

func ProcessStartDigestAPI(ctx context.Context) (context.Context, error)

func ProcessStartDigester

func ProcessStartDigester(ctx context.Context) (context.Context, error)

Types

type BaseCommand

type BaseCommand struct {
	*mitumcmds.BaseCommand
	Out io.Writer `kong:"-"`
}

func NewBaseCommand

func NewBaseCommand(name string) *BaseCommand

type BaseNodeCommand

type BaseNodeCommand struct {
	*logging.Logging
}

func NewBaseNodeCommand

func NewBaseNodeCommand(l *logging.Logging) *BaseNodeCommand

func (*BaseNodeCommand) BaseProcesses

func (cmd *BaseNodeCommand) BaseProcesses(ps *pm.Processes) (*pm.Processes, error)

type CreateDocumentCommand

type CreateDocumentCommand struct {
	*BaseCommand
	currencycmds.OperationFlags
	Sender   currencycmds.AddressFlag    `arg:"" name:"sender" help:"sender address" required:""`
	FileHash string                      `arg:"" name:"filehash" help:"filehash" required:""`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:""`

	Signers []currencycmds.AddressFlag `name:"signers" help:"signers for document"`
	// Keys      []KeyFlag `name:"key" help:"key for new document account (ex: \"<public key>,<weight>\")" sep:"@"`
	Seal currencycmds.FileLoad `help:"seal" optional:""`
	// contains filtered or unexported fields
}

func NewCreateDocumentCommand

func NewCreateDocumentCommand() CreateDocumentCommand

func (*CreateDocumentCommand) Run

func (cmd *CreateDocumentCommand) Run(version util.Version) error

type FileHashFlag

type FileHashFlag struct {
	FH blocksign.FileHash
}

func (*FileHashFlag) String

func (v *FileHashFlag) String() string

func (*FileHashFlag) UnmarshalText

func (v *FileHashFlag) UnmarshalText(b []byte) error

type InitCommand

type InitCommand struct {
	*BaseNodeCommand
	*mitumcmds.InitCommand
}

func NewInitCommand

func NewInitCommand(dryrun bool) (InitCommand, error)

type NodeCommand

type NodeCommand struct {
	Init InitCommand                  `cmd:"" help:"initialize node"`
	Run  RunCommand                   `cmd:"" help:"run node"`
	Info currencycmds.NodeInfoCommand `cmd:"" help:"node information"`
}

func NewNodeCommand

func NewNodeCommand() (NodeCommand, error)

type OperationFlags

type OperationFlags struct {
	Privatekey currencycmds.PrivatekeyFlag `arg:"" name:"privatekey" help:"privatekey to sign operation" required:"true"`
	Token      string                      `help:"token for operation" optional:""`
	NetworkID  mitumcmds.NetworkIDFlag     `name:"network-id" help:"network-id" required:"true"`
	Memo       string                      `name:"memo" help:"memo"`
	Pretty     bool                        `name:"pretty" help:"pretty format"`
}

func (*OperationFlags) IsValid

func (op *OperationFlags) IsValid([]byte) error

type RunCommand

type RunCommand struct {
	*mitumcmds.RunCommand
	*BaseNodeCommand
}

func NewRunCommand

func NewRunCommand(dryrun bool) (RunCommand, error)

type SealCommand

type SealCommand struct {
	Send                  SendCommand                               `cmd:"" name:"send" help:"send seal to remote mitum node"`
	CreateAccount         currencycmds.CreateAccountCommand         `cmd:"" name:"create-account" help:"create new account"`
	CreateDocument        CreateDocumentCommand                     `cmd:"" name:"create-document" help:"create new document"`
	SignDocument          SignDocumentCommand                       `cmd:"" name:"sign-document" help:"sign document"`
	Transfer              currencycmds.TransferCommand              `cmd:"" name:"transfer" help:"transfer big"`
	TransferDocument      TransferDocumentCommand                   `cmd:"" name:"transfer-document" help:"transfer document"`
	KeyUpdater            currencycmds.KeyUpdaterCommand            `cmd:"" name:"key-updater" help:"update keys"`
	CurrencyRegister      currencycmds.CurrencyRegisterCommand      `cmd:"" name:"currency-register" help:"register new currency"`
	CurrencyPolicyUpdater currencycmds.CurrencyPolicyUpdaterCommand `cmd:"" name:"currency-policy-updater" help:"update currency policy"` // revive:disable-line:line-length-limit
	Sign                  currencycmds.SignSealCommand              `cmd:"" name:"sign" help:"sign seal"`
	SignFact              currencycmds.SignFactCommand              `cmd:"" name:"sign-fact" help:"sign facts of operation seal"`
}

func NewSealCommand

func NewSealCommand() SealCommand

type SendCommand

type SendCommand struct {
	*BaseCommand
	URL        []*url.URL                  `name:"node" help:"remote mitum url (default: ${node_url})" default:"${node_url}"` // nolint
	NetworkID  mitumcmds.NetworkIDFlag     `name:"network-id" help:"network-id" `
	Seal       currencycmds.FileLoad       `help:"seal" optional:""`
	DryRun     bool                        `help:"dry-run, print operation" optional:"" default:"false"`
	Pretty     bool                        `name:"pretty" help:"pretty format"`
	Privatekey currencycmds.PrivatekeyFlag `arg:"" name:"privatekey" help:"privatekey for sign"`
	Timeout    time.Duration               `name:"timeout" help:"timeout; default: 5s"`
	TLSInscure bool                        `name:"tls-insecure" help:"allow inseucre TLS connection; default is false"`
}

func NewSendCommand

func NewSendCommand() SendCommand

func (*SendCommand) Run

func (cmd *SendCommand) Run(version util.Version) error

type SignDocumentCommand

type SignDocumentCommand struct {
	*BaseCommand
	currencycmds.OperationFlags
	Sender   currencycmds.AddressFlag    `arg:"" name:"sender" help:"sender address" required:""`
	DocId    currencycmds.BigFlag        `arg:"" name:"documentid" help:"document id" required:""`
	Owner    currencycmds.AddressFlag    `arg:"" name:"owner" help:"owner address" required:""`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:""`
	Seal     currencycmds.FileLoad       `help:"seal" optional:""`
	// contains filtered or unexported fields
}

func NewSignDocumentCommand

func NewSignDocumentCommand() SignDocumentCommand

func (*SignDocumentCommand) Run

func (cmd *SignDocumentCommand) Run(version util.Version) error

type TransferDocumentCommand

type TransferDocumentCommand struct {
	*BaseCommand
	currencycmds.OperationFlags
	Sender   currencycmds.AddressFlag    `arg:"" name:"sender" help:"sender address" required:""`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:""`
	DocId    currencycmds.BigFlag        `arg:"" name:"documentid" help:"document id" required:""`
	Receiver currencycmds.AddressFlag    `arg:"" name:"reciever" help:"reciever address" required:""`
	Seal     currencycmds.FileLoad       `help:"seal" optional:""`
	// contains filtered or unexported fields
}

func NewTransferDocumentCommand

func NewTransferDocumentCommand() TransferDocumentCommand

func (*TransferDocumentCommand) Run

func (cmd *TransferDocumentCommand) Run(version util.Version) error

Jump to

Keyboard shortcuts

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