Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
blockchain_guide
提交
aced19f4
B
blockchain_guide
项目概览
OpenDocCN
/
blockchain_guide
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
blockchain_guide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
aced19f4
编写于
7月 19, 2016
作者:
swbsin
提交者:
GitHub
7月 19, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete chaincode_example04.go
上级
de55ce16
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
131 deletion
+0
-131
hyperledger/chaincode_example04.go
hyperledger/chaincode_example04.go
+0
-131
未找到文件。
hyperledger/chaincode_example04.go
已删除
100644 → 0
浏览文件 @
de55ce16
/*
author:swb
emial:swbsin@163.com
MIT License
*/
package
main
import
(
"errors"
"fmt"
"crypto/md5"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"io"
"github.com/hyperledger/fabric/core/chaincode/shim"
)
type
SimpleChaincode
struct
{
}
var
schoolId
int
=
0
var
RecordId
int
=
0
type
School
struct
{
Name
string
Location
string
Address
string
PriKey
string
PubKey
string
StudentAddress
[]
string
}
type
Student
struct
{
Name
string
Address
string
BackgroundId
[]
string
}
//当离开学校才能记入
type
Background
struct
{
SchoolAddress
string
StartTime
string
EndTime
string
Status
//0:退学 1:毕业
}
type
Record
struct
{
Id
int
SchoolAddress
string
StudentAddress
string
ModifyTime
string
ModifyOperation
string
}
func
(
t
*
SimpleChaincode
)
Init
(
stub
*
shim
.
ChaincodeStub
,
function
string
,
args
[]
string
)
([]
byte
,
error
)
{
if
len
(
args
)
!=
0
{
return
nil
,
errors
.
New
(
"Incorrect number of arguments. Expecting 0"
)
}
return
nil
,
nil
}
func
(
t
*
SimpleChaincode
)
Invoke
(
stub
*
shim
.
ChaincodeStub
,
function
string
,
args
[]
string
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
(
t
*
SimpleChaincode
)
Query
(
stub
*
shim
.
ChaincodeStub
,
function
string
,
args
[]
string
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
main
()
{
err
:=
shim
.
Start
(
new
(
SimpleChaincode
))
if
err
!=
nil
{
fmt
.
Printf
(
"Error starting Simple chaincode: %s"
,
err
)
}
}
//生成Address
func
GetAddress
()
(
string
,
string
,
string
)
{
var
address
,
priKey
,
pubKey
string
b
:=
make
([]
byte
,
48
)
if
_
,
err
:=
io
.
ReadFull
(
rand
.
Reader
,
b
);
err
!=
nil
{
return
""
,
""
,
""
}
h
:=
md5
.
New
()
h
.
Write
([]
byte
(
base64
.
URLEncoding
.
EncodeToString
(
b
)))
address
=
hex
.
EncodeToString
(
h
.
Sum
(
nil
))
priKey
=
address
+
"1"
pubKey
=
address
+
"2"
return
address
,
priKey
,
pubKey
}
func
(
t
*
SimpleChaincode
)
createSchool
(
stub
*
shim
.
ChaincodeStub
,
args
[]
string
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
(
t
*
SimpleChaincode
)
createStudent
(
stub
*
shim
.
ChaincodeStub
,
args
[]
string
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
(
t
*
SimpleChaincode
)
enrollStudent
(
stub
*
shim
.
ChaincodeStub
,
args
[]
string
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
(
t
*
SimpleChaincode
)
updateDiploma
(
stub
*
shim
.
ChaincodeStub
,
args
[]
string
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
getStudentByAddress
(
stub
*
shim
.
ChaincodeStub
,
id
string
)
([]
Background
,[]
byte
,
error
)
{
return
nil
,
nil
,
nil
}
func
getRecordById
(
stub
*
shim
.
ChaincodeStub
,
id
string
)
(
Record
,[]
byte
,
error
)
{
return
nil
,
nil
,
nil
}
func
getRecords
(
stub
*
shim
.
ChaincodeStub
)
([]
Record
,
error
)
{
return
nil
,
nil
}
func
writeRecord
(
stub
*
shim
.
ChaincodeStub
,
centerBank
CenterBank
)
(
error
)
{
return
nil
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录