Beispiel #1
0
// Marshal serializes a `KVRead`
func (r *KVRead) Marshal(buf *proto.Buffer) error {
	if err := buf.EncodeStringBytes(r.Key); err != nil {
		return err
	}
	versionBytes := []byte{}
	if r.Version != nil {
		versionBytes = r.Version.ToBytes()
	}
	if err := buf.EncodeRawBytes(versionBytes); err != nil {
		return err
	}
	return nil
}
func _CommitRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*CommitRequest)
	// transaction_selector
	switch x := m.TransactionSelector.(type) {
	case *CommitRequest_Transaction:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.Transaction)
	case nil:
	default:
		return fmt.Errorf("CommitRequest.TransactionSelector has unexpected type %T", x)
	}
	return nil
}
Beispiel #3
0
func unmarshalTrieNodeValueFromBuffer(buffer *proto.Buffer) []byte {
	valueMarker, err := buffer.DecodeVarint()
	if err != nil {
		panic(fmt.Errorf("This error is not excpected: %s", err))
	}
	if valueMarker == 0 {
		return nil
	}
	value, err := buffer.DecodeRawBytes(false)
	if err != nil {
		panic(fmt.Errorf("This error is not excpected: %s", err))
	}
	return value
}
func _CommitRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*CommitRequest)
	switch tag {
	case 1: // transaction_selector.transaction
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeRawBytes(true)
		m.TransactionSelector = &CommitRequest_Transaction{x}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #5
0
// Unmarshal deserializes a `KVRead`
func (r *KVRead) Unmarshal(buf *proto.Buffer) error {
	var err error
	var versionBytes []byte
	if r.Key, err = buf.DecodeStringBytes(); err != nil {
		return err
	}
	if versionBytes, err = buf.DecodeRawBytes(false); err != nil {
		return err
	}
	if len(versionBytes) > 0 {
		r.Version, _ = version.NewHeightFromBytes(versionBytes)
	}
	return nil
}
Beispiel #6
0
func _MsgWithOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*MsgWithOneof)
	switch tag {
	case 1: // union.title
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Union = &MsgWithOneof_Title{x}
		return true, err
	case 2: // union.salary
		if wire != proto.WireVarint {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeVarint()
		m.Union = &MsgWithOneof_Salary{int64(x)}
		return true, err
	case 3: // union.Country
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Union = &MsgWithOneof_Country{x}
		return true, err
	case 4: // union.home_address
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Union = &MsgWithOneof_HomeAddress{x}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #7
0
func _Interest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Interest)
	switch tag {
	case 2: // RegInfo.chaincodeRegInfo
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ChaincodeReg)
		err := b.DecodeMessage(msg)
		m.RegInfo = &Interest_ChaincodeRegInfo{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #8
0
func _Interest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Interest)
	// RegInfo
	switch x := m.RegInfo.(type) {
	case *Interest_ChaincodeRegInfo:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ChaincodeRegInfo); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Interest.RegInfo has unexpected type %T", x)
	}
	return nil
}
Beispiel #9
0
func _Message_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Message)
	switch tag {
	case 1: // protocol.lorawan
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(lorawan.Message)
		err := b.DecodeMessage(msg)
		m.Protocol = &Message_Lorawan{msg}
		return true, err
	default:
		return false, nil
	}
}
func _ZoneServerMsg_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*ZoneServerMsg)
	// Msg
	switch x := m.Msg.(type) {
	case *ZoneServerMsg_ForWardZoneStartupMsg:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ForWardZoneStartupMsg); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("ZoneServerMsg.Msg has unexpected type %T", x)
	}
	return nil
}
func _ZoneServerMsg_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*ZoneServerMsg)
	switch tag {
	case 1: // Msg.ForWardZoneStartupMsg
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ForWardZoneStartupMsg)
		err := b.DecodeMessage(msg)
		m.Msg = &ZoneServerMsg_ForWardZoneStartupMsg{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #12
0
func _PipelineSource_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*PipelineSource)
	// typed_pipeline_source
	switch x := m.TypedPipelineSource.(type) {
	case *PipelineSource_GithubPipelineSource:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.GithubPipelineSource); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("PipelineSource.TypedPipelineSource has unexpected type %T", x)
	}
	return nil
}
Beispiel #13
0
func (chaincodeStateDelta *ChaincodeStateDelta) marshal(buffer *proto.Buffer) {
	err := buffer.EncodeVarint(uint64(len(chaincodeStateDelta.UpdatedKVs)))
	if err != nil {
		panic(fmt.Errorf("This error should not occur: %s", err))
	}
	for key, valueHolder := range chaincodeStateDelta.UpdatedKVs {
		err = buffer.EncodeStringBytes(key)
		if err != nil {
			panic(fmt.Errorf("This error should not occur: %s", err))
		}
		chaincodeStateDelta.marshalValueWithMarker(buffer, valueHolder.Value)
		chaincodeStateDelta.marshalValueWithMarker(buffer, valueHolder.PreviousValue)
	}
	return
}
Beispiel #14
0
func _PipelineSource_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*PipelineSource)
	switch tag {
	case 4: // typed_pipeline_source.github_pipeline_source
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(GithubPipelineSource)
		err := b.DecodeMessage(msg)
		m.TypedPipelineSource = &PipelineSource_GithubPipelineSource{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #15
0
func _Policy_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Policy)
	switch tag {
	case 1: // Type.SignaturePolicy
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(SignaturePolicyEnvelope)
		err := b.DecodeMessage(msg)
		m.Type = &Policy_SignaturePolicy{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #16
0
func _Policy_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Policy)
	// Type
	switch x := m.Type.(type) {
	case *Policy_SignaturePolicy:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.SignaturePolicy); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Policy.Type has unexpected type %T", x)
	}
	return nil
}
Beispiel #17
0
func _ArchiveServerConfig_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*ArchiveServerConfig)
	switch tag {
	case 3: // credentials.ssl_credentials
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ArchiveServerConfig_SslCredentials)
		err := b.DecodeMessage(msg)
		m.Credentials = &ArchiveServerConfig_SslCredentials_{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #18
0
func _ArchiveServerConfig_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*ArchiveServerConfig)
	// credentials
	switch x := m.Credentials.(type) {
	case *ArchiveServerConfig_SslCredentials_:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.SslCredentials); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("ArchiveServerConfig.Credentials has unexpected type %T", x)
	}
	return nil
}
Beispiel #19
0
func _WatchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*WatchRequest)
	switch tag {
	case 1: // request_union.create_request
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(WatchCreateRequest)
		err := b.DecodeMessage(msg)
		m.RequestUnion = &WatchRequest_CreateRequest{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #20
0
func _WatchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*WatchRequest)
	// request_union
	switch x := m.RequestUnion.(type) {
	case *WatchRequest_CreateRequest:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.CreateRequest); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("WatchRequest.RequestUnion has unexpected type %T", x)
	}
	return nil
}
Beispiel #21
0
func _Message_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Message)
	// protocol
	switch x := m.Protocol.(type) {
	case *Message_Lorawan:
		_ = b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Lorawan); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Message.Protocol has unexpected type %T", x)
	}
	return nil
}
func _Command_OneofUnmarshaler(msg proto1.Message, tag, wire int, b *proto1.Buffer) (bool, error) {
	m := msg.(*Command)
	switch tag {
	case 2: // command.say
		if wire != proto1.WireBytes {
			return true, proto1.ErrInternalBadWireType
		}
		msg := new(CommandSay)
		err := b.DecodeMessage(msg)
		m.Command = &Command_Say{msg}
		return true, err
	case 3: // command.nick
		if wire != proto1.WireBytes {
			return true, proto1.ErrInternalBadWireType
		}
		msg := new(CommandChangeNick)
		err := b.DecodeMessage(msg)
		m.Command = &Command_Nick{msg}
		return true, err
	case 4: // command.join
		if wire != proto1.WireBytes {
			return true, proto1.ErrInternalBadWireType
		}
		msg := new(CommandJoinChannel)
		err := b.DecodeMessage(msg)
		m.Command = &Command_Join{msg}
		return true, err
	case 5: // command.leave
		if wire != proto1.WireBytes {
			return true, proto1.ErrInternalBadWireType
		}
		msg := new(CommandLeaveChannel)
		err := b.DecodeMessage(msg)
		m.Command = &Command_Leave{msg}
		return true, err
	case 6: // command.exit
		if wire != proto1.WireBytes {
			return true, proto1.ErrInternalBadWireType
		}
		msg := new(CommandExit)
		err := b.DecodeMessage(msg)
		m.Command = &Command_Exit{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #23
0
func _Event_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Event)
	switch tag {
	case 1: // Event.register
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Register)
		err := b.DecodeMessage(msg)
		m.Event = &Event_Register{msg}
		return true, err
	case 2: // Event.block
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Block)
		err := b.DecodeMessage(msg)
		m.Event = &Event_Block{msg}
		return true, err
	case 3: // Event.chaincodeEvent
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ChaincodeEvent)
		err := b.DecodeMessage(msg)
		m.Event = &Event_ChaincodeEvent{msg}
		return true, err
	case 4: // Event.rejection
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Rejection)
		err := b.DecodeMessage(msg)
		m.Event = &Event_Rejection{msg}
		return true, err
	case 5: // Event.unregister
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Unregister)
		err := b.DecodeMessage(msg)
		m.Event = &Event_Unregister{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #24
0
func _LoadParams_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*LoadParams)
	switch tag {
	case 1: // load.closed_loop
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ClosedLoopParams)
		err := b.DecodeMessage(msg)
		m.Load = &LoadParams_ClosedLoop{msg}
		return true, err
	case 2: // load.poisson
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(PoissonParams)
		err := b.DecodeMessage(msg)
		m.Load = &LoadParams_Poisson{msg}
		return true, err
	case 3: // load.uniform
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(UniformParams)
		err := b.DecodeMessage(msg)
		m.Load = &LoadParams_Uniform{msg}
		return true, err
	case 4: // load.determ
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(DeterministicParams)
		err := b.DecodeMessage(msg)
		m.Load = &LoadParams_Determ{msg}
		return true, err
	case 5: // load.pareto
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ParetoParams)
		err := b.DecodeMessage(msg)
		m.Load = &LoadParams_Pareto{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #25
0
func _Mutation_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Mutation)
	switch tag {
	case 4: // operation.insert
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Entity)
		err := b.DecodeMessage(msg)
		m.Operation = &Mutation_Insert{msg}
		return true, err
	case 5: // operation.update
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Entity)
		err := b.DecodeMessage(msg)
		m.Operation = &Mutation_Update{msg}
		return true, err
	case 6: // operation.upsert
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Entity)
		err := b.DecodeMessage(msg)
		m.Operation = &Mutation_Upsert{msg}
		return true, err
	case 7: // operation.delete
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Key)
		err := b.DecodeMessage(msg)
		m.Operation = &Mutation_Delete{msg}
		return true, err
	case 8: // conflict_detection_strategy.base_version
		if wire != proto.WireVarint {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeVarint()
		m.ConflictDetectionStrategy = &Mutation_BaseVersion{int64(x)}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #26
0
func _SieveMessage_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*SieveMessage)
	switch tag {
	case 1: // payload.request
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Request)
		err := b.DecodeMessage(msg)
		m.Payload = &SieveMessage_Request{msg}
		return true, err
	case 2: // payload.execute
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Execute)
		err := b.DecodeMessage(msg)
		m.Payload = &SieveMessage_Execute{msg}
		return true, err
	case 3: // payload.verify
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Verify)
		err := b.DecodeMessage(msg)
		m.Payload = &SieveMessage_Verify{msg}
		return true, err
	case 4: // payload.pbft_message
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeRawBytes(true)
		m.Payload = &SieveMessage_PbftMessage{x}
		return true, err
	case 5: // payload.complaint
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(Request)
		err := b.DecodeMessage(msg)
		m.Payload = &SieveMessage_Complaint{msg}
		return true, err
	default:
		return false, nil
	}
}
Beispiel #27
0
func _StreamMessage_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*StreamMessage)
	switch tag {
	case 1: // message_oneof.rpc
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(RPC)
		err := b.DecodeMessage(msg)
		m.MessageOneof = &StreamMessage_Rpc{msg}
		return true, err
	case 2: // message_oneof.message
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(JSON)
		err := b.DecodeMessage(msg)
		m.MessageOneof = &StreamMessage_Message{msg}
		return true, err
	case 3: // message_oneof.byte_message
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeRawBytes(true)
		m.MessageOneof = &StreamMessage_ByteMessage{x}
		return true, err
	case 4: // message_oneof.error
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(JSON)
		err := b.DecodeMessage(msg)
		m.MessageOneof = &StreamMessage_Error{msg}
		return true, err
	case 5: // message_oneof.byte_error
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeRawBytes(true)
		m.MessageOneof = &StreamMessage_ByteError{x}
		return true, err
	default:
		return false, nil
	}
}
func addMetadataBytes(blockMetadata *common.BlockMetadata, buf *proto.Buffer) error {
	numItems := uint64(0)
	if blockMetadata != nil {
		numItems = uint64(len(blockMetadata.Metadata))
	}
	if err := buf.EncodeVarint(numItems); err != nil {
		return err
	}
	if numItems == 0 {
		return nil
	}
	for _, b := range blockMetadata.Metadata {
		if err := buf.EncodeRawBytes(b); err != nil {
			return err
		}
	}
	return nil
}
Beispiel #29
0
func (chaincodeStateDelta *ChaincodeStateDelta) unmarshalValueWithMarker(buffer *proto.Buffer) ([]byte, error) {
	valueMarker, err := buffer.DecodeVarint()
	if err != nil {
		return nil, fmt.Errorf("Error unmarshaling state delta : %s", err)
	}
	if valueMarker == 0 {
		return nil, nil
	}
	value, err := buffer.DecodeRawBytes(false)
	if err != nil {
		return nil, fmt.Errorf("Error unmarhsaling state delta : %s", err)
	}
	// protobuff makes an empty []byte into a nil. So, assigning an empty byte array explicitly
	if value == nil {
		value = []byte{}
	}
	return value, nil
}
Beispiel #30
0
func _JSON_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*JSON)
	switch tag {
	case 1: // json_value_oneof.json_string
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.JsonValueOneof = &JSON_JsonString{x}
		return true, err
	case 2: // json_value_oneof.json_number
		if wire != proto.WireFixed64 {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeFixed64()
		m.JsonValueOneof = &JSON_JsonNumber{math.Float64frombits(x)}
		return true, err
	case 3: // json_value_oneof.json_bool
		if wire != proto.WireVarint {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeVarint()
		m.JsonValueOneof = &JSON_JsonBool{x != 0}
		return true, err
	case 4: // json_value_oneof.json_object
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(JSONObject)
		err := b.DecodeMessage(msg)
		m.JsonValueOneof = &JSON_JsonObject{msg}
		return true, err
	case 5: // json_value_oneof.json_array
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(JSONArray)
		err := b.DecodeMessage(msg)
		m.JsonValueOneof = &JSON_JsonArray{msg}
		return true, err
	default:
		return false, nil
	}
}