// newCounters is a "constructor" for counters objects func newCounters() *counters { c := new(counters) c.logger = shim.NewLogger("counters:<uninitialized>") c.length = map[string]uint64{} c.count = map[string]uint64{} return c }
// initParms handles the initialization of `parms`. func (c *counters) initParms(stub *shim.ChaincodeStub, args []string) (val []byte, err error) { c.infof("initParms : Command-line arguments : %v", args) // Define and parse the parameters flags := flag.NewFlagSet("initParms", flag.ContinueOnError) flags.StringVar(&c.id, "id", "", "A unique identifier; Allows multiple copies of this chaincode to be deployed") loggingLevel := flags.String("loggingLevel", "default", "The logging level of the chaincode logger. Defaults to INFO.") shimLoggingLevel := flags.String("shimLoggingLevel", "default", "The logging level of the chaincode 'shim' interface. Defaults to WARNING.") flags.BoolVar(&c.checkCounters, "checkCounters", false, "Default false. If true, consistency checks are made on counter states during increment/decrement.") flags.BoolVar(&c.checkStatus, "checkStatus", true, "Default true; If false, no error/consistency checks are made in the 'status' method.") err = flags.Parse(args) if err != nil { c.errorf("initParms : Error during option processing : %s", err) } // Replace the original logger logging as "counters", with a new logger, // then set its logging level and the logging level of the shim. c.logger = shim.NewLogger("counters:" + c.id) if *loggingLevel == "default" { c.logger.SetLevel(shim.LogInfo) } else { level, _ := shim.LogLevel(*loggingLevel) c.logger.SetLevel(level) } if *shimLoggingLevel != "default" { level, _ := shim.LogLevel(*shimLoggingLevel) shim.SetLoggingLevel(level) } return }
// initParms handles the initialization of `parms`. func (c *counters) initParms(args []string) (val []byte, err error) { c.infof("initParms : Command-line arguments : %v", args) // Define and parse the parameters flags := flag.NewFlagSet("initParms", flag.ContinueOnError) flags.StringVar(&c.id, "id", "", "A unique identifier; Allows multiple copies of this chaincode to be deployed") loggingLevel := flags.String("loggingLevel", "default", "The logging level of the chaincode logger. Defaults to INFO.") shimLoggingLevel := flags.String("shimLoggingLevel", "default", "The logging level of the chaincode 'shim' interface. Defaults to WARNING.") err = flags.Parse(args) if err != nil { c.errorf("initParms : Error during option processing : %s", err) } // Replace the original logger, logging as "counters", with a new logger // logging as "counters:<id>", then set its logging level and the logging // level of the shim. c.logger = shim.NewLogger("counters:" + c.id) if *loggingLevel == "default" { c.logger.SetLevel(shim.LogInfo) } else { level, _ := shim.LogLevel(*loggingLevel) c.logger.SetLevel(level) } if *shimLoggingLevel != "default" { level, _ := shim.LogLevel(*shimLoggingLevel) shim.SetLoggingLevel(level) } return }
*/ package noop import ( "encoding/base64" "errors" "fmt" "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/core/chaincode/shim" ld "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/protos" ) var logger = shim.NewLogger("noop") type ledgerHandler interface { GetTransactionByUUID(txUUID string) (*protos.Transaction, error) } // SystemChaincode is type representing the chaincode // In general, one should not use vars in memory that can hold state // across invokes but this is used JUST for MOCKING type SystemChaincode struct { mockLedgerH ledgerHandler } func (t *SystemChaincode) getLedger() ledgerHandler { if t.mockLedgerH == nil { lh, err := ld.GetLedger()
// newCounters is a "constructor" for counters objects func newCounters() *counters { c := new(counters) c.logger = shim.NewLogger("counters:<uninitialized>") return c }