Documentation ¶
Index ¶
- Constants
- Variables
- func RunAndCleanup(cmd *cobra.Command, args []string, constructor CommandConstructor) (err error)
- type Command
- type CommandConstructor
- type Components
- func (components *Components) AtomicStorage() escrow.AtomicStorage
- func (components *Components) Blockchain() *blockchain.Processor
- func (components *Components) Close()
- func (components *Components) DB() *bbolt.DB
- func (components *Components) EscrowPaymentHandler() handler.PaymentHandler
- func (components *Components) EtcdClient() *etcddb.EtcdClient
- func (components *Components) EtcdServer() *etcddb.EtcdServer
- func (components *Components) GrpcInterceptor() grpc.StreamServerInterceptor
- func (components *Components) PaymentChannelService() escrow.PaymentChannelService
- func (components *Components) PaymentChannelStateService() (service *escrow.PaymentChannelStateService)
Constants ¶
View Source
const ( ClaimChannelIdFlag = "channel-id" ClaimPaymentIdFlag = "payment-id" ClaimSendBackFlag = "send-back" ClaimTimeoutFlag = "timeout" )
Variables ¶
View Source
var ClaimCmd = &cobra.Command{ Use: "claim", Short: "Claim money from payment channel", Long: "Command gets latest payment from channel, moves payment to in-progress state" + " and writes payment transaction to the blockchain. Channel nonce is" + " updated and client should start using new nonce. User can specify --timeout" + " for blockchain writing. If payment was not written before timeout then writing" + " operation can be restarted using --payment-id option. See 'snetd list claims' to" + " list payments in progress.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newClaimCommand) }, }
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "Write default configuration to file", Long: "Use this command to create default configuration file. Then update the file with your settings.", Run: func(cmd *cobra.Command, args []string) { var err error var configFile = cmd.Flags().Lookup("config").Value.String() log.WithField("configFile", configFile).Info("Writing default configuration to the file") if isFileExist(configFile) { log.WithField("configFile", configFile).Fatal("configFile already exists, please remove file first") } err = config.WriteConfig(configFile) if err != nil { log.WithError(err).WithField("configFile", configFile).Fatal("Cannot write default configuration") } }, }
View Source
var ListChannelsCmd = &cobra.Command{ Use: "channels", Short: "List payment channels", Long: "List payment channels for which at least on payment was received." + " User can use 'snetd claim --channel-id' command to claim funds from channel.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newListChannelsCommand) }, }
ListChannelsCmd shows list of channels from shared storage
View Source
var ListClaimsCmd = &cobra.Command{ Use: "claims", Short: "List payments which are not written to blockchain yet", Long: "List payments which are in progress state and not written" + " to the blockchain. 'snetd claim --payment-id' command can be" + " used to retry writing to the blockchain.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newListClaimsCommand) }, }
ListClaimsCmd shows list of channels from shared storage
View Source
var ListCmd = &cobra.Command{
Use: "list",
Short: "List channels, claims in progress, etc",
Long: "List command prints lists of objects from the shared storage; each object type has separate subcommand",
}
ListCmd command to list channels, claims, etc
View Source
var RootCmd = &cobra.Command{ Use: "snetd", Run: func(cmd *cobra.Command, args []string) { if command, _, err := cmd.Find(args); err != nil && command != nil { command.Execute() } else { ServeCmd.Run(cmd, args) } }, }
View Source
var ServeCmd = &cobra.Command{ Use: "serve", Run: func(cmd *cobra.Command, args []string) { var err error components := InitComponents(cmd) defer components.Close() etcdServer := components.EtcdServer() if etcdServer == nil { log.Info("Etcd server is disabled in the config file.") } err = logger.InitLogger(config.SubWithDefault(config.Vip(), config.LogKey)) if err != nil { log.WithError(err).Fatal("Unable to initialize logger") } config.LogConfig() var d daemon d, err = newDaemon(components) if err != nil { log.WithError(err).Fatal("Unable to initialize daemon") } d.start() defer d.stop() sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT) <-sigChan log.Debug("exiting") }, }
Functions ¶
func RunAndCleanup ¶ added in v0.1.2
func RunAndCleanup(cmd *cobra.Command, args []string, constructor CommandConstructor) (err error)
RunAndCleanup initializes components, constructs command, runs it, cleanups components and returns results
Types ¶
type Command ¶ added in v0.1.2
type Command interface {
Run() error
}
Command is an CLI command abstraction
type CommandConstructor ¶ added in v0.1.2
type CommandConstructor func(cmd *cobra.Command, args []string, components *Components) (command Command, err error)
CommandConstructor creates new command using command line arguments, cobra context and initialized components
type Components ¶ added in v0.1.2
type Components struct {
// contains filtered or unexported fields
}
func InitComponents ¶ added in v0.1.2
func InitComponents(cmd *cobra.Command) (components *Components)
func (*Components) AtomicStorage ¶ added in v0.1.2
func (components *Components) AtomicStorage() escrow.AtomicStorage
func (*Components) Blockchain ¶ added in v0.1.2
func (components *Components) Blockchain() *blockchain.Processor
func (*Components) Close ¶ added in v0.1.2
func (components *Components) Close()
func (*Components) DB ¶ added in v0.1.2
func (components *Components) DB() *bbolt.DB
func (*Components) EscrowPaymentHandler ¶ added in v0.1.2
func (components *Components) EscrowPaymentHandler() handler.PaymentHandler
func (*Components) EtcdClient ¶ added in v0.1.2
func (components *Components) EtcdClient() *etcddb.EtcdClient
func (*Components) EtcdServer ¶ added in v0.1.2
func (components *Components) EtcdServer() *etcddb.EtcdServer
func (*Components) GrpcInterceptor ¶ added in v0.1.2
func (components *Components) GrpcInterceptor() grpc.StreamServerInterceptor
func (*Components) PaymentChannelService ¶ added in v0.1.2
func (components *Components) PaymentChannelService() escrow.PaymentChannelService
func (*Components) PaymentChannelStateService ¶ added in v0.1.2
func (components *Components) PaymentChannelStateService() (service *escrow.PaymentChannelStateService)
Click to show internal directories.
Click to hide internal directories.