-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to store assets on the chain as json objects to enable rich queries. #31
Comments
I have also tried useing both |
I have created a middleware function to set the states to use the serialize.PreferJSONSerializer. func SetStateJSON(next router.HandlerFunc, pos ...int) router.HandlerFunc {
return func(c router.Context) (interface{}, error) {
c.State().UseSerializer(serialize.PreferJSONSerializer)
return next(c)
}
} It is working for submitting new assets and retrieving them one at a time, but the get list keeps getting a panic with the error `"reflect: call of unknown method on zero Value"
|
It seems like the problem is a arising here in the first if statment in the state_list.go get function. I got it to not error out when i removed the list maping ( |
Hi, Thomas! |
When I try to get the list of the users using that method I ended up only being able to populate the list as the IDs otherwise it errors out. Works: func QueryUsers(c router.Context) (interface{}, error) {
return c.State().List(&schema.UserId{})
} Errors out func QueryUsers(c router.Context) (interface{}, error) {
return c.State().List(&schema.User{})
} Tracebackgithub.com/nova38/biochain/fabric/biochain/cc_func.QueryUsers({0x10bbfc0, 0xc0000e4af0}) D:/projects/BioChain/fabric/biochain/cc_func/users.go:66 +0xf4 github.com/hyperledger-labs/cckit/router.(*Group).addHandler.func1({0x10bbfc0, 0xc0000e4af0}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/router/router.go:208 +0x156 github.com/hyperledger-labs/cckit/state/mapping.MapEvents.func1.1({0x10bbfc0, 0xc0000e4af0}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/state/mapping/middleware.go:20 +0xde github.com/hyperledger-labs/cckit/state/mapping.MapStates.func1.1({0x10bbfc0, 0xc0000e4af0}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/state/mapping/middleware.go:11 +0xde github.com/hyperledger-labs/cckit/router.(*Group).handleContext.func2({0x10bbfc0, 0xc0000e4af0}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/router/router.go:138 +0x231 github.com/hyperledger-labs/cckit/router.(*Group).handleContext(0xc000000000, {0x10bbfc0, 0xc0000e4af0}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/router/router.go:141 +0x93a github.com/hyperledger-labs/cckit/router.(*Group).buildHandler.func1({0x10bbfc0, 0xc0000e4af0}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/router/router.go:80 +0x1ae github.com/hyperledger-labs/cckit/router.(*Group).Handle(0xc000000000, {0x10bd8e8, 0xc0002d5550}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/router/router.go:102 +0x197 github.com/hyperledger-labs/cckit/router.(*Chaincode).Invoke(0xc00000a680, {0x10bd8e8, 0xc0002d5550}) C:/Users/devcs/go/pkg/mod/github.com/hyperledger-labs/[email protected]/router/chaincode.go:29 +0x85 github.com/hyperledger/fabric-chaincode-go/shim.(*Handler).handleTransaction(0xc0005983c0, 0xc0005a4a80) C:/Users/devcs/go/pkg/mod/github.com/hyperledger/[email protected]/shim/handler.go:209 +0x4a2 github.com/hyperledger/fabric-chaincode-go/shim.(*Handler).handleStubInteraction(0xc0005983c0, 0xc0004982a0, 0xc0005a4a80, 0xc000594960) C:/Users/devcs/go/pkg/mod/github.com/hyperledger/[email protected]/shim/handler.go:159 +0x5c created by github.com/hyperledger/fabric-chaincode-go/shim.(*Handler).handleReady C:/Users/devcs/go/pkg/mod/github.com/hyperledger/[email protected]/shim/handler.go:620 +0x37f message User {
string msp_id = 1;
string id = 3;
string name = 2;
string affiliation = 4;
repeated Membership memberships = 5;
}
message UserId {
string msp_id = 1;
string id = 2;
}
message UserList {
repeated User users = 1;
}
{
"items": [
{
"@type": "type.googleapis.com/schema.UserId",
"msp_id": "Org1MSP",
"id": "org-admin"
},
{
"@type": "type.googleapis.com/schema.UserId",
"msp_id": "Org1MSP",
"id": "user1"
}
]
} |
I am able to get the users full value by using the |
It doesn't hit that error if I leave off the |
Is there a way to set the router so that using the state mappings I could have the object defined in the .proto stored on the chain as a Json object/struct instead of a binary protobuf? I have already set the router option
WithSerializer(serialize.PreferJSONSerializer)
. The reason this would be useful is it would enable the ability to use CouchDB to be used in order to use rich queries.The text was updated successfully, but these errors were encountered: