Skip to content

Commit

Permalink
fix issue 5
Browse files Browse the repository at this point in the history
Fixes #5 by correcting license header and cleaning up glint errors

Signed-off-by: Christopher Ferris <chrisfer@us.ibm.com>
  • Loading branch information
christo4ferris committed May 13, 2016
1 parent 1772d84 commit bf387ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 60 deletions.
53 changes: 18 additions & 35 deletions finished/chaincode_finished.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Copyright IBM Corp 2016 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main
Expand All @@ -30,35 +27,28 @@ import (
type SimpleChaincode struct {
}

// ============================================================================================================================
// Main
// ============================================================================================================================
func main() {
err := shim.Start(new(SimpleChaincode))
if err != nil {
fmt.Printf("Error starting Simple chaincode: %s", err)
}
}

// ============================================================================================================================
// Init - reset all the things
// ============================================================================================================================
// Init resets all the things
func (t *SimpleChaincode) Init(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
if len(args) != 1 {
return nil, errors.New("Incorrect number of arguments. Expecting 1")
}

err := stub.PutState("hello_world", []byte(args[0]))
if err != nil {
return nil, err
}

return nil, nil
}

// ============================================================================================================================
// Invoke - Our entry point
// ============================================================================================================================
// Invoke isur entry point to invoke a chaincode function
func (t *SimpleChaincode) Invoke(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
fmt.Println("invoke is running " + function)

Expand All @@ -73,9 +63,7 @@ func (t *SimpleChaincode) Invoke(stub *shim.ChaincodeStub, function string, args
return nil, errors.New("Received unknown function invocation")
}

// ============================================================================================================================
// Query - Our entry point for Queries
// ============================================================================================================================
// Query is our entry point for queries
func (t *SimpleChaincode) Query(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
fmt.Println("query is running " + function)

Expand All @@ -88,9 +76,7 @@ func (t *SimpleChaincode) Query(stub *shim.ChaincodeStub, function string, args
return nil, errors.New("Received unknown function query")
}

// ============================================================================================================================
// write - invoke function to write key/value pair
// ============================================================================================================================
func (t *SimpleChaincode) write(stub *shim.ChaincodeStub, args []string) ([]byte, error) {
var name, value string
var err error
Expand All @@ -109,9 +95,7 @@ func (t *SimpleChaincode) write(stub *shim.ChaincodeStub, args []string) ([]byte
return nil, nil
}

// ============================================================================================================================
// read - query function to read key/value pair
// ============================================================================================================================
func (t *SimpleChaincode) read(stub *shim.ChaincodeStub, args []string) ([]byte, error) {
var name, jsonResp string
var err error
Expand All @@ -129,4 +113,3 @@ func (t *SimpleChaincode) read(stub *shim.ChaincodeStub, args []string) ([]byte,

return valAsbytes, nil
}

41 changes: 16 additions & 25 deletions start/chaincode_start.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Copyright IBM Corp 2016 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main
Expand All @@ -40,9 +37,7 @@ func main() {
}
}

// ============================================================================================================================
// Init - reset all the things
// ============================================================================================================================
// Init resets all the things
func (t *SimpleChaincode) Init(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
if len(args) != 1 {
return nil, errors.New("Incorrect number of arguments. Expecting 1")
Expand All @@ -51,9 +46,7 @@ func (t *SimpleChaincode) Init(stub *shim.ChaincodeStub, function string, args [
return nil, nil
}

// ============================================================================================================================
// Invoke - Our entry point
// ============================================================================================================================
// Invoke is our entry point to invoke a chaincode function
func (t *SimpleChaincode) Invoke(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
fmt.Println("invoke is running " + function)

Expand All @@ -66,9 +59,7 @@ func (t *SimpleChaincode) Invoke(stub *shim.ChaincodeStub, function string, args
return nil, errors.New("Received unknown function invocation")
}

// ============================================================================================================================
// Query - Our entry point for Queries
// ============================================================================================================================
// Query is our entry point for queries
func (t *SimpleChaincode) Query(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
fmt.Println("query is running " + function)

Expand Down

0 comments on commit bf387ec

Please sign in to comment.