Ejemplo n.º 1
0
        public ChainCodeInvokeResponse Invoke(IChaincodeStub stub)
        {
            try
            {
                var funcname = stub.GetFunction();
                switch (funcname)
                {
                case ConfigKey.InitChannelFunc:
                    return(CreateNewChannel(stub));

                case ConfigKey.AddOrgFunc:
                    return(AddOrg(stub));

                case ConfigKey.UpdateOrgFunc:
                    return(UpdateOrg(stub));

                case ConfigKey.AddOrgMemberFunc:
                    return(AddOrgMember(stub));

                case ConfigKey.UpdateOrgMemberFunc:
                    return(UpdateOrgMember(stub));

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(stub.Response(ex.Message, StatusCode.BAD_OTHERS));
            }
        }
Ejemplo n.º 2
0
        public ChainCodeInvokeResponse Query(IChaincodeStub stub)
        {
            var func = stub.GetFunction().ToUpper();

            switch (func)
            {
            case "FINDBYKEY":
                return(FindByKey(stub));

            default:
                return(null);
            }
        }
Ejemplo n.º 3
0
        public ChainCodeInvokeResponse Invoke(IChaincodeStub stub)
        {
            var func = stub.GetFunction().ToUpper();

            switch (func)
            {
            case "TRANSFER":
                return(Transfer(stub));

            default:
                return(stub.Response("can not find function", StatusCode.BAD_OTHERS));
            }
        }
Ejemplo n.º 4
0
        public ChainCodeInvokeResponse Query(IChaincodeStub stub)
        {
            try
            {
                var funcname = stub.GetFunction();
                switch (funcname)
                {
                //查询配置信息
                case ConfigKey.QueryChannelConfig:
                    return(QueryChannelConfig(stub));

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(stub.Response(ex.Message, StatusCode.BAD_OTHERS));
            }
        }
Ejemplo n.º 5
0
        public ChainCodeInvokeResponse Invoke(IChaincodeStub stub)
        {
            try
            {
                var funcname = stub.GetFunction();
                switch (funcname)
                {
                //安装链码 把链码配置到通道中
                case ConfigKey.InstallChaincodeFunc:
                    return(InstallChaincode(stub));

                //初始化链码 把init链码配置
                case ConfigKey.InitChaincodeFunc:
                    return(InitChaincode(stub));

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(stub.Response(ex.Message, StatusCode.BAD_OTHERS));
            }
        }