debug

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 24 Imported by: 1

Documentation

Overview

Package debug contains

  • chaincode interface definition
  • chaincode gateway definition
  • chaincode service to cckit router registration func

Package debug is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	DebugStateChaincode_StateClean = "StateClean"

	DebugStateChaincode_StateKeys = "StateKeys"

	DebugStateChaincode_StateGet = "StateGet"

	DebugStateChaincode_StatePut = "StatePut"

	DebugStateChaincode_StateDelete = "StateDelete"
)

DebugStateChaincode method names

View Source
const (
	InvokeStateCleanFunc  = `StateClean`
	QueryStateKeysFunc    = `StateKeys`
	QueryStateGetFunc     = `StateGet`
	InvokeStatePutFunc    = `StatePut`
	InvokeStateDeleteFunc = `StateDelete`
)

Variables

View Source
var (
	// KeyParam parameter for get, put, delete data from state
	KeyParam = param.Strings(`key`)

	// PrefixParam parameter
	PrefixParam = param.String(`prefix`)

	// PrefixesParams parameter
	PrefixesParam = param.Strings(`prefixes`)

	// ValueParam  parameter for putting value in state
	ValueParam = param.Bytes(`value`)
)

Functions

func AddHandlers

func AddHandlers(r *router.Group, prefix string, middleware ...router.MiddlewareFunc)

AddHandler adds debug handlers to router, allows to add more middleware for example for access control

func DeleteStateByPrefixes added in v0.7.3

func DeleteStateByPrefixes(s state.State, prefixes []string) (map[string]uint32, error)

DeleteStateByPrefixes deletes from state entries with matching key prefix raw function, do not use State wrappers, like encryption

func InvokeStateClean

func InvokeStateClean(c router.Context) (interface{}, error)

InvokeStateClean delete entries from state, prefix []string contains key prefixes or whole key

func InvokeStateDelete

func InvokeStateDelete(c router.Context) (interface{}, error)

QueryStateGet router handler delete state entry by key ([]string)

func InvokeStatePut

func InvokeStatePut(c router.Context) (interface{}, error)

InvokeValueByKeyPut router handler puts value in chaincode state with composite key, created with key parts ([]string)

func QueryKeysList

func QueryKeysList(c router.Context) (interface{}, error)

QueryKeysList router handler returns string slice with keys by prefix (object type)

func QueryStateGet

func QueryStateGet(c router.Context) (interface{}, error)

QueryStateGet router handler returns state entry by key ([]string)

func RegisterDebugStateChaincode added in v0.7.3

func RegisterDebugStateChaincode(r *cckit_router.Group, cc DebugStateChaincode) error

RegisterDebugStateChaincode registers service methods as chaincode router handlers

func RegisterDebugStateHandler added in v0.7.3

func RegisterDebugStateHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterDebugStateHandler registers the http handlers for service DebugState to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterDebugStateHandlerClient added in v0.7.3

func RegisterDebugStateHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DebugStateClient) error

RegisterDebugStateHandlerClient registers the http handlers for service DebugState to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DebugStateClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DebugStateClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "DebugStateClient" to call the correct interceptors.

func RegisterDebugStateHandlerFromEndpoint added in v0.7.3

func RegisterDebugStateHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterDebugStateHandlerFromEndpoint is same as RegisterDebugStateHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterDebugStateHandlerServer added in v0.7.3

func RegisterDebugStateHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DebugStateServer) error

RegisterDebugStateHandlerServer registers the http handlers for service DebugState to "mux". UnaryRPC :call DebugStateServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterDebugStateServer added in v0.7.3

func RegisterDebugStateServer(s *grpc.Server, srv DebugStateServer)

func StateAsIs added in v0.7.3

func StateAsIs(ctx router.Context) state.State

Types

type CompositeKey added in v0.7.3

type CompositeKey struct {
	Key                  []string `protobuf:"bytes,1,rep,name=key,proto3" json:"key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

State key

func (*CompositeKey) Descriptor added in v0.7.3

func (*CompositeKey) Descriptor() ([]byte, []int)

func (*CompositeKey) GetKey added in v0.7.3

func (m *CompositeKey) GetKey() []string

func (*CompositeKey) ProtoMessage added in v0.7.3

func (*CompositeKey) ProtoMessage()

func (*CompositeKey) Reset added in v0.7.3

func (m *CompositeKey) Reset()

func (*CompositeKey) String added in v0.7.3

func (m *CompositeKey) String() string

func (*CompositeKey) Validate added in v0.7.3

func (this *CompositeKey) Validate() error

func (*CompositeKey) XXX_DiscardUnknown added in v0.7.3

func (m *CompositeKey) XXX_DiscardUnknown()

func (*CompositeKey) XXX_Marshal added in v0.7.3

func (m *CompositeKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CompositeKey) XXX_Merge added in v0.7.3

func (m *CompositeKey) XXX_Merge(src proto.Message)

func (*CompositeKey) XXX_Size added in v0.7.3

func (m *CompositeKey) XXX_Size() int

func (*CompositeKey) XXX_Unmarshal added in v0.7.3

func (m *CompositeKey) XXX_Unmarshal(b []byte) error

type CompositeKeys added in v0.7.3

type CompositeKeys struct {
	Keys                 []*CompositeKey `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

State keys

func (*CompositeKeys) Descriptor added in v0.7.3

func (*CompositeKeys) Descriptor() ([]byte, []int)

func (*CompositeKeys) GetKeys added in v0.7.3

func (m *CompositeKeys) GetKeys() []*CompositeKey

func (*CompositeKeys) ProtoMessage added in v0.7.3

func (*CompositeKeys) ProtoMessage()

func (*CompositeKeys) Reset added in v0.7.3

func (m *CompositeKeys) Reset()

func (*CompositeKeys) String added in v0.7.3

func (m *CompositeKeys) String() string

func (*CompositeKeys) Validate added in v0.7.3

func (this *CompositeKeys) Validate() error

func (*CompositeKeys) XXX_DiscardUnknown added in v0.7.3

func (m *CompositeKeys) XXX_DiscardUnknown()

func (*CompositeKeys) XXX_Marshal added in v0.7.3

func (m *CompositeKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CompositeKeys) XXX_Merge added in v0.7.3

func (m *CompositeKeys) XXX_Merge(src proto.Message)

func (*CompositeKeys) XXX_Size added in v0.7.3

func (m *CompositeKeys) XXX_Size() int

func (*CompositeKeys) XXX_Unmarshal added in v0.7.3

func (m *CompositeKeys) XXX_Unmarshal(b []byte) error

type DebugStateChaincode added in v0.7.3

type DebugStateChaincode interface {
	StateClean(cckit_router.Context, *Prefixes) (*PrefixesMatchCount, error)

	StateKeys(cckit_router.Context, *Prefix) (*CompositeKeys, error)

	StateGet(cckit_router.Context, *CompositeKey) (*Value, error)

	StatePut(cckit_router.Context, *Value) (*Value, error)

	StateDelete(cckit_router.Context, *CompositeKey) (*Value, error)
}

DebugStateChaincode chaincode methods interface

type DebugStateChaincodeResolver added in v0.7.3

type DebugStateChaincodeResolver interface {
	DebugStateChaincode(ctx cckit_router.Context) (DebugStateChaincode, error)
}

DebugStateChaincodeResolver interface for service resolver

type DebugStateClient added in v0.7.3

type DebugStateClient interface {
	// Clear all state or, if prefixes are defined, only prefix matched
	StateClean(ctx context.Context, in *Prefixes, opts ...grpc.CallOption) (*PrefixesMatchCount, error)
	// Get keys list, returns all keys or, if prefixes are defined, only prefix matched
	StateKeys(ctx context.Context, in *Prefix, opts ...grpc.CallOption) (*CompositeKeys, error)
	// Get state value by key
	StateGet(ctx context.Context, in *CompositeKey, opts ...grpc.CallOption) (*Value, error)
	// Put state value
	StatePut(ctx context.Context, in *Value, opts ...grpc.CallOption) (*Value, error)
	// Delete state value
	StateDelete(ctx context.Context, in *CompositeKey, opts ...grpc.CallOption) (*Value, error)
}

DebugStateClient is the client API for DebugState service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewDebugStateClient added in v0.7.3

func NewDebugStateClient(cc grpc.ClientConnInterface) DebugStateClient

type DebugStateGateway added in v0.7.3

type DebugStateGateway struct {
	Gateway cckit_gateway.Chaincode
}

gateway implementation gateway can be used as kind of SDK, GRPC or REST server ( via grpc-gateway or clay )

func NewDebugStateGateway added in v0.7.3

func NewDebugStateGateway(ccService cckit_ccservice.Chaincode, channel, chaincode string, opts ...cckit_gateway.Opt) *DebugStateGateway

NewDebugStateGateway creates gateway to access chaincode method via chaincode service

func (*DebugStateGateway) ApiDef added in v0.7.3

ApiDef deprecated, use ServiceDef

func (*DebugStateGateway) Events added in v0.7.3

Events returns events subscription

func (*DebugStateGateway) ServiceDef added in v0.7.3

func (c *DebugStateGateway) ServiceDef() cckit_gateway.ServiceDef

ServiceDef returns service definition

func (*DebugStateGateway) StateClean added in v0.7.3

func (c *DebugStateGateway) StateClean(ctx context.Context, in *Prefixes) (*PrefixesMatchCount, error)

func (*DebugStateGateway) StateDelete added in v0.7.3

func (c *DebugStateGateway) StateDelete(ctx context.Context, in *CompositeKey) (*Value, error)

func (*DebugStateGateway) StateGet added in v0.7.3

func (c *DebugStateGateway) StateGet(ctx context.Context, in *CompositeKey) (*Value, error)

func (*DebugStateGateway) StateKeys added in v0.7.3

func (c *DebugStateGateway) StateKeys(ctx context.Context, in *Prefix) (*CompositeKeys, error)

func (*DebugStateGateway) StatePut added in v0.7.3

func (c *DebugStateGateway) StatePut(ctx context.Context, in *Value) (*Value, error)

type DebugStateServer added in v0.7.3

type DebugStateServer interface {
	// Clear all state or, if prefixes are defined, only prefix matched
	StateClean(context.Context, *Prefixes) (*PrefixesMatchCount, error)
	// Get keys list, returns all keys or, if prefixes are defined, only prefix matched
	StateKeys(context.Context, *Prefix) (*CompositeKeys, error)
	// Get state value by key
	StateGet(context.Context, *CompositeKey) (*Value, error)
	// Put state value
	StatePut(context.Context, *Value) (*Value, error)
	// Delete state value
	StateDelete(context.Context, *CompositeKey) (*Value, error)
}

DebugStateServer is the server API for DebugState service.

type Prefix added in v0.7.3

type Prefix struct {
	// parts of key
	Key                  []string `protobuf:"bytes,1,rep,name=key,proto3" json:"key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

State key prefix

func (*Prefix) Descriptor added in v0.7.3

func (*Prefix) Descriptor() ([]byte, []int)

func (*Prefix) GetKey added in v0.7.3

func (m *Prefix) GetKey() []string

func (*Prefix) ProtoMessage added in v0.7.3

func (*Prefix) ProtoMessage()

func (*Prefix) Reset added in v0.7.3

func (m *Prefix) Reset()

func (*Prefix) String added in v0.7.3

func (m *Prefix) String() string

func (*Prefix) Validate added in v0.7.3

func (this *Prefix) Validate() error

func (*Prefix) XXX_DiscardUnknown added in v0.7.3

func (m *Prefix) XXX_DiscardUnknown()

func (*Prefix) XXX_Marshal added in v0.7.3

func (m *Prefix) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Prefix) XXX_Merge added in v0.7.3

func (m *Prefix) XXX_Merge(src proto.Message)

func (*Prefix) XXX_Size added in v0.7.3

func (m *Prefix) XXX_Size() int

func (*Prefix) XXX_Unmarshal added in v0.7.3

func (m *Prefix) XXX_Unmarshal(b []byte) error

type Prefixes added in v0.7.3

type Prefixes struct {
	Prefixes             []*Prefix `protobuf:"bytes,1,rep,name=prefixes,proto3" json:"prefixes,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*Prefixes) Descriptor added in v0.7.3

func (*Prefixes) Descriptor() ([]byte, []int)

func (*Prefixes) GetPrefixes added in v0.7.3

func (m *Prefixes) GetPrefixes() []*Prefix

func (*Prefixes) ProtoMessage added in v0.7.3

func (*Prefixes) ProtoMessage()

func (*Prefixes) Reset added in v0.7.3

func (m *Prefixes) Reset()

func (*Prefixes) String added in v0.7.3

func (m *Prefixes) String() string

func (*Prefixes) Validate added in v0.7.3

func (this *Prefixes) Validate() error

func (*Prefixes) XXX_DiscardUnknown added in v0.7.3

func (m *Prefixes) XXX_DiscardUnknown()

func (*Prefixes) XXX_Marshal added in v0.7.3

func (m *Prefixes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Prefixes) XXX_Merge added in v0.7.3

func (m *Prefixes) XXX_Merge(src proto.Message)

func (*Prefixes) XXX_Size added in v0.7.3

func (m *Prefixes) XXX_Size() int

func (*Prefixes) XXX_Unmarshal added in v0.7.3

func (m *Prefixes) XXX_Unmarshal(b []byte) error

type PrefixesMatchCount added in v0.7.3

type PrefixesMatchCount struct {
	Matches              map[string]uint32 `` /* 156-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

State key prefix match count

func (*PrefixesMatchCount) Descriptor added in v0.7.3

func (*PrefixesMatchCount) Descriptor() ([]byte, []int)

func (*PrefixesMatchCount) GetMatches added in v0.7.3

func (m *PrefixesMatchCount) GetMatches() map[string]uint32

func (*PrefixesMatchCount) ProtoMessage added in v0.7.3

func (*PrefixesMatchCount) ProtoMessage()

func (*PrefixesMatchCount) Reset added in v0.7.3

func (m *PrefixesMatchCount) Reset()

func (*PrefixesMatchCount) String added in v0.7.3

func (m *PrefixesMatchCount) String() string

func (*PrefixesMatchCount) Validate added in v0.7.3

func (this *PrefixesMatchCount) Validate() error

func (*PrefixesMatchCount) XXX_DiscardUnknown added in v0.7.3

func (m *PrefixesMatchCount) XXX_DiscardUnknown()

func (*PrefixesMatchCount) XXX_Marshal added in v0.7.3

func (m *PrefixesMatchCount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PrefixesMatchCount) XXX_Merge added in v0.7.3

func (m *PrefixesMatchCount) XXX_Merge(src proto.Message)

func (*PrefixesMatchCount) XXX_Size added in v0.7.3

func (m *PrefixesMatchCount) XXX_Size() int

func (*PrefixesMatchCount) XXX_Unmarshal added in v0.7.3

func (m *PrefixesMatchCount) XXX_Unmarshal(b []byte) error

type StateFn added in v0.7.3

type StateFn func(router.Context) state.State

StateFn function can add mappings to state, for correct convertation in StateGet

type StateService added in v0.7.3

type StateService struct {
	State StateFn
}

func NewStateService added in v0.7.3

func NewStateService() *StateService

func (*StateService) StateClean added in v0.7.3

func (s *StateService) StateClean(ctx router.Context, prefixes *Prefixes) (*PrefixesMatchCount, error)

func (*StateService) StateDelete added in v0.7.3

func (s *StateService) StateDelete(ctx router.Context, key *CompositeKey) (*Value, error)

func (*StateService) StateGet added in v0.7.3

func (s *StateService) StateGet(ctx router.Context, key *CompositeKey) (*Value, error)

func (*StateService) StateKeys added in v0.7.3

func (s *StateService) StateKeys(ctx router.Context, prefix *Prefix) (*CompositeKeys, error)

func (*StateService) StatePut added in v0.7.3

func (s *StateService) StatePut(ctx router.Context, val *Value) (*Value, error)

type UnimplementedDebugStateServer added in v0.7.3

type UnimplementedDebugStateServer struct {
}

UnimplementedDebugStateServer can be embedded to have forward compatible implementations.

func (*UnimplementedDebugStateServer) StateClean added in v0.7.3

func (*UnimplementedDebugStateServer) StateDelete added in v0.7.3

func (*UnimplementedDebugStateServer) StateGet added in v0.7.3

func (*UnimplementedDebugStateServer) StateKeys added in v0.7.3

func (*UnimplementedDebugStateServer) StatePut added in v0.7.3

func (*UnimplementedDebugStateServer) StatePut(ctx context.Context, req *Value) (*Value, error)

type Value added in v0.7.3

type Value struct {
	Key                  []string `protobuf:"bytes,1,rep,name=key,proto3" json:"key,omitempty"`
	Value                []byte   `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	Json                 string   `protobuf:"bytes,3,opt,name=json,proto3" json:"json,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

State value

func (*Value) Descriptor added in v0.7.3

func (*Value) Descriptor() ([]byte, []int)

func (*Value) GetJson added in v0.7.3

func (m *Value) GetJson() string

func (*Value) GetKey added in v0.7.3

func (m *Value) GetKey() []string

func (*Value) GetValue added in v0.7.3

func (m *Value) GetValue() []byte

func (*Value) ProtoMessage added in v0.7.3

func (*Value) ProtoMessage()

func (*Value) Reset added in v0.7.3

func (m *Value) Reset()

func (*Value) String added in v0.7.3

func (m *Value) String() string

func (*Value) Validate added in v0.7.3

func (this *Value) Validate() error

func (*Value) XXX_DiscardUnknown added in v0.7.3

func (m *Value) XXX_DiscardUnknown()

func (*Value) XXX_Marshal added in v0.7.3

func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Value) XXX_Merge added in v0.7.3

func (m *Value) XXX_Merge(src proto.Message)

func (*Value) XXX_Size added in v0.7.3

func (m *Value) XXX_Size() int

func (*Value) XXX_Unmarshal added in v0.7.3

func (m *Value) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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