_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29400 | WithLedger | train | func WithLedger(ledger servicemocks.Ledger) Opt {
return func(opts *Opts) {
opts.Ledger = ledger
}
} | go | {
"resource": ""
} |
q29401 | WithResults | train | func WithResults(funcResults ...*OperationResult) Opt {
return func(opts *Opts) {
opts.Operations = make(map[Operation]ResultDesc)
for _, fr := range funcResults {
opts.Operations[fr.Operation] = ResultDesc{Result: fr.Result, ErrMsg: fr.ErrMessage}
}
}
} | go | {
"resource": ""
} |
q29402 | LoadPKCS11ContextHandle | train | func LoadPKCS11ContextHandle(lib, label, pin string, opts ...Options) (*ContextHandle, error) {
return getInstance(&pkcs11CtxCacheKey{lib: lib, label: label, pin: pin, opts: getCtxOpts(opts...)}, false)
} | go | {
"resource": ""
} |
q29403 | ReloadPKCS11ContextHandle | train | func ReloadPKCS11ContextHandle(lib, label, pin string, opts ...Options) (*ContextHandle, error) {
return getInstance(&pkcs11CtxCacheKey{lib: lib, label: label, pin: pin, opts: getCtxOpts(opts...)}, true)
} | go | {
"resource": ""
} |
q29404 | LoadContextAndLogin | train | func LoadContextAndLogin(lib, pin, label string) (*ContextHandle, error) {
pkcs11Context, err := LoadPKCS11ContextHandle(lib, label, pin)
if err != nil {
return nil, err
}
session, err := pkcs11Context.OpenSession()
if err != nil {
return nil, err
}
err = pkcs11Context.Login(session)
if err != nil {
ret... | go | {
"resource": ""
} |
q29405 | Login | train | func (handle *ContextHandle) Login(session mPkcs11.SessionHandle) error {
handle.lock.RLock()
defer handle.lock.RUnlock()
if handle.pin == "" {
return errors.New("No PIN set")
}
err := handle.ctx.Login(session, mPkcs11.CKU_USER, handle.pin)
if err != nil && err != mPkcs11.Error(mPkcs11.CKR_USER_ALREADY_LOGGED... | go | {
"resource": ""
} |
q29406 | ReturnSession | train | func (handle *ContextHandle) ReturnSession(session mPkcs11.SessionHandle) {
handle.lock.RLock()
defer handle.lock.RUnlock()
_, e := handle.ctx.GetSessionInfo(session)
if e != nil {
logger.Warnf("not returning session [%d], due to error [%s]. Discarding it", session, e)
e = handle.ctx.CloseSession(session)
i... | go | {
"resource": ""
} |
q29407 | GetSession | train | func (handle *ContextHandle) GetSession() (session mPkcs11.SessionHandle) {
handle.lock.RLock()
select {
case session = <-handle.sessions:
logger.Debugf("Reusing existing pkcs11 session %+v on slot %d\n", session, handle.slot)
default:
// cache is empty (or completely in use), create a new session
s, err :=... | go | {
"resource": ""
} |
q29408 | FindObjects | train | func (handle *ContextHandle) FindObjects(session mPkcs11.SessionHandle, max int) ([]mPkcs11.ObjectHandle, bool, error) {
handle.lock.RLock()
defer handle.lock.RUnlock()
return handle.ctx.FindObjects(session, max)
} | go | {
"resource": ""
} |
q29409 | CopyObject | train | func (handle *ContextHandle) CopyObject(sh mPkcs11.SessionHandle, o mPkcs11.ObjectHandle, temp []*mPkcs11.Attribute) (mPkcs11.ObjectHandle, error) {
handle.lock.RLock()
defer handle.lock.RUnlock()
return handle.ctx.CopyObject(sh, o, temp)
} | go | {
"resource": ""
} |
q29410 | FindKeyPairFromSKI | train | func (handle *ContextHandle) FindKeyPairFromSKI(session mPkcs11.SessionHandle, ski []byte, keyType bool) (*mPkcs11.ObjectHandle, error) {
handle.lock.RLock()
defer handle.lock.RUnlock()
return cachebridge.GetKeyPairFromSessionSKI(&cachebridge.KeyPairCacheKey{Mod: handle.ctx, Session: session, SKI: ski, KeyType: key... | go | {
"resource": ""
} |
q29411 | validateSession | train | func (handle *ContextHandle) validateSession(currentSession mPkcs11.SessionHandle) mPkcs11.SessionHandle {
handle.lock.RLock()
e := handle.detectErrorCondition(currentSession)
switch e {
case errSlotIDChanged,
mPkcs11.Error(mPkcs11.CKR_OBJECT_HANDLE_INVALID),
mPkcs11.Error(mPkcs11.CKR_SESSION_HANDLE_INVALID)... | go | {
"resource": ""
} |
q29412 | detectErrorCondition | train | func (handle *ContextHandle) detectErrorCondition(currentSession mPkcs11.SessionHandle) error {
var e error
slot, ok := handle.findSlot(handle.ctx)
if !ok || slot != handle.slot {
e = errSlotIDChanged
}
if e == nil {
_, e = handle.ctx.GetSessionInfo(currentSession)
if e == nil {
_, e = handle.ctx.GetOper... | go | {
"resource": ""
} |
q29413 | sendNotification | train | func (handle *ContextHandle) sendNotification() {
if handle.reloadNotification != nil {
select {
case handle.reloadNotification <- struct{}{}:
logger.Info("Notification sent for recreated pkcs11 ctx")
default:
logger.Warn("Unable to send notification for recreated pkcs11 ctx")
}
}
} | go | {
"resource": ""
} |
q29414 | disposePKCS11Ctx | train | func (handle *ContextHandle) disposePKCS11Ctx() {
//ignore error on close all sessions
err := handle.ctx.CloseAllSessions(handle.slot)
if err != nil {
logger.Warnf("Unable to close session", err)
}
//clear cache
cachebridge.ClearAllSession()
//Initialize context
err = handle.ctx.Finalize()
if err != nil {
... | go | {
"resource": ""
} |
q29415 | createNewPKCS11Ctx | train | func (handle *ContextHandle) createNewPKCS11Ctx() *mPkcs11.Ctx {
newCtx := mPkcs11.New(handle.lib)
if newCtx == nil {
logger.Warn("Failed to recreate new context for given library")
return nil
}
//initialize new context
err := newCtx.Initialize()
if err != nil {
if err != mPkcs11.Error(mPkcs11.CKR_CRYPTOKI... | go | {
"resource": ""
} |
q29416 | findSlot | train | func (handle *ContextHandle) findSlot(ctx *mPkcs11.Ctx) (uint, bool) {
var found bool
var slot uint
//get all slots
slots, err := ctx.GetSlotList(true)
if err != nil {
logger.Warn("Failed to get slot list for recreated context:", err)
return slot, found
}
//find slot matching label
for _, s := range slot... | go | {
"resource": ""
} |
q29417 | String | train | func (key *pkcs11CtxCacheKey) String() string {
return fmt.Sprintf("%x_%s_%s_%d_%d", key.lib, key.label, key.opts.connectionName, key.opts.sessionCacheSize, key.opts.openSessionRetry)
} | go | {
"resource": ""
} |
q29418 | getInstance | train | func getInstance(key lazycache.Key, reload bool) (*ContextHandle, error) {
once.Do(func() {
ctxCache = newCtxCache()
//anyway, loading first time, no need to reload
reload = false
})
if reload {
ctxCache.Delete(key)
}
ref, err := ctxCache.Get(key)
if err != nil {
return nil, errors.WithMessage(err, "... | go | {
"resource": ""
} |
q29419 | finalizer | train | func finalizer() lazyref.Finalizer {
return func(v interface{}) {
if handle, ok := v.(*ContextHandle); ok {
err := handle.ctx.CloseAllSessions(handle.slot)
if err != nil {
logger.Warnf("unable to close all sessions in finalizer for [%s, %s] : %s", handle.lib, handle.label, err)
}
err = handle.ctx.Fin... | go | {
"resource": ""
} |
q29420 | loadLibInitializer | train | func loadLibInitializer() lazycache.EntryInitializer {
return func(key lazycache.Key) (interface{}, error) {
ctxKey := key.(*pkcs11CtxCacheKey)
var slot uint
logger.Debugf("Loading pkcs11 library [%s]\n", ctxKey.lib)
if ctxKey.lib == "" {
return &ContextHandle{}, errors.New("No PKCS11 library default")
}... | go | {
"resource": ""
} |
q29421 | New | train | func New(channelID string, options ...Option) (*ChannelConfig, error) {
opts, err := prepareOpts(options...)
if err != nil {
return nil, err
}
return &ChannelConfig{channelID: channelID, opts: opts}, nil
} | go | {
"resource": ""
} |
q29422 | Query | train | func (c *ChannelConfig) Query(reqCtx reqContext.Context) (fab.ChannelCfg, error) {
if c.opts.Orderer != nil {
return c.queryOrderer(reqCtx)
}
return c.queryPeers(reqCtx)
} | go | {
"resource": ""
} |
q29423 | WithPeers | train | func WithPeers(peers []fab.Peer) Option {
return func(opts *Opts) error {
opts.Targets = peers
return nil
}
} | go | {
"resource": ""
} |
q29424 | WithMinResponses | train | func WithMinResponses(min int) Option {
return func(opts *Opts) error {
opts.MinResponses = min
return nil
}
} | go | {
"resource": ""
} |
q29425 | WithOrderer | train | func WithOrderer(orderer fab.Orderer) Option {
return func(opts *Opts) error {
opts.Orderer = orderer
return nil
}
} | go | {
"resource": ""
} |
q29426 | WithMaxTargets | train | func WithMaxTargets(maxTargets int) Option {
return func(opts *Opts) error {
opts.MaxTargets = maxTargets
return nil
}
} | go | {
"resource": ""
} |
q29427 | WithRetryOpts | train | func WithRetryOpts(retryOpts retry.Opts) Option {
return func(opts *Opts) error {
opts.RetryOpts = retryOpts
return nil
}
} | go | {
"resource": ""
} |
q29428 | prepareOpts | train | func prepareOpts(options ...Option) (Opts, error) {
opts := Opts{}
for _, option := range options {
err := option(&opts)
if err != nil {
return opts, errors.WithMessage(err, "Failed to read query config opts")
}
}
return opts, nil
} | go | {
"resource": ""
} |
q29429 | randomMaxTargets | train | func randomMaxTargets(targets []fab.ProposalProcessor, max int) []fab.ProposalProcessor {
if len(targets) <= max {
return targets
}
for i := range targets {
j := rand.Intn(i + 1)
targets[i], targets[j] = targets[j], targets[i]
}
return targets[:max]
} | go | {
"resource": ""
} |
q29430 | getOptsByConfig | train | func getOptsByConfig(c core.CryptoSuiteConfig) *pkcs11.PKCS11Opts {
pkks := pkcs11.FileKeystoreOpts{KeyStorePath: c.KeyStorePath()}
opts := &pkcs11.PKCS11Opts{
SecLevel: c.SecurityLevel(),
HashFamily: c.SecurityAlgorithm(),
FileKeystore: &pkks,
Library: c.SecurityProviderLibPath(),
Pin: ... | go | {
"resource": ""
} |
q29431 | NewSeekEvent | train | func NewSeekEvent(seekInfo *ab.SeekInfo, errch chan<- error) *SeekEvent {
return &SeekEvent{
SeekInfo: seekInfo,
ErrCh: errch,
}
} | go | {
"resource": ""
} |
q29432 | NewRefCache | train | func NewRefCache(opts ...options.Opt) *lazycache.Cache {
initializer := func(key lazycache.Key) (interface{}, error) {
ck, ok := key.(CacheKey)
if !ok {
return nil, errors.New("unexpected cache key")
}
return NewRef(ck.Context(), ck.Provider(), ck.ChannelID(), opts...), nil
}
return lazycache.New("Channe... | go | {
"resource": ""
} |
q29433 | BlockHeight | train | func (e *EventEndpoint) BlockHeight() uint64 {
peerState, ok := e.Peer.(fab.PeerState)
if !ok {
return 0
}
return peerState.BlockHeight()
} | go | {
"resource": ""
} |
q29434 | FromPeerConfig | train | func FromPeerConfig(config fab.EndpointConfig, peer fab.Peer, peerCfg *fab.PeerConfig) *EventEndpoint {
opts := comm.OptsFromPeerConfig(peerCfg)
opts = append(opts, comm.WithConnectTimeout(config.Timeout(fab.PeerConnection)))
return &EventEndpoint{
Peer: peer,
opts: opts,
}
} | go | {
"resource": ""
} |
q29435 | NewSimpleMockBlock | train | func NewSimpleMockBlock() *common.Block {
return &common.Block{
Data: &common.BlockData{
Data: [][]byte{[]byte("test")},
},
Header: &common.BlockHeader{
DataHash: []byte(""),
PreviousHash: []byte(""),
Number: 1,
},
Metadata: &common.BlockMetadata{
Metadata: [][]byte{[]byte("test")},
... | go | {
"resource": ""
} |
q29436 | Build | train | func (b *MockConfigBlockBuilder) Build() *common.Block {
return &common.Block{
Header: &common.BlockHeader{
Number: b.Index,
},
Metadata: b.buildBlockMetadata(),
Data: &common.BlockData{
Data: b.buildBlockEnvelopeBytes(),
},
}
} | go | {
"resource": ""
} |
q29437 | Build | train | func (b *MockConfigUpdateEnvelopeBuilder) Build() *common.Envelope {
return &common.Envelope{
Payload: marshalOrPanic(b.buildPayload()),
}
} | go | {
"resource": ""
} |
q29438 | CreateBlockWithCCEvent | train | func CreateBlockWithCCEvent(events *pp.ChaincodeEvent, txID string,
channelID string) (*common.Block, error) {
return CreateBlockWithCCEventAndTxStatus(events, txID, channelID, pp.TxValidationCode_VALID)
} | go | {
"resource": ""
} |
q29439 | CreateBlockWithCCEventAndTxStatus | train | func CreateBlockWithCCEventAndTxStatus(events *pp.ChaincodeEvent, txID string,
channelID string, txValidationCode pp.TxValidationCode) (*common.Block, error) {
chdr := &common.ChannelHeader{
Type: int32(common.HeaderType_ENDORSER_TRANSACTION),
Version: 1,
Timestamp: ×tamp.Timestamp{
Seconds: time.Now... | go | {
"resource": ""
} |
q29440 | newBlock | train | func newBlock(seqNum uint64, previousHash []byte) *common.Block {
block := &common.Block{}
block.Header = &common.BlockHeader{}
block.Header.Number = seqNum
block.Header.PreviousHash = previousHash
block.Data = &common.BlockData{}
var metadataContents [][]byte
for i := 0; i < len(common.BlockMetadataIndex_name)... | go | {
"resource": ""
} |
q29441 | NewService | train | func NewService(discovery fab.DiscoveryService) (fab.SelectionService, error) {
return &SelectionService{discoveryService: discovery}, nil
} | go | {
"resource": ""
} |
q29442 | GetEndorsersForChaincode | train | func (s *SelectionService) GetEndorsersForChaincode(chaincodes []*fab.ChaincodeCall, opts ...copts.Opt) ([]fab.Peer, error) {
params := options.NewParams(opts)
channelPeers, err := s.discoveryService.GetPeers()
if err != nil {
logger.Errorf("Error retrieving peers from discovery service: %s", err)
return nil, n... | go | {
"resource": ""
} |
q29443 | Store | train | func (s *MemoryUserStore) Store(user *msp.UserData) error {
s.store[user.ID+"@"+user.MSPID] = user.EnrollmentCertificate
return nil
} | go | {
"resource": ""
} |
q29444 | Load | train | func (s *MemoryUserStore) Load(id msp.IdentityIdentifier) (*msp.UserData, error) {
cert, ok := s.store[id.ID+"@"+id.MSPID]
if !ok {
return nil, msp.ErrUserNotFound
}
userData := msp.UserData{
ID: id.ID,
MSPID: id.MSPID,
EnrollmentCertificate: cert,
}
return &userData, ni... | go | {
"resource": ""
} |
q29445 | NewMemoryKeyStore | train | func NewMemoryKeyStore(password []byte) *MemoryKeyStore {
store := make(map[string]bccsp.Key)
return &MemoryKeyStore{store: store, password: password}
} | go | {
"resource": ""
} |
q29446 | GetKey | train | func (s *MemoryKeyStore) GetKey(ski []byte) (bccsp.Key, error) {
key, ok := s.store[hex.EncodeToString(ski)]
if !ok {
return nil, fmt.Errorf("Key not found [%s]", ski)
}
return key, nil
} | go | {
"resource": ""
} |
q29447 | StoreKey | train | func (s *MemoryKeyStore) StoreKey(key bccsp.Key) error {
ski := hex.EncodeToString(key.SKI())
s.store[ski] = key
return nil
} | go | {
"resource": ""
} |
q29448 | NewRegisterBlockEvent | train | func NewRegisterBlockEvent(filter fab.BlockFilter, eventch chan<- *fab.BlockEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterBlockEvent {
return &RegisterBlockEvent{
Reg: &BlockReg{Filter: filter, Eventch: eventch},
RegisterEvent: NewRegisterEvent(respch, errCh),
}
} | go | {
"resource": ""
} |
q29449 | NewRegisterFilteredBlockEvent | train | func NewRegisterFilteredBlockEvent(eventch chan<- *fab.FilteredBlockEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterFilteredBlockEvent {
return &RegisterFilteredBlockEvent{
Reg: &FilteredBlockReg{Eventch: eventch},
RegisterEvent: NewRegisterEvent(respch, errCh),
}
} | go | {
"resource": ""
} |
q29450 | NewRegisterChaincodeEvent | train | func NewRegisterChaincodeEvent(ccID, eventFilter string, eventch chan<- *fab.CCEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterChaincodeEvent {
return &RegisterChaincodeEvent{
Reg: &ChaincodeReg{
ChaincodeID: ccID,
EventFilter: eventFilter,
Eventch: eventch,
},
RegisterEvent: New... | go | {
"resource": ""
} |
q29451 | NewRegisterTxStatusEvent | train | func NewRegisterTxStatusEvent(txID string, eventch chan<- *fab.TxStatusEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterTxStatusEvent {
return &RegisterTxStatusEvent{
Reg: &TxStatusReg{TxID: txID, Eventch: eventch},
RegisterEvent: NewRegisterEvent(respch, errCh),
}
} | go | {
"resource": ""
} |
q29452 | NewRegisterEvent | train | func NewRegisterEvent(respch chan<- fab.Registration, errCh chan<- error) RegisterEvent {
return RegisterEvent{
RegCh: respch,
ErrCh: errCh,
}
} | go | {
"resource": ""
} |
q29453 | NewBlockEvent | train | func NewBlockEvent(block *cb.Block, sourceURL string) *fab.BlockEvent {
return &fab.BlockEvent{
Block: block,
SourceURL: sourceURL,
}
} | go | {
"resource": ""
} |
q29454 | NewFilteredBlockEvent | train | func NewFilteredBlockEvent(fblock *pb.FilteredBlock, sourceURL string) *fab.FilteredBlockEvent {
return &fab.FilteredBlockEvent{
FilteredBlock: fblock,
SourceURL: sourceURL,
}
} | go | {
"resource": ""
} |
q29455 | NewChaincodeEvent | train | func NewChaincodeEvent(chaincodeID, eventName, txID string, payload []byte, blockNum uint64, sourceURL string) *fab.CCEvent {
return &fab.CCEvent{
ChaincodeID: chaincodeID,
EventName: eventName,
TxID: txID,
Payload: payload,
BlockNumber: blockNum,
SourceURL: sourceURL,
}
} | go | {
"resource": ""
} |
q29456 | NewTxStatusEvent | train | func NewTxStatusEvent(txID string, txValidationCode pb.TxValidationCode, blockNum uint64, sourceURL string) *fab.TxStatusEvent {
return &fab.TxStatusEvent{
TxID: txID,
TxValidationCode: txValidationCode,
BlockNumber: blockNum,
SourceURL: sourceURL,
}
} | go | {
"resource": ""
} |
q29457 | NewTransferEvent | train | func NewTransferEvent(snapshotch chan<- fab.EventSnapshot, errch chan<- error) *TransferEvent {
return &TransferEvent{
ErrCh: errch,
SnapshotCh: snapshotch,
}
} | go | {
"resource": ""
} |
q29458 | NewStopAndTransferEvent | train | func NewStopAndTransferEvent(snapshotch chan<- fab.EventSnapshot, errch chan<- error) *StopAndTransferEvent {
return &StopAndTransferEvent{
ErrCh: errch,
SnapshotCh: snapshotch,
}
} | go | {
"resource": ""
} |
q29459 | Lookup | train | func (c *defConfigBackend) Lookup(key string) (interface{}, bool) {
value := c.configViper.Get(key)
if value == nil {
return nil, false
}
return value, true
} | go | {
"resource": ""
} |
q29460 | loadTemplateConfig | train | func (c *defConfigBackend) loadTemplateConfig() error {
// get Environment Default Config Path
templatePath := c.opts.templatePath
if templatePath == "" {
return nil
}
// if set, use it to load default config
c.configViper.AddConfigPath(pathvar.Subst(templatePath))
err := c.configViper.ReadInConfig() // Find ... | go | {
"resource": ""
} |
q29461 | NewMockSelectionService | train | func NewMockSelectionService(err error, peers ...fab.Peer) *MockSelectionService {
return &MockSelectionService{Error: err, Peers: peers}
} | go | {
"resource": ""
} |
q29462 | ProcessProposal | train | func (m *MockEndorserServer) ProcessProposal(context context.Context,
proposal *pb.SignedProposal) (*pb.ProposalResponse, error) {
if m.ProposalError == nil {
return &pb.ProposalResponse{Response: &pb.Response{
Status: 200,
}, Endorsement: &pb.Endorsement{Endorser: []byte("endorser"), Signature: []byte("signat... | go | {
"resource": ""
} |
q29463 | anyNil | train | func anyNil(objs ...interface{}) bool {
for _, p := range objs {
if p == nil {
return true
}
}
return false
} | go | {
"resource": ""
} |
q29464 | Initialize | train | func Initialize(l api.LoggerProvider) {
loggerProviderOnce.Do(func() {
loggerProviderInstance = l
logger := loggerProviderInstance.GetLogger(loggerModule)
logger.Debug("Logger provider initialized")
// TODO
// use custom leveler implementation (otherwise fallback to default)
// levelerProvider, ok := log... | go | {
"resource": ""
} |
q29465 | Fatalf | train | func (l *Logger) Fatalf(format string, args ...interface{}) {
l.logger().Fatalf(format, args...)
} | go | {
"resource": ""
} |
q29466 | Panicf | train | func (l *Logger) Panicf(format string, args ...interface{}) {
l.logger().Panicf(format, args...)
} | go | {
"resource": ""
} |
q29467 | Printf | train | func (l *Logger) Printf(format string, args ...interface{}) {
l.logger().Printf(format, args...)
} | go | {
"resource": ""
} |
q29468 | Debugf | train | func (l *Logger) Debugf(format string, args ...interface{}) {
l.logger().Debugf(format, args...)
} | go | {
"resource": ""
} |
q29469 | Infof | train | func (l *Logger) Infof(format string, args ...interface{}) {
l.logger().Infof(format, args...)
} | go | {
"resource": ""
} |
q29470 | Warnf | train | func (l *Logger) Warnf(format string, args ...interface{}) {
l.logger().Warnf(format, args...)
} | go | {
"resource": ""
} |
q29471 | Errorf | train | func (l *Logger) Errorf(format string, args ...interface{}) {
l.logger().Errorf(format, args...)
} | go | {
"resource": ""
} |
q29472 | ParseLevel | train | func ParseLevel(level string) (api.Level, error) {
for i, name := range levelNames {
if strings.EqualFold(name, level) {
return api.Level(i), nil
}
}
return api.ERROR, errors.New("logger: invalid log level")
} | go | {
"resource": ""
} |
q29473 | Random | train | func Random() Balancer {
logger.Debugf("Creating Random balancer")
return func(peers []fab.Peer) []fab.Peer {
logger.Debugf("Load balancing %d peers using Random strategy...", len(peers))
balancedPeers := make([]fab.Peer, len(peers))
for i, index := range rand.Perm(len(peers)) {
balancedPeers[i] = peers[ind... | go | {
"resource": ""
} |
q29474 | RoundRobin | train | func RoundRobin() Balancer {
logger.Debugf("Creating Round-robin balancer")
counter := rollingcounter.New()
return func(peers []fab.Peer) []fab.Peer {
logger.Debugf("Load balancing %d peers using Round-Robin strategy...", len(peers))
index := counter.Next(len(peers))
balancedPeers := make([]fab.Peer, len(peer... | go | {
"resource": ""
} |
q29475 | WithUser | train | func WithUser(username string) ContextOption {
return func(o *identityOptions) error {
o.username = username
return nil
}
} | go | {
"resource": ""
} |
q29476 | WithIdentity | train | func WithIdentity(signingIdentity msp.SigningIdentity) ContextOption {
return func(o *identityOptions) error {
o.signingIdentity = signingIdentity
return nil
}
} | go | {
"resource": ""
} |
q29477 | WithOrg | train | func WithOrg(org string) ContextOption {
return func(o *identityOptions) error {
o.orgName = org
return nil
}
} | go | {
"resource": ""
} |
q29478 | WithEventConsumerBufferSize | train | func WithEventConsumerBufferSize(value uint) options.Opt {
return func(p options.Params) {
if setter, ok := p.(eventConsumerBufferSizeSetter); ok {
setter.SetEventConsumerBufferSize(value)
}
}
} | go | {
"resource": ""
} |
q29479 | WithSnapshot | train | func WithSnapshot(value fab.EventSnapshot) options.Opt {
return func(p options.Params) {
if setter, ok := p.(snapshotSetter); ok {
err := setter.SetSnapshot(value)
if err != nil {
logger.Errorf("Unable to set snapshot: %s", err)
}
}
}
} | go | {
"resource": ""
} |
q29480 | New | train | func New(initializer Initializer) *Value {
f := &Value{
initializer: initializer,
}
f.Lock()
return f
} | go | {
"resource": ""
} |
q29481 | Initialize | train | func (f *Value) Initialize() (interface{}, error) {
value, err := f.initializer()
f.set(value, err)
f.Unlock()
return value, err
} | go | {
"resource": ""
} |
q29482 | MustGet | train | func (f *Value) MustGet() interface{} {
value, err := f.Get()
if err != nil {
panic(fmt.Sprintf("get returned error: %s", err))
}
return value
} | go | {
"resource": ""
} |
q29483 | IsSet | train | func (f *Value) IsSet() bool {
p := atomic.LoadPointer(&f.ref)
return p != nil
} | go | {
"resource": ""
} |
q29484 | CreateEventService | train | func (f *MockInfraProvider) CreateEventService(ic fab.ClientContext, channelID string, opts ...options.Opt) (fab.EventService, error) {
panic("not implemented")
} | go | {
"resource": ""
} |
q29485 | CreateChannelCfg | train | func (f *MockInfraProvider) CreateChannelCfg(ctx fab.ClientContext, name string) (fab.ChannelCfg, error) {
return nil, nil
} | go | {
"resource": ""
} |
q29486 | CreateChannelMembership | train | func (f *MockInfraProvider) CreateChannelMembership(ctx fab.ClientContext, channel string) (fab.ChannelMembership, error) {
return nil, fmt.Errorf("Not implemented")
} | go | {
"resource": ""
} |
q29487 | CreateChannelConfig | train | func (f *MockInfraProvider) CreateChannelConfig(channelID string) (fab.ChannelConfig, error) {
return nil, nil
} | go | {
"resource": ""
} |
q29488 | New | train | func New(ctx contextAPI.Client, channelID string, discovery fab.DiscoveryService, opts ...coptions.Opt) (*Service, error) {
options := params{retryOpts: defaultRetryOpts}
coptions.Apply(&options, opts)
if options.refreshInterval == 0 {
options.refreshInterval = ctx.EndpointConfig().Timeout(fab.SelectionServiceRef... | go | {
"resource": ""
} |
q29489 | GetSuite | train | func GetSuite(securityLevel int, hashFamily string, keyStore bccsp.KeyStore) (core.CryptoSuite, error) {
bccsp, err := sw.NewWithParams(securityLevel, hashFamily, keyStore)
if err != nil {
return nil, err
}
return wrapper.NewCryptoSuite(bccsp), nil
} | go | {
"resource": ""
} |
q29490 | getOptsByConfig | train | func getOptsByConfig(c core.CryptoSuiteConfig) *bccspSw.SwOpts {
opts := &bccspSw.SwOpts{
HashFamily: c.SecurityAlgorithm(),
SecLevel: c.SecurityLevel(),
FileKeystore: &bccspSw.FileKeystoreOpts{
KeyStorePath: c.KeyStorePath(),
},
}
logger.Debug("Initialized SW cryptosuite")
return opts
} | go | {
"resource": ""
} |
q29491 | GetSigningIdentity | train | func (m *MockMSP) GetSigningIdentity(identifier *msp.IdentityIdentifier) (msp.SigningIdentity, error) {
return nil, nil
} | go | {
"resource": ""
} |
q29492 | SatisfiesPrincipal | train | func (m *MockMSP) SatisfiesPrincipal(id msp.Identity, principal *msp_protos.MSPPrincipal) error {
return nil
} | go | {
"resource": ""
} |
q29493 | NewMockDeliverServerWithDeliveries | train | func NewMockDeliverServerWithDeliveries(d <-chan *cb.Block) *MockDeliverServer {
return &MockDeliverServer{
status: cb.Status_UNKNOWN,
deliveries: d,
}
} | go | {
"resource": ""
} |
q29494 | NewMockDeliverServerWithFilteredDeliveries | train | func NewMockDeliverServerWithFilteredDeliveries(d <-chan *pb.FilteredBlock) *MockDeliverServer {
return &MockDeliverServer{
status: cb.Status_UNKNOWN,
filteredDeliveries: d,
}
} | go | {
"resource": ""
} |
q29495 | SetStatus | train | func (s *MockDeliverServer) SetStatus(status cb.Status) {
s.Lock()
defer s.Unlock()
s.status = status
} | go | {
"resource": ""
} |
q29496 | Status | train | func (s *MockDeliverServer) Status() cb.Status {
s.RLock()
defer s.RUnlock()
return s.status
} | go | {
"resource": ""
} |
q29497 | Disconnect | train | func (s *MockDeliverServer) Disconnect(err error) {
s.Lock()
defer s.Unlock()
s.disconnErr = err
} | go | {
"resource": ""
} |
q29498 | Deliver | train | func (s *MockDeliverServer) Deliver(srv pb.Deliver_DeliverServer) error {
status := s.Status()
if status != cb.Status_UNKNOWN {
err := srv.Send(&pb.DeliverResponse{
Type: &pb.DeliverResponse_Status{
Status: status,
},
})
return errors.Errorf("returning error status: %s %s", status, err)
}
disconnect... | go | {
"resource": ""
} |
q29499 | DeliverFiltered | train | func (s *MockDeliverServer) DeliverFiltered(srv pb.Deliver_DeliverFilteredServer) error {
if s.status != cb.Status_UNKNOWN {
err1 := srv.Send(&pb.DeliverResponse{
Type: &pb.DeliverResponse_Status{
Status: s.status,
},
})
return errors.Errorf("returning error status: %s %s", s.status, err1)
}
disconne... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.