| @@ -89,7 +89,7 @@ public interface DataCodes { | |||
| public static final int ENUM_TYPE_TRANSACTION_STATE = 0xB22; | |||
| public static final int ENUM_TYPE_DATA_TYPE = 0xB23; | |||
| public static final int ENUM_TYPE_BYTES_VALUE_TYPE = 0xB23; | |||
| public static final int DIGITALSIGNATURE = 0xB30; | |||
| @@ -2,7 +2,6 @@ package com.jd.blockchain.binaryproto; | |||
| import com.jd.blockchain.utils.io.BytesInputStream; | |||
| import com.jd.blockchain.utils.io.BytesOutputBuffer; | |||
| import com.jd.blockchain.utils.io.BytesSlice; | |||
| /** | |||
| * 二进制编码器; | |||
| @@ -37,11 +37,11 @@ public @interface DataField { | |||
| * 基本数据类型; | |||
| * <p> | |||
| * | |||
| * 如果字段的类型属于 {@link DataType} 枚举中的基本数据类型,则需要显式指定一种具体的类型; | |||
| * 如果字段的类型属于 {@link PrimitiveType} 枚举中的基本数据类型,则需要显式指定一种具体的类型; | |||
| * | |||
| * @return | |||
| */ | |||
| DataType primitiveType() default DataType.NIL; | |||
| PrimitiveType primitiveType() default PrimitiveType.NIL; | |||
| /** | |||
| * 是否是枚举类型; | |||
| @@ -78,8 +78,8 @@ public @interface DataField { | |||
| /** | |||
| * 最大长度,单位为“byte” | |||
| * <p> | |||
| * 仅对于文本、字节数组、大整数等相关的数据类型有效(即:{@link DataType} 枚举中编码大于等于 0x20 | |||
| * {@link DataType#TEXT}的数据类型); | |||
| * 仅对于文本、字节数组、大整数等相关的数据类型有效(即:{@link PrimitiveType} 枚举中编码大于等于 0x20 | |||
| * {@link PrimitiveType#TEXT}的数据类型); | |||
| * | |||
| * @return | |||
| */ | |||
| @@ -1,114 +1,11 @@ | |||
| package com.jd.blockchain.binaryproto; | |||
| /** | |||
| * 键值操作的数据类型; | |||
| * | |||
| * @author huanghaiquan | |||
| * | |||
| */ | |||
| public enum DataType { | |||
| /** | |||
| * 空; | |||
| */ | |||
| NIL((byte) 0x00), | |||
| /** | |||
| * 布尔型; | |||
| */ | |||
| BOOLEAN((byte) 0x10), | |||
| /** | |||
| * 数值型: | |||
| */ | |||
| INT8((byte) 0x11), | |||
| INT16((byte) 0x12), | |||
| INT32((byte) 0x13), | |||
| INT64((byte) 0x14), | |||
| /** | |||
| * 日期时间; | |||
| */ | |||
| DATETIME((byte) 0x15), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| TEXT((byte) 0x20), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| JSON((byte) 0x21), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| XML((byte) 0x22), | |||
| /** | |||
| * 二进制数据; | |||
| */ | |||
| BYTES((byte) 0x40), | |||
| /** | |||
| * 大整数; | |||
| */ | |||
| BIG_INT((byte) 0x41), | |||
| /** | |||
| * 图片; | |||
| */ | |||
| IMG((byte) 0x42), | |||
| /** | |||
| * 视频; | |||
| */ | |||
| VIDEO((byte) 0x43), | |||
| /** | |||
| * 位置; | |||
| */ | |||
| LOCATION((byte) 0x44); | |||
| // /** | |||
| // * 引用; <br> | |||
| // * | |||
| // * 表示引用区块链系统中的某一个特定的对象,用以下形式的 URI 表示; | |||
| // * | |||
| // * state://ledger/account/key/version <br> | |||
| // * 或 <br> | |||
| // * proof:state://account_merkle_path/key_merkle_path | |||
| // * | |||
| // * proof:tx:// | |||
| // * | |||
| // */ | |||
| // REFERENCE((byte) 0x80); | |||
| public static final byte NUMERIC_FLAG = (byte)0x10; | |||
| public static final byte TEXT_FLAG = (byte)0x20; | |||
| public static final byte BINARY_FLAG = (byte)0x40; | |||
| public final byte CODE; | |||
| private DataType(byte code) { | |||
| this.CODE = code; | |||
| } | |||
| public static DataType valueOf(byte code) { | |||
| for (DataType dataType : DataType.values()) { | |||
| if (dataType.CODE == code) { | |||
| return dataType; | |||
| } | |||
| } | |||
| throw new IllegalArgumentException("Unsupported code[" + code + "] of DataType!"); | |||
| } | |||
| } | |||
| package com.jd.blockchain.binaryproto; | |||
| public interface DataType { | |||
| public static final byte NUMERIC_FLAG = (byte)0x10; | |||
| public static final byte TEXT_FLAG = (byte)0x20; | |||
| public static final byte BINARY_FLAG = (byte)0x40; | |||
| } | |||
| @@ -13,11 +13,11 @@ public @interface EnumField { | |||
| * 枚举值的类型; | |||
| * | |||
| * <p> | |||
| * 注:只支持 {@link DataType#INT8} ~ {@link DataType#INT32} 这几种类型; | |||
| * 注:只支持 {@link PrimitiveType#INT8} ~ {@link PrimitiveType#INT32} 这几种类型; | |||
| * | |||
| * | |||
| * @return | |||
| */ | |||
| DataType type(); | |||
| PrimitiveType type(); | |||
| } | |||
| @@ -10,7 +10,7 @@ public interface EnumSpecification { | |||
| long getVersion(); | |||
| DataType getValueType(); | |||
| PrimitiveType getValueType(); | |||
| int[] getItemValues(); | |||
| @@ -33,11 +33,11 @@ public interface FieldSpec { | |||
| * 字段的值的类型; | |||
| * <p> | |||
| * 如果不是字段的值不是基本类型,则返回 null(即: {@link DataField#primitiveType()} 设置为 | |||
| * {@link DataType#NIL}); | |||
| * {@link PrimitiveType#NIL}); | |||
| * | |||
| * @return | |||
| */ | |||
| DataType getPrimitiveType(); | |||
| PrimitiveType getPrimitiveType(); | |||
| /** | |||
| * 字段的值引用的枚举契约; | |||
| @@ -0,0 +1,93 @@ | |||
| package com.jd.blockchain.binaryproto; | |||
| /** | |||
| * 键值操作的数据类型; | |||
| * | |||
| * @author huanghaiquan | |||
| * | |||
| */ | |||
| public enum PrimitiveType { | |||
| /** | |||
| * 空; | |||
| */ | |||
| NIL((byte) 0x00), | |||
| /** | |||
| * 布尔型; | |||
| */ | |||
| BOOLEAN((byte) 0x10), | |||
| /** | |||
| * 数值型: | |||
| */ | |||
| INT8((byte) 0x11), | |||
| INT16((byte) 0x12), | |||
| INT32((byte) 0x13), | |||
| INT64((byte) 0x14), | |||
| /** | |||
| * 日期时间; | |||
| */ | |||
| DATETIME((byte) 0x15), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| TEXT((byte) 0x20), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| JSON((byte) 0x21), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| XML((byte) 0x22), | |||
| /** | |||
| * 二进制数据; | |||
| */ | |||
| BYTES((byte) 0x40), | |||
| /** | |||
| * 大整数; | |||
| */ | |||
| BIG_INT((byte) 0x41), | |||
| /** | |||
| * 图片; | |||
| */ | |||
| IMG((byte) 0x42), | |||
| /** | |||
| * 视频; | |||
| */ | |||
| VIDEO((byte) 0x43), | |||
| /** | |||
| * 位置; | |||
| */ | |||
| LOCATION((byte) 0x44); | |||
| public final byte CODE; | |||
| private PrimitiveType(byte code) { | |||
| this.CODE = code; | |||
| } | |||
| public static PrimitiveType valueOf(byte code) { | |||
| for (PrimitiveType dataType : PrimitiveType.values()) { | |||
| if (dataType.CODE == code) { | |||
| return dataType; | |||
| } | |||
| } | |||
| throw new IllegalArgumentException("Code[" + code + "] not suppported by PrimitiveType!"); | |||
| } | |||
| } | |||
| @@ -2,7 +2,6 @@ package com.jd.blockchain.binaryproto.impl; | |||
| import com.jd.blockchain.utils.io.BytesInputStream; | |||
| import com.jd.blockchain.utils.io.BytesOutputBuffer; | |||
| import com.jd.blockchain.utils.io.BytesSlice; | |||
| import com.jd.blockchain.utils.io.NumberMask; | |||
| public abstract class AbstractDynamicValueConverter implements DynamicValueConverter { | |||
| @@ -17,7 +17,7 @@ import com.jd.blockchain.binaryproto.DataContractEncoder; | |||
| import com.jd.blockchain.binaryproto.DataContractException; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataSpecification; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumContract; | |||
| import com.jd.blockchain.binaryproto.EnumField; | |||
| import com.jd.blockchain.binaryproto.EnumSpecification; | |||
| @@ -65,23 +65,23 @@ public class DataContractContext { | |||
| private static Map<Class<?>, EnumSpecification> enumContractSpecMap = new ConcurrentHashMap<>(); | |||
| private static Map<DataType, Map<Class<?>, ValueConverter>> primitiveTypeConverters = new HashMap<>(); | |||
| private static Map<PrimitiveType, Map<Class<?>, ValueConverter>> primitiveTypeConverters = new HashMap<>(); | |||
| static { | |||
| addConverterMapping(DataType.BOOLEAN, boolean.class, new BoolConverter()); | |||
| addConverterMapping(DataType.BOOLEAN, Boolean.class, new BoolWrapperConverter()); | |||
| addConverterMapping(DataType.INT8, byte.class, new Int8ByteConverter()); | |||
| addConverterMapping(DataType.INT8, Byte.class, new Int8ByteWrapperConverter()); | |||
| addConverterMapping(DataType.INT16, short.class, new Int16ShortConverter()); | |||
| addConverterMapping(DataType.INT16, Short.class, new Int16ShortWrapperConverter()); | |||
| addConverterMapping(DataType.INT16, char.class, new Int16CharConverter()); | |||
| addConverterMapping(DataType.INT16, Character.class, new Int16CharWrapperConverter()); | |||
| addConverterMapping(DataType.INT32, int.class, new Int32IntConverter()); | |||
| addConverterMapping(DataType.INT32, Integer.class, new Int32IntWrapperConverter()); | |||
| addConverterMapping(DataType.INT64, long.class, new Int64LongConverter()); | |||
| addConverterMapping(DataType.INT64, Long.class, new Int64LongWrapperConverter()); | |||
| addConverterMapping(DataType.TEXT, String.class, new StringValueConverter()); | |||
| addConverterMapping(DataType.BYTES, byte[].class, new BytesValueConverter()); | |||
| addConverterMapping(PrimitiveType.BOOLEAN, boolean.class, new BoolConverter()); | |||
| addConverterMapping(PrimitiveType.BOOLEAN, Boolean.class, new BoolWrapperConverter()); | |||
| addConverterMapping(PrimitiveType.INT8, byte.class, new Int8ByteConverter()); | |||
| addConverterMapping(PrimitiveType.INT8, Byte.class, new Int8ByteWrapperConverter()); | |||
| addConverterMapping(PrimitiveType.INT16, short.class, new Int16ShortConverter()); | |||
| addConverterMapping(PrimitiveType.INT16, Short.class, new Int16ShortWrapperConverter()); | |||
| addConverterMapping(PrimitiveType.INT16, char.class, new Int16CharConverter()); | |||
| addConverterMapping(PrimitiveType.INT16, Character.class, new Int16CharWrapperConverter()); | |||
| addConverterMapping(PrimitiveType.INT32, int.class, new Int32IntConverter()); | |||
| addConverterMapping(PrimitiveType.INT32, Integer.class, new Int32IntWrapperConverter()); | |||
| addConverterMapping(PrimitiveType.INT64, long.class, new Int64LongConverter()); | |||
| addConverterMapping(PrimitiveType.INT64, Long.class, new Int64LongWrapperConverter()); | |||
| addConverterMapping(PrimitiveType.TEXT, String.class, new StringValueConverter()); | |||
| addConverterMapping(PrimitiveType.BYTES, byte[].class, new BytesValueConverter()); | |||
| ENCODER_LOOKUP = new DataContractEncoderLookup() { | |||
| @Override | |||
| @@ -101,7 +101,7 @@ public class DataContractContext { | |||
| }; | |||
| } | |||
| private static void addConverterMapping(DataType protocalType, Class<?> javaType, ValueConverter converter) { | |||
| private static void addConverterMapping(PrimitiveType protocalType, Class<?> javaType, ValueConverter converter) { | |||
| Map<Class<?>, ValueConverter> converterMap = primitiveTypeConverters.get(protocalType); | |||
| if (converterMap == null) { | |||
| converterMap = new HashMap<>(); | |||
| @@ -110,14 +110,14 @@ public class DataContractContext { | |||
| converterMap.put(javaType, converter); | |||
| } | |||
| private static ValueConverter getPrimitiveTypeConverter(DataType protocalType, Class<?> javaType) { | |||
| private static ValueConverter getPrimitiveTypeConverter(PrimitiveType protocalType, Class<?> javaType) { | |||
| Map<Class<?>, ValueConverter> converterMap = primitiveTypeConverters.get(protocalType); | |||
| if (converterMap != null) { | |||
| ValueConverter converter = converterMap.get(javaType); | |||
| if (converter != null) { | |||
| return converter; | |||
| } | |||
| if (DataType.BYTES == protocalType && BytesSerializable.class.isAssignableFrom(javaType)) { | |||
| if (PrimitiveType.BYTES == protocalType && BytesSerializable.class.isAssignableFrom(javaType)) { | |||
| converter = new BytesSerializableValueConverter(javaType); | |||
| converterMap.put(javaType, converter); | |||
| return converter; | |||
| @@ -366,7 +366,7 @@ public class DataContractContext { | |||
| EnumSpecificationInfo enumSpec = (EnumSpecificationInfo) fieldInfo.fieldSpec.getRefEnum(); | |||
| int[] values = enumSpec.getItemValues(); | |||
| Object[] constants = enumSpec.getConstants(); | |||
| DataType codeType = enumSpec.getValueType(); | |||
| PrimitiveType codeType = enumSpec.getValueType(); | |||
| ValueConverter baseConverter = getPrimitiveTypeConverter(codeType, enumSpec.getDataType()); | |||
| @@ -410,8 +410,8 @@ public class DataContractContext { | |||
| private static BinarySliceSpec buildSlice(FieldSpecInfo fieldSpec) { | |||
| boolean fixed = false; | |||
| int len = -1; | |||
| DataType fixedValueType = null; | |||
| if (fieldSpec.getPrimitiveType() != null && fieldSpec.getPrimitiveType() != DataType.NIL) { | |||
| PrimitiveType fixedValueType = null; | |||
| if (fieldSpec.getPrimitiveType() != null && fieldSpec.getPrimitiveType() != PrimitiveType.NIL) { | |||
| fixedValueType = fieldSpec.getPrimitiveType(); | |||
| } else if (fieldSpec.getRefEnum() != null) { | |||
| fixedValueType = fieldSpec.getRefEnum().getValueType(); | |||
| @@ -546,7 +546,7 @@ public class DataContractContext { | |||
| } | |||
| int maxSize = annoField.maxSize(); | |||
| DataType primitiveType = annoField.primitiveType(); | |||
| PrimitiveType primitiveType = annoField.primitiveType(); | |||
| if (primitiveType != null) { | |||
| primitiveType = verifyPrimitiveType(primitiveType, dataType, accessor); | |||
| } | |||
| @@ -650,7 +650,7 @@ public class DataContractContext { | |||
| * @param dataType | |||
| * @return | |||
| */ | |||
| private static DataType verifyPrimitiveType(DataType primitiveType, Class<?> dataType, Method accessor) { | |||
| private static PrimitiveType verifyPrimitiveType(PrimitiveType primitiveType, Class<?> dataType, Method accessor) { | |||
| switch (primitiveType) { | |||
| case NIL: | |||
| return null; | |||
| @@ -762,6 +762,7 @@ public class DataContractContext { | |||
| public Method reader; | |||
| @SuppressWarnings("unused") | |||
| public DataField annoField; | |||
| public FieldDeclaredInfo(Method accessor, DataField annoField, FieldSpecInfo fieldSpec) { | |||
| @@ -1,6 +1,5 @@ | |||
| package com.jd.blockchain.binaryproto.impl; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| @@ -3,7 +3,7 @@ package com.jd.blockchain.binaryproto.impl; | |||
| import java.util.LinkedHashSet; | |||
| import java.util.Set; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumSpecification; | |||
| /** | |||
| @@ -11,7 +11,7 @@ import com.jd.blockchain.binaryproto.EnumSpecification; | |||
| */ | |||
| public class EnumSpecificationInfo implements EnumSpecification { | |||
| private DataType valueType; | |||
| private PrimitiveType valueType; | |||
| private Class<?> dataType; | |||
| @@ -24,7 +24,7 @@ public class EnumSpecificationInfo implements EnumSpecification { | |||
| // private Map<Object, Object> itemCodeMapping = new HashMap<>(); | |||
| // private Map<Object, Object> codeItemMapping = new HashMap<>(); | |||
| public EnumSpecificationInfo(DataType valueType, int code, long version, String name, String description, Class<?> dataType) { | |||
| public EnumSpecificationInfo(PrimitiveType valueType, int code, long version, String name, String description, Class<?> dataType) { | |||
| this.valueType = valueType; | |||
| this.code = code; | |||
| this.version = version; | |||
| @@ -54,7 +54,7 @@ public class EnumSpecificationInfo implements EnumSpecification { | |||
| } | |||
| @Override | |||
| public DataType getValueType() { | |||
| public PrimitiveType getValueType() { | |||
| return this.valueType; | |||
| } | |||
| @@ -1,14 +1,14 @@ | |||
| package com.jd.blockchain.binaryproto.impl; | |||
| import com.jd.blockchain.binaryproto.DataContractException; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.utils.io.BytesSlice; | |||
| public class EnumValueConverter implements FixedValueConverter { | |||
| private Class<?> enumType; | |||
| private DataType codeType; | |||
| private PrimitiveType codeType; | |||
| private int[] values; | |||
| @@ -16,7 +16,7 @@ public class EnumValueConverter implements FixedValueConverter { | |||
| private FixedValueConverter valueConverter; | |||
| public EnumValueConverter(Class<?> enumType, DataType codeType, int[] values, Object[] constants, FixedValueConverter valueConverter) { | |||
| public EnumValueConverter(Class<?> enumType, PrimitiveType codeType, int[] values, Object[] constants, FixedValueConverter valueConverter) { | |||
| this.enumType = enumType; | |||
| this.values = values; | |||
| this.constants = constants; | |||
| @@ -1,7 +1,7 @@ | |||
| package com.jd.blockchain.binaryproto.impl; | |||
| import com.jd.blockchain.binaryproto.DataSpecification; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumSpecification; | |||
| import com.jd.blockchain.binaryproto.FieldSpec; | |||
| @@ -15,7 +15,7 @@ public class FieldSpecInfo implements FieldSpec { | |||
| private boolean repeatable; | |||
| private DataType primitiveType; | |||
| private PrimitiveType primitiveType; | |||
| private EnumSpecification enumSpec; | |||
| @@ -27,7 +27,7 @@ public class FieldSpecInfo implements FieldSpec { | |||
| private boolean isGenericContract = false; | |||
| public FieldSpecInfo(int order, String name, String decription, DataType primitiveType, boolean repeatable, | |||
| public FieldSpecInfo(int order, String name, String decription, PrimitiveType primitiveType, boolean repeatable, | |||
| int maxSize, Class<?> dataType) { | |||
| if (primitiveType == null) { | |||
| throw new IllegalArgumentException("primitiveType is null!"); | |||
| @@ -71,7 +71,7 @@ public class FieldSpecInfo implements FieldSpec { | |||
| } | |||
| @Override | |||
| public DataType getPrimitiveType() { | |||
| public PrimitiveType getPrimitiveType() { | |||
| return primitiveType; | |||
| } | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/11/30. | |||
| @@ -10,7 +10,7 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code = 0xc, name = "CompositeDatas", description = "") | |||
| public interface CompositeDatas { | |||
| @DataField(order = 1, primitiveType = DataType.BOOLEAN) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BOOLEAN) | |||
| boolean isEnable(); | |||
| @DataField(order = 2, refEnum = true) | |||
| @@ -22,7 +22,7 @@ public interface CompositeDatas { | |||
| @DataField(order=4, list = true, refContract=true, genericContract = true) | |||
| Operation[] getOperations(); | |||
| @DataField(order = 5, primitiveType = DataType.INT16) | |||
| @DataField(order = 5, primitiveType = PrimitiveType.INT16) | |||
| short getAge(); | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| package test.com.jd.blockchain.binaryproto; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumContract; | |||
| import com.jd.blockchain.binaryproto.EnumField; | |||
| @@ -14,7 +14,7 @@ public enum EnumLevel { | |||
| V2((byte) 2); | |||
| @EnumField(type= DataType.INT8) | |||
| @EnumField(type= PrimitiveType.INT8) | |||
| public final byte CODE; | |||
| public byte getCode() { | |||
| return CODE; | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/11. | |||
| @@ -10,22 +10,22 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code = 0x06, name = "Primitive", description = "") | |||
| public interface FieldOrderConflictedDatas { | |||
| @DataField(order = 2, primitiveType = DataType.BOOLEAN) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BOOLEAN) | |||
| boolean isEnable(); | |||
| @DataField(order = 3, primitiveType = DataType.INT8) | |||
| @DataField(order = 3, primitiveType = PrimitiveType.INT8) | |||
| byte isBoy(); | |||
| @DataField(order = 7, primitiveType = DataType.INT16) | |||
| @DataField(order = 7, primitiveType = PrimitiveType.INT16) | |||
| short getAge(); | |||
| @DataField(order = -1, primitiveType = DataType.INT32) | |||
| @DataField(order = -1, primitiveType = PrimitiveType.INT32) | |||
| int getId(); | |||
| @DataField(order = 6, primitiveType = DataType.TEXT) | |||
| @DataField(order = 6, primitiveType = PrimitiveType.TEXT) | |||
| String getName(); | |||
| @DataField(order = 7, primitiveType = DataType.INT64) | |||
| @DataField(order = 7, primitiveType = PrimitiveType.INT64) | |||
| long getValue(); | |||
| @@ -1,8 +1,6 @@ | |||
| package test.com.jd.blockchain.binaryproto; | |||
| import java.util.ArrayList; | |||
| import java.util.Collection; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| /** | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| import com.jd.blockchain.utils.net.NetworkAddress; | |||
| @@ -12,37 +12,37 @@ import com.jd.blockchain.utils.net.NetworkAddress; | |||
| @DataContract(code = 0x05, name = "Primitive", description = "") | |||
| public interface PrimitiveDatas { | |||
| @DataField(order = 2, primitiveType = DataType.BOOLEAN) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BOOLEAN) | |||
| boolean isEnable(); | |||
| @DataField(order = 3, primitiveType = DataType.INT8) | |||
| @DataField(order = 3, primitiveType = PrimitiveType.INT8) | |||
| byte isBoy(); | |||
| @DataField(order = 4, primitiveType = DataType.INT16) | |||
| @DataField(order = 4, primitiveType = PrimitiveType.INT16) | |||
| short getAge(); | |||
| @DataField(order = -1, primitiveType = DataType.INT32) | |||
| @DataField(order = -1, primitiveType = PrimitiveType.INT32) | |||
| int getId(); | |||
| @DataField(order = 6, primitiveType = DataType.TEXT) | |||
| @DataField(order = 6, primitiveType = PrimitiveType.TEXT) | |||
| String getName(); | |||
| @DataField(order = 7, primitiveType = DataType.INT64) | |||
| @DataField(order = 7, primitiveType = PrimitiveType.INT64) | |||
| long getValue(); | |||
| @DataField(order = 12, primitiveType = DataType.BYTES) | |||
| @DataField(order = 12, primitiveType = PrimitiveType.BYTES) | |||
| byte[] getImage(); | |||
| @DataField(order = 100, primitiveType = DataType.INT16) | |||
| @DataField(order = 100, primitiveType = PrimitiveType.INT16) | |||
| char getFlag(); | |||
| @DataField(order = 200, primitiveType = DataType.BYTES) | |||
| @DataField(order = 200, primitiveType = PrimitiveType.BYTES) | |||
| Bytes getConfig(); | |||
| @DataField(order = 201, primitiveType = DataType.BYTES) | |||
| @DataField(order = 201, primitiveType = PrimitiveType.BYTES) | |||
| Bytes getSetting(); | |||
| @DataField(order = 202, primitiveType = DataType.BYTES) | |||
| @DataField(order = 202, primitiveType = PrimitiveType.BYTES) | |||
| NetworkAddress getNetworkAddr(); | |||
| } | |||
| @@ -1,7 +1,5 @@ | |||
| package test.com.jd.blockchain.binaryproto; | |||
| import org.omg.CORBA.PUBLIC_MEMBER; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| import com.jd.blockchain.utils.net.NetworkAddress; | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/11/29. | |||
| @@ -10,7 +10,7 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code = 0xa, name = "SubOperation", description = "") | |||
| public interface SubOperation extends Operation { | |||
| @DataField(order=1, primitiveType = DataType.TEXT) | |||
| @DataField(order=1, primitiveType = PrimitiveType.TEXT) | |||
| String getUserName(); | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| // | |||
| //@DataContract(code=0x02, name="Address" , description="") | |||
| //public interface Address { | |||
| // | |||
| // @DataField(order=1, primitiveType=ValueType.TEXT) | |||
| // String getStreet(); | |||
| // | |||
| // @DataField(order=2, primitiveType=ValueType.INT32) | |||
| // int getNumber(); | |||
| // | |||
| //} | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/9. | |||
| @@ -10,10 +10,10 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code=0x02, name="Address" , description="") | |||
| public interface AddressCodeDuplicate { | |||
| @DataField(order=1, primitiveType= DataType.TEXT) | |||
| @DataField(order=1, primitiveType= PrimitiveType.TEXT) | |||
| String getStreet(); | |||
| @DataField(order=2, primitiveType=DataType.INT32) | |||
| @DataField(order=2, primitiveType=PrimitiveType.INT32) | |||
| int getNumber(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/9. | |||
| @@ -10,10 +10,10 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code=0x03, name="Address" , description="") | |||
| public interface AddressOrderDuplicate { | |||
| @DataField(order=1, primitiveType= DataType.TEXT) | |||
| @DataField(order=1, primitiveType= PrimitiveType.TEXT) | |||
| String getStreet(); | |||
| @DataField(order=1, primitiveType=DataType.INT32) | |||
| @DataField(order=1, primitiveType=PrimitiveType.INT32) | |||
| int getNumber(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/11. | |||
| @@ -10,16 +10,16 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code=0x08, name="Array" , description="") | |||
| public interface Array { | |||
| @DataField(order=1, primitiveType= DataType.INT32, list=true) | |||
| @DataField(order=1, primitiveType= PrimitiveType.INT32, list=true) | |||
| int[] getScores(); | |||
| @DataField(order=2, primitiveType=DataType.TEXT, list=true) | |||
| @DataField(order=2, primitiveType=PrimitiveType.TEXT, list=true) | |||
| String[] getFeatures(); | |||
| @DataField(order=3, primitiveType=DataType.BYTES) | |||
| @DataField(order=3, primitiveType=PrimitiveType.BYTES) | |||
| byte[] getFamilyMemberAges(); | |||
| @DataField(order=4, primitiveType=DataType.INT64, list=true) | |||
| @DataField(order=4, primitiveType=PrimitiveType.INT64, list=true) | |||
| long[] getFamilyMemberIds(); | |||
| } | |||
| @@ -1,158 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.EnumContract; | |||
| //import com.jd.blockchain.binaryproto.EnumField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| //import com.jd.blockchain.crypto.CryptoAlgorithmType; | |||
| //import my.utils.io.BytesUtils; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@EnumContract(code=0x0102) | |||
| //public enum CryptoAlgorithm { | |||
| // | |||
| // // Hash 类; | |||
| // // SHA_128(CryptoAlgorithmMask.HASH, (byte) 0x01, false, false), | |||
| // | |||
| // SHA_256(CryptoAlgorithmType.HASH, (byte) 0x01, false, false), | |||
| // | |||
| // RIPLE160(CryptoAlgorithmType.HASH, (byte) 0x02, false, false), | |||
| // | |||
| // SM3(CryptoAlgorithmType.HASH, (byte) 0x03, false, false), | |||
| // | |||
| // // 非对称签名/加密算法; | |||
| // | |||
| // /** | |||
| // * RSA 签名算法;可签名,可加密; | |||
| // */ | |||
| // RSA(CryptoAlgorithmType.ASYMMETRIC, (byte) 0x01, true, true), | |||
| // | |||
| // /** | |||
| // * ED25519 签名算法;只用于签名,没有加密特性; | |||
| // */ | |||
| // ED25519(CryptoAlgorithmType.ASYMMETRIC, (byte) 0x02, true, false), | |||
| // | |||
| // /** | |||
| // * ECDSA 签名算法;只用于签名,没有加密特性;??? | |||
| // */ | |||
| // ECDSA(CryptoAlgorithmType.ASYMMETRIC, (byte) 0x03, true, false), | |||
| // | |||
| // /** | |||
| // * 国密 SM2 算法;可签名,可加密; | |||
| // */ | |||
| // SM2(CryptoAlgorithmType.ASYMMETRIC, (byte) 0x04, true, true), | |||
| // | |||
| // // 对称加密; | |||
| // /** | |||
| // * AES 算法;可加密; | |||
| // */ | |||
| // AES(CryptoAlgorithmType.SYMMETRIC, (byte) 0x01, false, true), | |||
| // | |||
| // SM4(CryptoAlgorithmType.SYMMETRIC, (byte) 0x02, false, true), | |||
| // | |||
| // // 随机性; | |||
| // /** | |||
| // * ????? 一种随机数算法,待定; | |||
| // */ | |||
| // JAVA_SECURE(CryptoAlgorithmType.RANDOM, (byte) 0x01, false, false); | |||
| // | |||
| // /** | |||
| // * 密码算法的代号;<br> | |||
| // * 注:只占16位; | |||
| // */ | |||
| // @EnumField(type = ValueType.INT8) | |||
| // public final byte CODE; | |||
| // | |||
| // private final boolean signable; | |||
| // | |||
| // private final boolean encryptable; | |||
| // | |||
| // private CryptoAlgorithm(byte algType, byte algId, boolean signable, boolean encryptable) { | |||
| // this.CODE = (byte) (algType | algId); | |||
| // this.signable = signable; | |||
| // this.encryptable = encryptable; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 是否属于摘要算法; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // public boolean isHash() { | |||
| // return (CODE & CryptoAlgorithmType.HASH) == CryptoAlgorithmType.HASH; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 是否属于非对称密码算法; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // public boolean isAsymmetric() { | |||
| // return (CODE & CryptoAlgorithmType.ASYMMETRIC) == CryptoAlgorithmType.ASYMMETRIC; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 是否属于对称密码算法; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // public boolean isSymmetric() { | |||
| // return (CODE & CryptoAlgorithmType.SYMMETRIC) == CryptoAlgorithmType.SYMMETRIC; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 是否属于随机数算法; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // public boolean isRandom() { | |||
| // return (CODE & CryptoAlgorithmType.RANDOM) == CryptoAlgorithmType.RANDOM; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 是否支持签名操作; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // public boolean isSignable() { | |||
| // return signable; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 是否支持加密操作; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // public boolean isEncryptable() { | |||
| // return encryptable; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 返回指定编码对应的枚举实例;<br> | |||
| // * | |||
| // * 如果不存在,则返回 null; | |||
| // * | |||
| // * @param code | |||
| // * @return | |||
| // */ | |||
| // public static CryptoAlgorithm valueOf(byte code) { | |||
| // for (CryptoAlgorithm alg : CryptoAlgorithm.values()) { | |||
| // if (alg.CODE == code) { | |||
| // return alg; | |||
| // } | |||
| // } | |||
| // throw new IllegalArgumentException("CryptoAlgorithm doesn't support enum code[" + code + "]!"); | |||
| // } | |||
| // | |||
| // // /** | |||
| // // * @return | |||
| // // */ | |||
| // // public byte[] toBytes() { | |||
| // // byte[] bytes = BytesUtils.toBytes(CODE); | |||
| // // byte[] result = new byte[BYTES_SIZE]; | |||
| // // System.arraycopy(bytes, 2, result, 0, 2); | |||
| // // // TODO: 只返回最后2个字节; | |||
| // // return result; | |||
| // // } | |||
| //} | |||
| @@ -1,41 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@DataContract(code=0x0d, name="CryptoSetting", description = "Crypto setting") | |||
| //public interface CryptoSetting { | |||
| // | |||
| // /** | |||
| // * 系统中使用的 Hash 算法; <br> | |||
| // * | |||
| // * 对于历史数据,如果它未发生更改,则总是按照该数据产生时采用的算法进行校验,即使当时指定的Hash算法和当前的不同;<br> | |||
| // * | |||
| // * 如果对数据进行了更新,则采用新的 Hash 算法来计算生成完整性证明; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @DataField(order=1, refEnum=true) | |||
| // public HashAlgorithm getHashAlgorithm(); | |||
| // | |||
| // @DataField(order=2, refEnum=true) | |||
| // public CryptoAlgorithm getHashAlgorithm1(); | |||
| // | |||
| // /** | |||
| // * 当有完整性证明的数据被从持久化介质中加载时,是否对其进行完整性校验(重新计算 hash 比对是否一致); <br> | |||
| // * | |||
| // * 如果为 true ,则自动进行校验,如果校验失败,会引发异常; <br> | |||
| // * | |||
| // * 注意:开启此选项将对性能会产生负面影响,因此使用者需要在性能和数据安全性之间做出权衡; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @DataField(order=3, primitiveType= ValueType.BOOLEAN) | |||
| // public boolean getAutoVerifyHash();//func name is getxxxxx type | |||
| // | |||
| //} | |||
| // | |||
| @@ -1,50 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.EnumContract; | |||
| //import com.jd.blockchain.binaryproto.EnumField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@EnumContract(code=0x0101) | |||
| //public enum HashAlgorithm { | |||
| // | |||
| // RIPE160((byte) 1), | |||
| // | |||
| // SHA256((byte) 2), | |||
| // | |||
| // SM3((byte) 4); | |||
| // | |||
| // @EnumField(type = ValueType.INT8) | |||
| // public final byte CODE; | |||
| // | |||
| // private HashAlgorithm(byte algorithm) { | |||
| // CODE = algorithm; | |||
| // } | |||
| // | |||
| // public byte getAlgorithm() { | |||
| // return CODE; | |||
| // } | |||
| // | |||
| // public static HashAlgorithm valueOf(byte algorithm) { | |||
| // for (HashAlgorithm hashAlgorithm : HashAlgorithm.values()) { | |||
| // if (hashAlgorithm.CODE == algorithm) { | |||
| // return hashAlgorithm; | |||
| // } | |||
| // } | |||
| // throw new IllegalArgumentException("Unsupported hash algorithm [" + algorithm + "]!"); | |||
| // } | |||
| // | |||
| // public static void checkHashAlgorithm(HashAlgorithm algorithm) { | |||
| // switch (algorithm) { | |||
| // case RIPE160: | |||
| // break; | |||
| // case SHA256: | |||
| // break; | |||
| // default: | |||
| // throw new IllegalArgumentException("Unsupported hash algorithm [" + algorithm + "]!"); | |||
| // } | |||
| // } | |||
| //} | |||
| // | |||
| @@ -1,28 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| //import com.jd.blockchain.crypto.hash.HashDigest; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@DataContract(code=0x12, name="LedgerBlock", description ="LedgerBlock") | |||
| //public interface LedgerBlock extends LedgerDataSnapshot{ | |||
| // | |||
| // @DataField(order=1, refHashDigest=true) | |||
| // HashDigest getHash(); | |||
| // | |||
| // @DataField(order=2, refHashDigest=true) | |||
| // HashDigest getPreviousHash(); | |||
| // | |||
| // @DataField(order=3, refHashDigest=true) | |||
| // HashDigest getLedgerHash(); | |||
| // | |||
| // @DataField(order=4, primitiveType=ValueType.INT64) | |||
| // long getHeight(); | |||
| // | |||
| // @DataField(order=5, refHashDigest=true) | |||
| // HashDigest getTransactionSetHash(); | |||
| //} | |||
| @@ -1,34 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.crypto.hash.HashDigest; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@DataContract(code=0x11, name="LedgerDataSnapshot", description ="LedgerDataSnapshot") | |||
| //public interface LedgerDataSnapshot { | |||
| // | |||
| // @DataField(order=1, refHashDigest=true) | |||
| // HashDigest getAdminAccountHash(); | |||
| // | |||
| // @DataField(order=2, refHashDigest=true) | |||
| // HashDigest getUserAccountSetHash(); | |||
| // | |||
| // @DataField(order=3, refHashDigest=true) | |||
| // HashDigest getUserPrivilegeHash(); | |||
| // | |||
| // @DataField(order=4, refHashDigest=true) | |||
| // HashDigest getDataAccountSetHash(); | |||
| // | |||
| // @DataField(order=5, refHashDigest=true) | |||
| // HashDigest getDataPrivilegeHash(); | |||
| // | |||
| // @DataField(order=6, refHashDigest=true) | |||
| // HashDigest getContractAccountSetHash(); | |||
| // | |||
| // @DataField(order=7, refHashDigest=true) | |||
| // HashDigest getContractPrivilegeHash(); | |||
| // | |||
| //} | |||
| @@ -1,25 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@DataContract(code=0x0b, name="LedgerMetadata", description = "Ledger meta data") | |||
| //public interface LedgerMetadata { | |||
| // | |||
| // @DataField(order=1, primitiveType= ValueType.INT8, list=true) | |||
| // byte[] getSeed(); | |||
| // | |||
| // @DataField(order = 2, refContract=true) | |||
| // LedgerSetting getSetting(); | |||
| // | |||
| // @DataField(order=3, primitiveType=ValueType.INT8, list=true) | |||
| // byte[] getPrivilegesHash(); | |||
| // | |||
| // @DataField(order=4, primitiveType=ValueType.INT8, list=true) | |||
| // byte[] getParticipantsHash(); | |||
| // | |||
| //} | |||
| @@ -1,21 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@DataContract(code=0x0c, name="LedgerSetting", description = "Ledger setting") | |||
| //public interface LedgerSetting { | |||
| // | |||
| // //@DataField(order=1, refContract=true) | |||
| // //ConsensusSetting getConsensusSetting(); | |||
| // | |||
| // @DataField(order=2, refContract=true) | |||
| // CryptoSetting getCryptoSetting(); | |||
| // | |||
| // @DataField(order=3, refContract=true) | |||
| // PrivilegeModelSetting getPrivilegesModelSetting(); | |||
| // | |||
| //} | |||
| @@ -1,6 +1,6 @@ | |||
| package test.com.jd.blockchain.binaryproto.contract; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumContract; | |||
| import com.jd.blockchain.binaryproto.EnumField; | |||
| @@ -11,7 +11,7 @@ public enum Level { | |||
| V2((byte) 2); | |||
| @EnumField(type=DataType.INT8) | |||
| @EnumField(type=PrimitiveType.INT8) | |||
| public final byte CODE; | |||
| public byte getCode() { | |||
| return CODE; | |||
| @@ -1,18 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| // | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| // | |||
| ///** | |||
| // * Created by zhangshuang3 on 2018/7/30. | |||
| // */ | |||
| //@DataContract(code=0x10, name="Privilege", description ="Privilege") | |||
| //public interface Privilege { | |||
| // | |||
| // //SortedSet<Byte> getOpCodes(); implement later | |||
| // | |||
| // @DataField(order=2, primitiveType= ValueType.INT64) | |||
| // long getVersion(); | |||
| // | |||
| //} | |||
| @@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/30. | |||
| @@ -10,7 +10,7 @@ import com.jd.blockchain.binaryproto.DataType; | |||
| @DataContract(code=0x0f, name="PrivilegeModelSetting", description ="Privilege Model setting") | |||
| public interface PrivilegeModelSetting { | |||
| @DataField(order=1, primitiveType= DataType.INT64) | |||
| @DataField(order=1, primitiveType= PrimitiveType.INT64) | |||
| long getLatestVersion(); | |||
| //@DataField(order=2, refContract=true) | |||
| @@ -1,20 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/11. | |||
| */ | |||
| /* | |||
| @DataContract(code=0x07, name="RefContract" , description="") | |||
| public interface RefContract { | |||
| @DataField(order=1, refContract=true) | |||
| Address getAddress(); | |||
| @DataField(order=2, refContract=true) | |||
| Address getAddress1(); | |||
| } | |||
| */ | |||
| @@ -1,41 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| /* | |||
| @DataContract(code=0x01, name="测试数据契约1", description = "用于测试的数据契约") | |||
| public interface Student { | |||
| @DataField(order=1, primitiveType=ValueType.INT32) | |||
| int getId(); | |||
| @DataField(order=2, primitiveType=ValueType.INT8) | |||
| byte getFamilyMemberNum(); | |||
| @DataField(order=3, primitiveType=ValueType.TEXT) | |||
| String getName(); | |||
| @DataField(order=4, primitiveType=ValueType.INT16) | |||
| short getAge(); | |||
| @DataField(order=5, refEnum=true) | |||
| Level getLevel(); | |||
| @DataField(order=6, refContract=true) | |||
| Address getAddress(); | |||
| @DataField(order=7, primitiveType=ValueType.INT32, list=true) | |||
| int[] getScores(); | |||
| @DataField(order=8, primitiveType=ValueType.TEXT, list=true) | |||
| String[] getFeatures(); | |||
| @DataField(order=9, primitiveType=ValueType.INT8, list=true) | |||
| byte[] getFamilyMemberAges(); | |||
| @DataField(order=10, primitiveType=ValueType.INT64, list=true) | |||
| long[] getFamilyMemberIds(); | |||
| } | |||
| */ | |||
| @@ -1,44 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/9. | |||
| */ | |||
| /* | |||
| @DataContract(code=0x04, name="测试数据契约1", description = "用于测试的数据契约") | |||
| public interface StudentInvert { | |||
| @DataField(order=10, primitiveType=ValueType.INT64, list=true) | |||
| long[] getFamilyMemberIds(); | |||
| @DataField(order=9, primitiveType=ValueType.INT8, list=true) | |||
| byte[] getFamilyMemberAges(); | |||
| @DataField(order=8, primitiveType=ValueType.TEXT, list=true) | |||
| String[] getFeatures(); | |||
| @DataField(order=7, primitiveType=ValueType.INT32, list=true) | |||
| int[] getScores(); | |||
| @DataField(order=6, refContract=true) | |||
| Address getAddress(); | |||
| @DataField(order=5, refEnum=true) | |||
| Level getLevel(); | |||
| @DataField(order=4, primitiveType=ValueType.INT16) | |||
| short getAge(); | |||
| @DataField(order=3, primitiveType=ValueType.TEXT) | |||
| String getName(); | |||
| @DataField(order=2, primitiveType=ValueType.INT8) | |||
| byte getFamilyMemberNum(); | |||
| @DataField(order=1, primitiveType= ValueType.INT32) | |||
| int getId(); | |||
| } | |||
| */ | |||
| @@ -1,31 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract; | |||
| //import com.jd.blockchain.binaryproto.DataContract; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.ValueType; | |||
| //import com.jd.blockchain.crypto.asymmetric.PubKey; | |||
| //import my.utils.io.ByteArray; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/25. | |||
| */ | |||
| /* | |||
| @DataContract(code=0x09, name="UserAccount", description = "用户账户") | |||
| public interface User { | |||
| @DataField(order=1, primitiveType= ValueType.TEXT) | |||
| String getAddress(); | |||
| @DataField(order=2, refPubKey = true) | |||
| PubKey getPubKey(); | |||
| @DataField(order=3, refPubKey = true) | |||
| PubKey getDataPubKey(); | |||
| @DataField(order=4, primitiveType = ValueType.BYTES) | |||
| ByteArray getDataHash(); | |||
| @DataField(order=5, primitiveType = ValueType.BYTES) | |||
| ByteArray getPrivilegeHash(); | |||
| } | |||
| */ | |||
| @@ -1,29 +0,0 @@ | |||
| /* | |||
| package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| import test.com.jd.blockchain.binaryproto.contract.Address; | |||
| public class AddressImpl implements Address { | |||
| private String street; | |||
| private int number; | |||
| @Override | |||
| public String getStreet() { | |||
| // TODO Auto-generated method stub | |||
| return this.street; | |||
| } | |||
| public void setStreet(String street) { | |||
| this.street = street; | |||
| } | |||
| @Override | |||
| public int getNumber() { | |||
| // TODO Auto-generated method stub | |||
| return this.number; | |||
| } | |||
| public void setNumber(int number) { | |||
| this.number = number; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,40 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import test.com.jd.blockchain.binaryproto.contract.CryptoAlgorithm; | |||
| //import test.com.jd.blockchain.binaryproto.contract.CryptoSetting; | |||
| //import test.com.jd.blockchain.binaryproto.contract.HashAlgorithm; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/30. | |||
| */ | |||
| /* | |||
| public class CryptoSettingImpl implements CryptoSetting { | |||
| private HashAlgorithm hashAlgorithm; | |||
| private CryptoAlgorithm cryptoAlgorithm; | |||
| private boolean isAuto; | |||
| @Override | |||
| public HashAlgorithm getHashAlgorithm() { | |||
| return this.hashAlgorithm; | |||
| } | |||
| public void setHashAlgorithm(HashAlgorithm hashAlgorithm) { | |||
| this.hashAlgorithm = hashAlgorithm; | |||
| } | |||
| @Override | |||
| public CryptoAlgorithm getHashAlgorithm1() { | |||
| return this.cryptoAlgorithm; | |||
| } | |||
| public void setHashAlgorithm1(CryptoAlgorithm cryptoAlgorithm) { | |||
| this.cryptoAlgorithm = cryptoAlgorithm; | |||
| } | |||
| @Override | |||
| public boolean getAutoVerifyHash() { | |||
| return isAuto; | |||
| } | |||
| public void setAutoVerifyHash(boolean isAuto) { | |||
| this.isAuto = isAuto; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,147 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import com.jd.blockchain.binaryproto.DConstructor; | |||
| //import com.jd.blockchain.binaryproto.DataField; | |||
| //import com.jd.blockchain.binaryproto.FieldSetter; | |||
| //import com.jd.blockchain.crypto.hash.HashDigest; | |||
| //import test.com.jd.blockchain.binaryproto.contract.Address; | |||
| //import test.com.jd.blockchain.binaryproto.contract.LedgerBlock; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/30. | |||
| */ | |||
| /* | |||
| public class LedgerBlockImpl implements LedgerBlock { | |||
| private HashDigest hash; | |||
| private long height; | |||
| private HashDigest ledgerHash; | |||
| private HashDigest previousHash; | |||
| private HashDigest adminAccountHash; | |||
| private HashDigest userAccountSetHash; | |||
| private HashDigest userPrivilegeHash; | |||
| private HashDigest dataAccountSetHash; | |||
| private HashDigest dataPrivilegeHash; | |||
| private HashDigest contractAccountSetHash; | |||
| private HashDigest contractPrivilegeHash; | |||
| private HashDigest transactionSetHash; | |||
| public void setAdminAccountHash(HashDigest adminAccountHash) { | |||
| this.adminAccountHash = adminAccountHash; | |||
| } | |||
| public void setUserAccountSetHash(HashDigest userAccountSetHash) { | |||
| this.userAccountSetHash = userAccountSetHash; | |||
| } | |||
| public void setUserPrivilegeHash(HashDigest userPrivilegeHash) { | |||
| this.userPrivilegeHash = userPrivilegeHash; | |||
| } | |||
| public void setDataAccountSetHash(HashDigest dataAccountSetHash) { | |||
| this.dataAccountSetHash = dataAccountSetHash; | |||
| } | |||
| public void setDataPrivilegeHash(HashDigest dataPrivilegeHash) { | |||
| this.dataPrivilegeHash = dataPrivilegeHash; | |||
| } | |||
| public void setContractAccountSetHash(HashDigest contractAccountSetHash) { | |||
| this.contractAccountSetHash = contractAccountSetHash; | |||
| } | |||
| public void setContractPrivilegeHash(HashDigest contractPrivilegeHash) { | |||
| this.contractPrivilegeHash = contractPrivilegeHash; | |||
| } | |||
| public void setTransactionSetHash(HashDigest transactionSetHash) { | |||
| this.transactionSetHash = transactionSetHash; | |||
| } | |||
| public LedgerBlockImpl() { | |||
| } | |||
| @DConstructor(name="LedgerBlockImpl") | |||
| public LedgerBlockImpl(@FieldSetter(name="getHeight", type="long") long height, @FieldSetter(name="getLedgerHash", type="HashDigest") HashDigest ledgerHash, @FieldSetter(name="getPreviousHash", type="HashDigest") HashDigest previousHash) { | |||
| this.height = height; | |||
| this.ledgerHash = ledgerHash; | |||
| this.previousHash = previousHash; | |||
| } | |||
| @Override | |||
| public HashDigest getHash() { | |||
| return hash; | |||
| } | |||
| @Override | |||
| public HashDigest getPreviousHash() { | |||
| return previousHash; | |||
| } | |||
| @Override | |||
| public HashDigest getLedgerHash() { | |||
| return ledgerHash; | |||
| } | |||
| @Override | |||
| public long getHeight() { | |||
| return height; | |||
| } | |||
| @Override | |||
| public HashDigest getAdminAccountHash() { | |||
| return adminAccountHash; | |||
| } | |||
| @Override | |||
| public HashDigest getUserAccountSetHash() { | |||
| return userAccountSetHash; | |||
| } | |||
| @Override | |||
| public HashDigest getUserPrivilegeHash() { | |||
| return userPrivilegeHash; | |||
| } | |||
| @Override | |||
| public HashDigest getDataAccountSetHash() { | |||
| return dataAccountSetHash; | |||
| } | |||
| @Override | |||
| public HashDigest getDataPrivilegeHash() { | |||
| return dataPrivilegeHash; | |||
| } | |||
| @Override | |||
| public HashDigest getContractAccountSetHash() { | |||
| return contractAccountSetHash; | |||
| } | |||
| @Override | |||
| public HashDigest getContractPrivilegeHash() { | |||
| return contractPrivilegeHash; | |||
| } | |||
| @Override | |||
| public HashDigest getTransactionSetHash() { | |||
| return transactionSetHash; | |||
| } | |||
| public void setHash(HashDigest blockHash) { | |||
| this.hash = blockHash; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,56 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import test.com.jd.blockchain.binaryproto.contract.*; | |||
| //import test.com.jd.blockchain.binaryproto.contract.LedgerMetadata; | |||
| //import test.com.jd.blockchain.binaryproto.contract.LedgerSetting; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/30. | |||
| */ | |||
| /* | |||
| public class LedgerMetadataImpl implements LedgerMetadata { | |||
| private byte[] seed; | |||
| private LedgerSetting setting; | |||
| private byte[] privilegesHash; | |||
| private byte[] participantsHash; | |||
| @Override | |||
| public byte[] getSeed() { | |||
| return seed; | |||
| } | |||
| @Override | |||
| public LedgerSetting getSetting() { | |||
| return setting; | |||
| } | |||
| @Override | |||
| public byte[] getPrivilegesHash() { | |||
| return privilegesHash; | |||
| } | |||
| @Override | |||
| public byte[] getParticipantsHash() { | |||
| return participantsHash; | |||
| } | |||
| public void setSeed(byte[] seed) { | |||
| this.seed = seed; | |||
| } | |||
| public void setSetting(LedgerSetting setting) { | |||
| this.setting = setting; | |||
| } | |||
| public void setPrivilegesHash(byte[] privilegesHash) { | |||
| this.privilegesHash = privilegesHash; | |||
| } | |||
| public void setParticipantsHash(byte[] participantsHash) { | |||
| this.participantsHash = participantsHash; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,30 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import test.com.jd.blockchain.binaryproto.contract.LedgerSetting; | |||
| //import test.com.jd.blockchain.binaryproto.contract.CryptoSetting; | |||
| //import test.com.jd.blockchain.binaryproto.contract.PrivilegeModelSetting; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/30. | |||
| */ | |||
| /* | |||
| public class LedgerSettingImpl implements LedgerSetting { | |||
| private CryptoSetting cryptoSetting; | |||
| private PrivilegeModelSetting privilegeModelSetting; | |||
| @Override | |||
| public CryptoSetting getCryptoSetting() { | |||
| return this.cryptoSetting; | |||
| } | |||
| public void setCryptoSetting(CryptoSetting cryptoSetting) { | |||
| this.cryptoSetting = cryptoSetting; | |||
| } | |||
| @Override | |||
| public PrivilegeModelSetting getPrivilegesModelSetting() { | |||
| return this.privilegeModelSetting; | |||
| } | |||
| public void setPrivilegesModelSetting(PrivilegeModelSetting privilegeModelSetting) { | |||
| this.privilegeModelSetting = privilegeModelSetting; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,32 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import test.com.jd.blockchain.binaryproto.contract.Address; | |||
| //import test.com.jd.blockchain.binaryproto.contract.RefContract; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/11. | |||
| */ | |||
| /* | |||
| public class RefContractImpl implements RefContract { | |||
| private Address address; | |||
| private Address address1; | |||
| @Override | |||
| public Address getAddress() { | |||
| // TODO Auto-generated method stub | |||
| return this.address; | |||
| } | |||
| public void setAddress(Address address) { | |||
| this.address = address; | |||
| } | |||
| @Override | |||
| public Address getAddress1() { | |||
| // TODO Auto-generated method stub | |||
| return this.address1; | |||
| } | |||
| public void setAddress1(Address address) { | |||
| this.address1 = address; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,108 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import test.com.jd.blockchain.binaryproto.contract.Address; | |||
| //import test.com.jd.blockchain.binaryproto.contract.Level; | |||
| //import test.com.jd.blockchain.binaryproto.contract.Student; | |||
| //import test.com.jd.blockchain.binaryproto.contract.StudentInvert; | |||
| /* | |||
| public class StudentImpl implements Student,StudentInvert { | |||
| private int id; | |||
| private short age; | |||
| private String name; | |||
| private Level level; | |||
| private Address address; | |||
| private int[] scores; | |||
| private String[] features; | |||
| private byte familyMemberNum; | |||
| private byte[] familyMemberAges; | |||
| private long[] familyMemberIds; | |||
| @Override | |||
| public int getId() { | |||
| return id; | |||
| } | |||
| public void setId(int id) { | |||
| this.id = id; | |||
| } | |||
| @Override | |||
| public String getName() { | |||
| // TODO Auto-generated method stub | |||
| return this.name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| @Override | |||
| public Level getLevel() { | |||
| // TODO Auto-generated method stub | |||
| return this.level; | |||
| } | |||
| public void setLevel(Level level) { | |||
| this.level = level; | |||
| } | |||
| @Override | |||
| public Address getAddress() { | |||
| // TODO Auto-generated method stub | |||
| return this.address; | |||
| } | |||
| public void setAddress(Address address) { | |||
| this.address = address; | |||
| } | |||
| public short getAge() { | |||
| return age; | |||
| } | |||
| public void setAge(short age) { | |||
| this.age = age; | |||
| } | |||
| @Override | |||
| public int[] getScores() { | |||
| // TODO Auto-generated method stub | |||
| return this.scores; | |||
| } | |||
| public void setScores(int[] scores) { | |||
| this.scores = scores; | |||
| } | |||
| @Override | |||
| public String[] getFeatures() { | |||
| return this.features; | |||
| } | |||
| public void setFeatures(String[] features) { | |||
| this.features = features; | |||
| } | |||
| @Override | |||
| public byte getFamilyMemberNum() { | |||
| return this.familyMemberNum; | |||
| } | |||
| public void setFamilyMemberNum(byte familyMemberNum) { | |||
| this.familyMemberNum = familyMemberNum; | |||
| } | |||
| @Override | |||
| public byte[] getFamilyMemberAges() { | |||
| return this.familyMemberAges; | |||
| } | |||
| public void setFamilyMemberAges(byte[] familyMemberAge) { | |||
| this.familyMemberAges = familyMemberAge; | |||
| } | |||
| @Override | |||
| public long[] getFamilyMemberIds() { | |||
| return this.familyMemberIds; | |||
| } | |||
| public void setFamilyMemberIds(long[] familyMemberId) { | |||
| this.familyMemberIds = familyMemberId; | |||
| } | |||
| } | |||
| */ | |||
| @@ -1,51 +0,0 @@ | |||
| //package test.com.jd.blockchain.binaryproto.contract.impl; | |||
| //import com.jd.blockchain.binaryproto.DConstructor; | |||
| //import com.jd.blockchain.binaryproto.FieldSetter; | |||
| //import com.jd.blockchain.crypto.asymmetric.PubKey; | |||
| //import my.utils.io.ByteArray; | |||
| //import test.com.jd.blockchain.binaryproto.contract.User; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/7/24. | |||
| */ | |||
| /* | |||
| public class UserImpl implements User { | |||
| String address; | |||
| PubKey pubKey; | |||
| PubKey dataPubKey; | |||
| ByteArray dataHash; | |||
| ByteArray privHash; | |||
| @DConstructor(name = "UserImpl") | |||
| public UserImpl(@FieldSetter(name = "getAddress", type = "String") String address, @FieldSetter(name = "getPubKey",type = "PubKey") PubKey pubKey, @FieldSetter(name = "getDataPubKey",type = "PubKey") PubKey dataPubKey, | |||
| @FieldSetter(name = "getDataHash", type = "byte[]") byte[] dataHash, @FieldSetter(name = "getPrivilegeHash", type = "byte[]") byte[] privHash) { | |||
| this.address = address; | |||
| this.pubKey = pubKey; | |||
| this.dataPubKey = dataPubKey; | |||
| this.dataHash = ByteArray.wrap(dataHash); | |||
| this.privHash = ByteArray.wrap(privHash); | |||
| } | |||
| @Override | |||
| public String getAddress() { | |||
| return address; | |||
| } | |||
| @Override | |||
| public PubKey getPubKey() { | |||
| return pubKey; | |||
| } | |||
| @Override | |||
| public PubKey getDataPubKey() { | |||
| return dataPubKey; | |||
| } | |||
| @Override | |||
| public ByteArray getDataHash() { | |||
| return dataHash; | |||
| } | |||
| @Override | |||
| public ByteArray getPrivilegeHash() { | |||
| return privHash; | |||
| } | |||
| } | |||
| */ | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.consensus.bftsmart; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consensus.ClientIncomingSettings; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| @@ -10,13 +10,13 @@ import com.jd.blockchain.crypto.PubKey; | |||
| @DataContract(code = DataCodes.CONSENSUS_BFTSMART_CLI_INCOMING_SETTINGS) | |||
| public interface BftsmartClientIncomingSettings extends ClientIncomingSettings { | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| byte[] getTopology(); | |||
| @DataField(order = 2, primitiveType = DataType.BYTES) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BYTES) | |||
| byte[] getTomConfig(); | |||
| @DataField(order = 3, primitiveType=DataType.BYTES) | |||
| @DataField(order = 3, primitiveType=PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| } | |||
| @@ -2,16 +2,16 @@ package com.jd.blockchain.consensus.bftsmart; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code = DataCodes.CONSENSUS_BFTSMART_BLOCK_SETTINGS) | |||
| public interface BftsmartCommitBlockSettings { | |||
| @DataField(order = 0, primitiveType = DataType.INT32) | |||
| @DataField(order = 0, primitiveType = PrimitiveType.INT32) | |||
| int getTxSizePerBlock(); | |||
| @DataField(order = 1, primitiveType = DataType.INT64) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.INT64) | |||
| long getMaxDelayMilliSecondsPerBlock(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.consensus.bftsmart; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consensus.ConsensusSettings; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.utils.Property; | |||
| @@ -11,7 +11,7 @@ import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils; | |||
| @DataContract(code = DataCodes.CONSENSUS_BFTSMART_SETTINGS) | |||
| public interface BftsmartConsensusSettings extends ConsensusSettings { | |||
| @DataField(order = 1, primitiveType = DataType.BYTES, list=true) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES, list=true) | |||
| Property[] getSystemConfigs(); | |||
| @DataField(order = 2, refContract = true) | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.consensus.bftsmart; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consensus.NodeSettings; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| @@ -31,7 +31,7 @@ public interface BftsmartNodeSettings extends NodeSettings { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 2, primitiveType = DataType.INT32) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.INT32) | |||
| int getId(); | |||
| /** | |||
| @@ -39,7 +39,7 @@ public interface BftsmartNodeSettings extends NodeSettings { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 3, primitiveType = DataType.BYTES) | |||
| @DataField(order = 3, primitiveType = PrimitiveType.BYTES) | |||
| NetworkAddress getNetworkAddress(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.consensus; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| import com.jd.blockchain.crypto.SignatureDigest; | |||
| @@ -21,7 +21,7 @@ public interface ClientIdentification { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 0, primitiveType = DataType.BYTES) | |||
| @DataField(order = 0, primitiveType = PrimitiveType.BYTES) | |||
| byte[] getIdentityInfo(); | |||
| /** | |||
| @@ -29,7 +29,7 @@ public interface ClientIdentification { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| /** | |||
| @@ -37,7 +37,7 @@ public interface ClientIdentification { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 2, primitiveType = DataType.BYTES) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BYTES) | |||
| SignatureDigest getSignature(); | |||
| /** | |||
| @@ -45,6 +45,6 @@ public interface ClientIdentification { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 3, primitiveType = DataType.TEXT) | |||
| @DataField(order = 3, primitiveType = PrimitiveType.TEXT) | |||
| String getProviderName(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.consensus; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| /** | |||
| @@ -19,7 +19,7 @@ public interface ClientIncomingSettings { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 0, primitiveType = DataType.INT32) | |||
| @DataField(order = 0, primitiveType = PrimitiveType.INT32) | |||
| int getClientId(); | |||
| /** | |||
| @@ -27,7 +27,7 @@ public interface ClientIncomingSettings { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.TEXT) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.TEXT) | |||
| String getProviderName(); | |||
| /** | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.consensus; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| @@ -22,7 +22,7 @@ public interface NodeSettings { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=0, primitiveType=DataType.TEXT) | |||
| @DataField(order=0, primitiveType=PrimitiveType.TEXT) | |||
| String getAddress(); | |||
| /** | |||
| @@ -30,6 +30,6 @@ public interface NodeSettings { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| } | |||
| @@ -2,27 +2,27 @@ package com.jd.blockchain.consensus.action; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code= DataCodes.CONSENSUS_ACTION_REQUEST) | |||
| public interface ActionRequest { | |||
| @DataField(order=1, list=true, primitiveType= DataType.INT8) | |||
| @DataField(order=1, list=true, primitiveType= PrimitiveType.INT8) | |||
| byte[] getGroupId(); | |||
| @DataField(order=2, primitiveType=DataType.TEXT) | |||
| @DataField(order=2, primitiveType=PrimitiveType.TEXT) | |||
| String getHandleType(); | |||
| @DataField(order=3, primitiveType=DataType.TEXT) | |||
| @DataField(order=3, primitiveType=PrimitiveType.TEXT) | |||
| String getHandleMethod(); | |||
| // String getMessageType(); | |||
| @DataField(order=4, list=true, primitiveType= DataType.INT8) | |||
| @DataField(order=4, list=true, primitiveType= PrimitiveType.INT8) | |||
| byte[] getMessageBody(); | |||
| @DataField(order=5, primitiveType= DataType.TEXT) | |||
| @DataField(order=5, primitiveType= PrimitiveType.TEXT) | |||
| String getTransactionType(); | |||
| // String getReponseType(); | |||
| @@ -2,22 +2,22 @@ package com.jd.blockchain.consensus.action; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code= DataCodes.CONSENSUS_ACTION_RESPONSE) | |||
| public interface ActionResponse { | |||
| @DataField(order=1, list=true, primitiveType= DataType.INT8) | |||
| @DataField(order=1, list=true, primitiveType= PrimitiveType.INT8) | |||
| byte[] getMessage(); | |||
| @DataField(order=2, primitiveType=DataType.BOOLEAN) | |||
| @DataField(order=2, primitiveType=PrimitiveType.BOOLEAN) | |||
| boolean getError(); | |||
| @DataField(order=3, primitiveType=DataType.TEXT) | |||
| @DataField(order=3, primitiveType=PrimitiveType.TEXT) | |||
| String getErrorMessage(); | |||
| @DataField(order=4, primitiveType=DataType.TEXT) | |||
| @DataField(order=4, primitiveType=PrimitiveType.TEXT) | |||
| String getErrorType(); | |||
| } | |||
| @@ -10,7 +10,7 @@ package com.jd.blockchain.consensus.mq.settings; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| /** | |||
| @@ -22,9 +22,9 @@ import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_BLOCK_SETTINGS) | |||
| public interface MsgQueueBlockSettings { | |||
| @DataField(order = 0, primitiveType = DataType.INT32) | |||
| @DataField(order = 0, primitiveType = PrimitiveType.INT32) | |||
| int getTxSizePerBlock(); | |||
| @DataField(order = 1, primitiveType = DataType.INT64) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.INT64) | |||
| long getMaxDelayMilliSecondsPerBlock(); | |||
| } | |||
| @@ -10,7 +10,7 @@ package com.jd.blockchain.consensus.mq.settings; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consensus.ClientIncomingSettings; | |||
| import com.jd.blockchain.consensus.ConsensusSettings; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @@ -25,6 +25,6 @@ import com.jd.blockchain.crypto.PubKey; | |||
| @DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_CLI_INCOMING_SETTINGS) | |||
| public interface MsgQueueClientIncomingSettings extends ClientIncomingSettings { | |||
| @DataField(order = 1, primitiveType=DataType.BYTES) | |||
| @DataField(order = 1, primitiveType=PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| } | |||
| @@ -10,7 +10,7 @@ package com.jd.blockchain.consensus.mq.settings; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consensus.ConsensusSettings; | |||
| import com.jd.blockchain.consensus.mq.config.MsgQueueBlockConfig; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @@ -10,7 +10,7 @@ package com.jd.blockchain.consensus.mq.settings; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| /** | |||
| @@ -22,15 +22,15 @@ import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_NETWORK_SETTINGS) | |||
| public interface MsgQueueNetworkSettings { | |||
| @DataField(order = 0, primitiveType = DataType.TEXT) | |||
| @DataField(order = 0, primitiveType = PrimitiveType.TEXT) | |||
| String getServer(); | |||
| @DataField(order = 1, primitiveType = DataType.TEXT) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.TEXT) | |||
| String getTxTopic(); | |||
| @DataField(order = 2, primitiveType = DataType.TEXT) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.TEXT) | |||
| String getBlTopic(); | |||
| @DataField(order = 3, primitiveType = DataType.TEXT) | |||
| @DataField(order = 3, primitiveType = PrimitiveType.TEXT) | |||
| String getMsgTopic(); | |||
| } | |||
| @@ -5,7 +5,7 @@ import java.io.OutputStream; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.utils.io.BytesUtils; | |||
| @@ -63,7 +63,7 @@ public interface CryptoAlgorithm { | |||
| * {@link #EXT_ALGORITHM}) 5 种); 接下来4位标识密钥类型(包括:{@link #SYMMETRIC_KEY}, | |||
| * {@link #ASYMMETRIC_KEY}); 最后8位是算法唯一ID; | |||
| */ | |||
| @DataField(primitiveType = DataType.INT16, order = 0) | |||
| @DataField(primitiveType = PrimitiveType.INT16, order = 0) | |||
| short code(); | |||
| /** | |||
| @@ -1,7 +1,7 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| @@ -142,7 +142,7 @@ public class DataAccount implements AccountHeader, MerkleProvable { | |||
| key = baseAccount.dataset.getKeyAtIndex(fromIndex); | |||
| ver = baseAccount.dataset.getVersion(key); | |||
| BytesValue decodeData = BinaryEncodingUtils.decode(value); | |||
| kvDataEntries[i] = new KVDataObject(key, ver, DataType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||
| kvDataEntries[i] = new KVDataObject(key, ver, PrimitiveType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||
| fromIndex++; | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.crypto.SignatureDigest; | |||
| @@ -21,14 +21,14 @@ public interface LedgerInitDecision { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=1, primitiveType=DataType.INT32) | |||
| @DataField(order=1, primitiveType=PrimitiveType.INT32) | |||
| int getParticipantId(); | |||
| /** | |||
| * 新建账本的哈希; | |||
| * @return | |||
| */ | |||
| @DataField(order=2, primitiveType = DataType.BYTES) | |||
| @DataField(order=2, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getLedgerHash(); | |||
| /** | |||
| @@ -40,7 +40,7 @@ public interface LedgerInitDecision { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=3, primitiveType = DataType.BYTES) | |||
| @DataField(order=3, primitiveType = PrimitiveType.BYTES) | |||
| SignatureDigest getSignature(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.SignatureDigest; | |||
| import com.jd.blockchain.ledger.LedgerInitOperation; | |||
| @@ -21,7 +21,7 @@ public interface LedgerInitPermission { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.INT32) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.INT32) | |||
| int getParticipantId(); | |||
| /** | |||
| @@ -39,7 +39,7 @@ public interface LedgerInitPermission { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 2, primitiveType = DataType.BYTES) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BYTES) | |||
| SignatureDigest getTransactionSignature(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @@ -14,7 +14,7 @@ public interface LedgerMetadata { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| byte[] getSeed(); | |||
| /** | |||
| @@ -22,7 +22,7 @@ public interface LedgerMetadata { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 2, primitiveType = DataType.BYTES) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getParticipantsHash(); | |||
| /** | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.ledger.CryptoSetting; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @@ -10,10 +10,10 @@ import com.jd.blockchain.utils.Bytes; | |||
| @DataContract(code = DataCodes.METADATA_LEDGER_SETTING) | |||
| public interface LedgerSetting { | |||
| @DataField(order=0, primitiveType=DataType.TEXT) | |||
| @DataField(order=0, primitiveType=PrimitiveType.TEXT) | |||
| String getConsensusProvider(); | |||
| @DataField(order=1, primitiveType=DataType.BYTES) | |||
| @DataField(order=1, primitiveType=PrimitiveType.BYTES) | |||
| Bytes getConsensusSetting(); | |||
| @DataField(order=2, refContract=true) | |||
| @@ -1,7 +1,7 @@ | |||
| package com.jd.blockchain.ledger.core.impl; | |||
| import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.BytesValue; | |||
| @@ -271,11 +271,11 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| for (int i = 0; i < entries.length; i++) { | |||
| ver = dataAccount.getDataVersion(Bytes.fromString(keys[i])); | |||
| if (ver < 0) { | |||
| entries[i] = new KVDataObject(keys[i], -1, DataType.NIL, null); | |||
| entries[i] = new KVDataObject(keys[i], -1, PrimitiveType.NIL, null); | |||
| }else { | |||
| byte[] value = dataAccount.getBytes(Bytes.fromString(keys[i]), ver); | |||
| BytesValue decodeData = BinaryEncodingUtils.decode(value); | |||
| entries[i] = new KVDataObject(keys[i], ver, DataType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||
| entries[i] = new KVDataObject(keys[i], ver, PrimitiveType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||
| } | |||
| } | |||
| @@ -9,7 +9,7 @@ import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.BlockchainIdentity; | |||
| import com.jd.blockchain.ledger.BytesValue; | |||
| import com.jd.blockchain.ledger.BytesValueImpl; | |||
| import com.jd.blockchain.ledger.BytesValueEntry; | |||
| import com.jd.blockchain.ledger.DataAccountKVSetOperation; | |||
| import com.jd.blockchain.ledger.DataAccountRegisterOperation; | |||
| import com.jd.blockchain.ledger.BytesValueType; | |||
| @@ -273,7 +273,7 @@ public class ContractLedgerContext implements LedgerContext { | |||
| @Override | |||
| public DataAccountKVSetOperationBuilder set(String key, byte[] value, long expVersion) { | |||
| BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value); | |||
| BytesValue bytesValue = new BytesValueEntry(BytesValueType.BYTES, value); | |||
| this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | |||
| generatedOpList.add(op); | |||
| opHandleContext.handle(op); | |||
| @@ -283,10 +283,10 @@ public class ContractLedgerContext implements LedgerContext { | |||
| public DataAccountKVSetOperationBuilder set(String key, String value, long expVersion) { | |||
| BytesValue bytesValue; | |||
| if (isJson(value)) { | |||
| bytesValue = new BytesValueImpl(BytesValueType.JSON, value.getBytes()); | |||
| bytesValue = new BytesValueEntry(BytesValueType.JSON, value.getBytes()); | |||
| } | |||
| else { | |||
| bytesValue = new BytesValueImpl(BytesValueType.TEXT, value.getBytes()); | |||
| bytesValue = new BytesValueEntry(BytesValueType.TEXT, value.getBytes()); | |||
| } | |||
| this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | |||
| generatedOpList.add(op); | |||
| @@ -295,7 +295,7 @@ public class ContractLedgerContext implements LedgerContext { | |||
| } | |||
| @Override | |||
| public DataAccountKVSetOperationBuilder set(String key, Bytes value, long expVersion) { | |||
| BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value.toBytes()); | |||
| BytesValue bytesValue = new BytesValueEntry(BytesValueType.BYTES, value.toBytes()); | |||
| this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | |||
| generatedOpList.add(op); | |||
| opHandleContext.handle(op); | |||
| @@ -303,7 +303,7 @@ public class ContractLedgerContext implements LedgerContext { | |||
| } | |||
| @Override | |||
| public DataAccountKVSetOperationBuilder set(String key, long value, long expVersion) { | |||
| BytesValue bytesValue = new BytesValueImpl(BytesValueType.INT64, BytesUtils.toBytes(value)); | |||
| BytesValue bytesValue = new BytesValueEntry(BytesValueType.INT64, BytesUtils.toBytes(value)); | |||
| this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | |||
| generatedOpList.add(op); | |||
| opHandleContext.handle(op); | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| @@ -11,13 +11,13 @@ import com.jd.blockchain.utils.Bytes; | |||
| @DataContract(code= DataCodes.ACCOUNT_HEADER) | |||
| public interface AccountHeader { | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| Bytes getAddress(); | |||
| @DataField(order=2, primitiveType = DataType.BYTES) | |||
| @DataField(order=2, primitiveType = PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| @DataField(order=3, primitiveType = DataType.BYTES) | |||
| @DataField(order=3, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getRootHash(); | |||
| } | |||
| @@ -1,406 +0,0 @@ | |||
| //package com.jd.blockchain.ledger; | |||
| // | |||
| //import java.io.ByteArrayOutputStream; | |||
| //import java.io.IOException; | |||
| //import java.io.InputStream; | |||
| //import java.io.OutputStream; | |||
| // | |||
| //import com.jd.blockchain.ledger.data.HashEncoding; | |||
| // | |||
| //import my.utils.io.ByteArray; | |||
| //import my.utils.io.BytesEncoding; | |||
| //import my.utils.io.BytesReader; | |||
| //import my.utils.io.BytesUtils; | |||
| //import my.utils.io.BytesWriter; | |||
| //import my.utils.io.NumberMask; | |||
| // | |||
| //public class AccountImpl implements BlockchainAccount, BytesWriter, BytesReader { | |||
| // public static final long INIT_TX_SEQUENCE_NUMBER = 0; // 初始交易流水号 | |||
| // public static final long INIT_MODEL_VERSION = 0; // 初始模型版本号 | |||
| // public static final long INIT_VERSION = 0; // 初始版本号 | |||
| // public static final long INIT_PRIVILLEGE_VERSION = 0; // 初始权限版本号 | |||
| // public static final long INIT_STATE_VERSION = 0; // 初始状态版本号 | |||
| // public static final long INIT_CODE_VERSION = 0; // 初始合约版本号 | |||
| // | |||
| // private BlockchainIdentity identity; | |||
| // private ByteArray ledgerHash; // 账本hash | |||
| // private long blockHeight; // 账户注册的区块高度 | |||
| // private long txSequenceNumber; // 交易流水号 | |||
| // private long modelVersion; // 账户模型版本 | |||
| // private long version; // 账户版本 | |||
| // private ByteArray privilegeHash; // 权限树根hash | |||
| // private long privilegeVersion; // 权限版本 | |||
| // private AccountStateType stateType; // 状态类型 | |||
| // private ByteArray stateHash; // 状态数根hash | |||
| // private long stateVersion; // 状态版本 | |||
| // private ByteArray code; // 合约代码 | |||
| // private long codeVersion; // 合约版本 | |||
| // private HashAlgorithm codeHashAlgorithm = HashAlgorithm.SHA256; | |||
| // private ByteArray codeHash; | |||
| // | |||
| // public AccountImpl() { | |||
| // } | |||
| // | |||
| // public AccountImpl(BlockchainIdentity identity, ByteArray ledgerHash, long blockHeight, long txSequenceNumber, | |||
| // long modelVersion, long version, ByteArray privilegeHash, long privilegeVersion, AccountStateType stateType, | |||
| // ByteArray stateHash, long stateVersion, ByteArray code, long codeVersion) { | |||
| // this.identity = identity; | |||
| // this.ledgerHash = ledgerHash; | |||
| // this.blockHeight = blockHeight; | |||
| // this.txSequenceNumber = txSequenceNumber; | |||
| // this.modelVersion = modelVersion; | |||
| // this.version = version; | |||
| // this.privilegeHash = privilegeHash; | |||
| // this.privilegeVersion = privilegeVersion; | |||
| // this.stateType = stateType; | |||
| // this.stateHash = stateHash; | |||
| // this.stateVersion = stateVersion; | |||
| // this.code = code; | |||
| // this.codeVersion = codeVersion; | |||
| // } | |||
| // | |||
| // public AccountImpl(BlockchainIdentity identity, ByteArray ledgerHash, long blockHeight, ByteArray privilegeHash, | |||
| // AccountStateType stateType, ByteArray stateHash, ByteArray code) { | |||
| // this.identity = identity; | |||
| // this.ledgerHash = ledgerHash; | |||
| // this.blockHeight = blockHeight; | |||
| // this.txSequenceNumber = INIT_TX_SEQUENCE_NUMBER; | |||
| // this.modelVersion = INIT_MODEL_VERSION; | |||
| // this.version = INIT_VERSION; | |||
| // this.privilegeHash = privilegeHash; | |||
| // this.privilegeVersion = INIT_PRIVILLEGE_VERSION; | |||
| // this.stateType = stateType; | |||
| // this.stateHash = stateHash; | |||
| // this.stateVersion = INIT_STATE_VERSION; | |||
| // this.code = code; | |||
| // this.codeVersion = INIT_CODE_VERSION; | |||
| // } | |||
| // | |||
| // @Override | |||
| // public void resolvFrom(InputStream in) throws IOException { | |||
| // BlockchainIdentity identity = new BlockchainIdentity(); | |||
| // identity.resolvFrom(in); | |||
| // ByteArray ledgerHash = HashEncoding.read(in); | |||
| // long blockHeight = BytesUtils.readLong(in); | |||
| // long txSeqNum = BytesUtils.readLong(in); | |||
| // long modelVersion = BytesUtils.readLong(in); | |||
| // long version = BytesUtils.readLong(in); | |||
| // ByteArray privilegeHash = HashEncoding.read(in); | |||
| // long privilegeVersion = BytesUtils.readLong(in); | |||
| // AccountStateType stateType = AccountStateType.valueOf(BytesUtils.readByte(in)); | |||
| // ByteArray stateHash = HashEncoding.read(in); | |||
| // long stateVersion = BytesUtils.readLong(in); | |||
| // | |||
| // ByteArray code = BytesEncoding.readAsByteArray(NumberMask.NORMAL, in); | |||
| // long codeVersion = BytesUtils.readLong(in); | |||
| // HashAlgorithm codeHashAlgorithm = HashAlgorithm.valueOf(BytesUtils.readByte(in)); | |||
| // ByteArray codeHash = HashEncoding.read(in); | |||
| // | |||
| // this.identity = identity; | |||
| // this.ledgerHash = ledgerHash; | |||
| // this.blockHeight = blockHeight; | |||
| // this.txSequenceNumber = txSeqNum; | |||
| // this.modelVersion = modelVersion; | |||
| // this.version = version; | |||
| // this.privilegeHash = privilegeHash; | |||
| // this.privilegeVersion = privilegeVersion; | |||
| // this.stateType = stateType; | |||
| // this.stateHash = stateHash; | |||
| // this.stateVersion = stateVersion; | |||
| // this.code = code; | |||
| // this.codeVersion = codeVersion; | |||
| // this.codeHashAlgorithm = codeHashAlgorithm; | |||
| // this.codeHash = codeHash; | |||
| // } | |||
| // | |||
| // @Override | |||
| // public void writeTo(OutputStream out) throws IOException { | |||
| // identity.writeTo(out); | |||
| // HashEncoding.write(ledgerHash, out); | |||
| // BytesUtils.writeLong(blockHeight, out); | |||
| // BytesUtils.writeLong(txSequenceNumber, out); | |||
| // BytesUtils.writeLong(modelVersion, out); | |||
| // BytesUtils.writeLong(version, out); | |||
| // HashEncoding.write(privilegeHash, out); | |||
| // BytesUtils.writeLong(privilegeVersion, out); | |||
| // BytesUtils.writeByte(stateType.getCODE(), out); | |||
| // HashEncoding.write(stateHash, out); | |||
| // BytesUtils.writeLong(stateVersion, out); | |||
| // | |||
| // BytesEncoding.write(code, NumberMask.NORMAL, out); | |||
| // BytesUtils.writeLong(codeVersion, out); | |||
| // BytesUtils.writeByte(codeHashAlgorithm.getAlgorithm(), out); | |||
| // HashEncoding.write(getCodeHash(), out); | |||
| // } | |||
| // | |||
| // /** | |||
| // * 地址; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public BlockchainIdentity getAddress() { | |||
| // return identity; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 账户所属的账本的 hash;<br> | |||
| // * <p> | |||
| // * 注:账本的hash 等同于该账本的创世区块的 hash; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public ByteArray getLedgerHash() { | |||
| // return ledgerHash; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 注册账户的区块高度; <br> | |||
| // * <p> | |||
| // * 注册此账户的区块高度; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getRegisteredHeight() { | |||
| // return blockHeight; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 交易流水号;<br> | |||
| // * <p> | |||
| // * 账户的交易流水号初始为 0,当账户作为交易的科目账户(SubjectAccount )发起一个交易并被成功执行之后,账户的交易流水号增加1; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getTxSquenceNumber() { | |||
| // return txSequenceNumber; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 账户模型版本; <br> | |||
| // * <p> | |||
| // * 表示构成一个账户结构的属性模型的程序版本号; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getModelVersion() { | |||
| // return modelVersion; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 账户版本; <br> | |||
| // * <p> | |||
| // * 初始为 0,对账户的每一次变更(包括对权限设置、状态和合约代码的变更)都会使账户状态版本增加 1 ;注:交易序号的改变不会导致账户版本的增加; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getVersion() { | |||
| // return version; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 权限 hash;<br> | |||
| // * <p> | |||
| // * 权限树的根hash; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public ByteArray getPrivilegeHash() { | |||
| // return privilegeHash; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 权限版本; <br> | |||
| // * <p> | |||
| // * 初始为 0, 每次对权限的变更都导致版本号加 1; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getPrivilegeVersion() { | |||
| // return privilegeVersion; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 状态类型; <br> | |||
| // * <p> | |||
| // * 账户的状态类型有3种:空类型(NIL);键值类型;对象类型;参考 {@link AccountStateType} | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public AccountStateType getStateType() { | |||
| // return stateType; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 状态版本;<br> | |||
| // * <p> | |||
| // * 初始为 0,每次对状态的更改都使得状态版本增加1; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getStateVersion() { | |||
| // return stateVersion; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 状态哈希;<br> | |||
| // * <p> | |||
| // * 数据状态的 merkle tree 的根hash; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public ByteArray getStateHash() { | |||
| // return stateHash; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 合约代码哈希; <br> | |||
| // * <p> | |||
| // * 由“账户地址+合约代码版本号+合约代码内容”生成的哈希; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public ByteArray getCodeHash() { | |||
| // if (codeHash == null || codeHash == ByteArray.EMPTY) { | |||
| // ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
| // BytesEncoding.write(getAddress().getAddress().getBytes(), NumberMask.SHORT, out); | |||
| // BytesUtils.writeLong(codeVersion, out); | |||
| // BytesEncoding.write(code, NumberMask.NORMAL, out); | |||
| // | |||
| // codeHash = HashEncoding.computeHash(out.toByteArray(), codeHashAlgorithm); | |||
| // } | |||
| // | |||
| // return codeHash; | |||
| // } | |||
| // | |||
| // public ByteArray getCode() { | |||
| // return code; | |||
| // } | |||
| // | |||
| // /** | |||
| // * 代码版本; <br> | |||
| // * <p> | |||
| // * 初始为 0,每次对代码的变更都使版本加 1 ; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // @Override | |||
| // public long getCodeVersion() { | |||
| // return codeVersion; | |||
| // } | |||
| // | |||
| // public BlockchainIdentity getIdentity() { | |||
| // return identity; | |||
| // } | |||
| // | |||
| // public void setIdentity(BlockchainIdentity identity) { | |||
| // this.identity = identity; | |||
| // } | |||
| // | |||
| // public void setLedgerHash(ByteArray ledgerHash) { | |||
| // this.ledgerHash = ledgerHash; | |||
| // } | |||
| // | |||
| // public long getBlockHeight() { | |||
| // return blockHeight; | |||
| // } | |||
| // | |||
| // public void setBlockHeight(long blockHeight) { | |||
| // this.blockHeight = blockHeight; | |||
| // } | |||
| // | |||
| // public long getTxSequenceNumber() { | |||
| // return txSequenceNumber; | |||
| // } | |||
| // | |||
| // public void setTxSequenceNumber(long txSequenceNumber) { | |||
| // this.txSequenceNumber = txSequenceNumber; | |||
| // } | |||
| // | |||
| // public void setModelVersion(long modelVersion) { | |||
| // this.modelVersion = modelVersion; | |||
| // } | |||
| // | |||
| // public void setVersion(long version) { | |||
| // this.version = version; | |||
| // } | |||
| // | |||
| // public void setPrivilegeHash(ByteArray privilegeHash) { | |||
| // this.privilegeHash = privilegeHash; | |||
| // } | |||
| // | |||
| // public void setPrivilegeVersion(long privilegeVersion) { | |||
| // this.privilegeVersion = privilegeVersion; | |||
| // } | |||
| // | |||
| // public void setStateType(AccountStateType stateType) { | |||
| // this.stateType = stateType; | |||
| // } | |||
| // | |||
| // public void setStateHash(ByteArray stateHash) { | |||
| // this.stateHash = stateHash; | |||
| // } | |||
| // | |||
| // public void setStateVersion(long stateVersion) { | |||
| // this.stateVersion = stateVersion; | |||
| // } | |||
| // | |||
| // public void setCodeHash(ByteArray codeHash) { | |||
| // this.codeHash = codeHash; | |||
| // } | |||
| // | |||
| // public void setCodeVersion(long codeVersion) { | |||
| // this.codeVersion = codeVersion; | |||
| // } | |||
| // | |||
| // @Override | |||
| // public boolean equals(Object o) { | |||
| // if (this == o) | |||
| // return true; | |||
| // if (!(o instanceof AccountImpl)) | |||
| // return false; | |||
| // | |||
| // AccountImpl account = (AccountImpl) o; | |||
| // | |||
| // if (getBlockHeight() != account.getBlockHeight()) | |||
| // return false; | |||
| // if (getTxSequenceNumber() != account.getTxSequenceNumber()) | |||
| // return false; | |||
| // if (getModelVersion() != account.getModelVersion()) | |||
| // return false; | |||
| // if (getVersion() != account.getVersion()) | |||
| // return false; | |||
| // if (getPrivilegeVersion() != account.getPrivilegeVersion()) | |||
| // return false; | |||
| // if (getStateVersion() != account.getStateVersion()) | |||
| // return false; | |||
| // if (getCodeVersion() != account.getCodeVersion()) | |||
| // return false; | |||
| // if (!getIdentity().equals(account.getIdentity())) | |||
| // return false; | |||
| // if (!getLedgerHash().equals(account.getLedgerHash())) | |||
| // return false; | |||
| // if (!getPrivilegeHash().equals(account.getPrivilegeHash())) | |||
| // return false; | |||
| // if (getStateType() != account.getStateType()) | |||
| // return false; | |||
| // if (!getStateHash().equals(account.getStateHash())) | |||
| // return false; | |||
| // if (!code.equals(account.code)) | |||
| // return false; | |||
| // if (codeHashAlgorithm != account.codeHashAlgorithm) | |||
| // return false; | |||
| // return getCodeHash().equals(account.getCodeHash()); | |||
| // } | |||
| //} | |||
| @@ -1,38 +0,0 @@ | |||
| //package com.jd.blockchain.ledger; | |||
| // | |||
| //import my.utils.io.ByteArray; | |||
| // | |||
| ///** | |||
| // * @author huanghaiquan | |||
| // * | |||
| // */ | |||
| //public interface AccountRegisterOperation extends BlockchainOperation { | |||
| // | |||
| // /** | |||
| // * 要注册的身份;<br> | |||
| // * | |||
| // * 必选; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // BlockchainIdentity getId(); | |||
| // | |||
| // /** | |||
| // * 数据状态的存储类型;<br> | |||
| // * | |||
| // * 必选; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // AccountStateType getStateType(); | |||
| // | |||
| //// /** | |||
| //// * 账户的合约代码; <br> | |||
| //// * | |||
| //// * 可选; | |||
| //// * | |||
| //// * @return | |||
| //// */ | |||
| //// ByteArray getContractCode(); | |||
| // | |||
| //} | |||
| @@ -2,22 +2,22 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @DataContract(code= DataCodes.BLOCK_BODY) | |||
| public interface BlockBody extends LedgerDataSnapshot{ | |||
| @DataField(order=2, primitiveType = DataType.BYTES) | |||
| @DataField(order=2, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getPreviousHash(); | |||
| @DataField(order=3, primitiveType = DataType.BYTES) | |||
| @DataField(order=3, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getLedgerHash(); | |||
| @DataField(order=4, primitiveType= DataType.INT64) | |||
| @DataField(order=4, primitiveType= PrimitiveType.INT64) | |||
| long getHeight(); | |||
| @DataField(order=5, primitiveType = DataType.BYTES) | |||
| @DataField(order=5, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getTransactionSetHash(); | |||
| } | |||
| @@ -1,146 +0,0 @@ | |||
| //package com.jd.blockchain.ledger; | |||
| // | |||
| //import my.utils.io.ByteArray; | |||
| // | |||
| //import java.io.Serializable; | |||
| // | |||
| ///** | |||
| // * 区块链账户; | |||
| // * | |||
| // * @author huanghaiquan | |||
| // * | |||
| // */ | |||
| //public interface BlockchainAccount extends Serializable { | |||
| // | |||
| // /** | |||
| // * 地址; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // BlockchainIdentity getAddress(); | |||
| // | |||
| // /** | |||
| // * 账户所属的账本的 hash;<br> | |||
| // * | |||
| // * 注:账本的hash 等同于该账本的创世区块的 hash; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // ByteArray getLedgerHash(); | |||
| // | |||
| // /** | |||
| // * 注册账户的区块高度; <br> | |||
| // * | |||
| // * 注册此账户的区块高度; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getRegisteredHeight(); | |||
| // | |||
| // /** | |||
| // * 交易流水号;<br> | |||
| // * | |||
| // * 账户的交易流水号初始为 0,当账户作为交易的科目账户(SubjectAccount )发起一个交易并被成功执行之后,账户的交易流水号增加1; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getTxSquenceNumber(); | |||
| // | |||
| // /** | |||
| // * 账户模型版本; <br> | |||
| // * | |||
| // * 表示构成一个账户结构的属性模型的程序版本号; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getModelVersion(); | |||
| // | |||
| // /** | |||
| // * 账户版本; <br> | |||
| // * | |||
| // * 初始为 0,对账户的每一次变更(包括对权限设置、状态和合约代码的变更)都会使账户状态版本增加 1 ;注:交易序号的改变不会导致账户版本的增加; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getVersion(); | |||
| // | |||
| // // /** | |||
| // // * 权限设置; | |||
| // // * | |||
| // // * @return | |||
| // // */ | |||
| // // PrivilegeSetting getPrivilegeSetting(); | |||
| // | |||
| // /** | |||
| // * 权限 hash;<br> | |||
| // * | |||
| // * 权限树的根hash; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // ByteArray getPrivilegeHash(); | |||
| // | |||
| // /** | |||
| // * 权限版本; <br> | |||
| // * | |||
| // * 初始为 0, 每次对权限的变更都导致版本号加 1; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getPrivilegeVersion(); | |||
| // | |||
| //// /** | |||
| //// * 状态类型; <br> | |||
| //// * | |||
| //// * 账户的状态类型有3种:空类型(NIL);键值类型;对象类型;参考 {@link AccountStateType} | |||
| //// * | |||
| //// * @return | |||
| //// */ | |||
| //// AccountStateType getStateType(); | |||
| // | |||
| // /** | |||
| // * 状态版本;<br> | |||
| // * | |||
| // * 初始为 0,每次对状态的更改都使得状态版本增加1; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getStateVersion(); | |||
| // | |||
| // /** | |||
| // * 状态哈希;<br> | |||
| // * | |||
| // * 数据状态的 merkle tree 的根hash; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // ByteArray getStateHash(); | |||
| // | |||
| // // /** | |||
| // // * 合约代码;<br> | |||
| // // * | |||
| // // * 合约代码是一段代码片段; | |||
| // // * | |||
| // // * @return | |||
| // // */ | |||
| // // String getCode(); | |||
| // | |||
| // /** | |||
| // * 合约代码哈希; <br> | |||
| // * | |||
| // * 由“账户地址+合约代码版本号+合约代码内容”生成的哈希; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // ByteArray getCodeHash(); | |||
| // | |||
| // /** | |||
| // * 代码版本; <br> | |||
| // * | |||
| // * 初始为 0,每次对代码的变更都使版本加 1 ; | |||
| // * | |||
| // * @return | |||
| // */ | |||
| // long getCodeVersion(); | |||
| // | |||
| //} | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @@ -10,10 +10,10 @@ import com.jd.blockchain.utils.Bytes; | |||
| @DataContract(code= DataCodes.BLOCK_CHAIN_IDENTITY) | |||
| public interface BlockchainIdentity { | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| Bytes getAddress(); | |||
| @DataField(order = 2, primitiveType=DataType.BYTES) | |||
| @DataField(order = 2, primitiveType=PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| } | |||
| @@ -1,11 +0,0 @@ | |||
| //package com.jd.blockchain.ledger; | |||
| // | |||
| //import java.io.Serializable; | |||
| // | |||
| //public interface BlockchainOperation extends Serializable { | |||
| // | |||
| // OperationType getOperationType(); | |||
| // | |||
| //// Operation getOperation(); | |||
| // | |||
| //} | |||
| @@ -2,10 +2,16 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.utils.io.BytesSlice; | |||
| /** | |||
| * BytesValue is the base structure of Value in Blockchain Account; | |||
| * | |||
| * @author huanghaiquan | |||
| * | |||
| */ | |||
| @DataContract(code = DataCodes.BYTES_VALUE) | |||
| public interface BytesValue { | |||
| @@ -22,7 +28,7 @@ public interface BytesValue { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| BytesSlice getValue(); | |||
| } | |||
| @@ -5,11 +5,11 @@ import com.jd.blockchain.utils.io.BytesSlice; | |||
| /** | |||
| * Created by zhangshuang3 on 2018/12/3. | |||
| */ | |||
| public class BytesValueImpl implements BytesValue{ | |||
| public class BytesValueEntry implements BytesValue{ | |||
| BytesValueType type; | |||
| BytesSlice slice; | |||
| public BytesValueImpl(BytesValueType type, byte[] bytes) { | |||
| public BytesValueEntry(BytesValueType type, byte[] bytes) { | |||
| this.type = type; | |||
| this.slice = new BytesSlice(bytes); | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumContract; | |||
| import com.jd.blockchain.binaryproto.EnumField; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @@ -11,90 +11,78 @@ import com.jd.blockchain.consts.DataCodes; | |||
| * @author huanghaiquan | |||
| * | |||
| */ | |||
| @EnumContract(code = DataCodes.ENUM_TYPE_DATA_TYPE, name = "DataType", decription = "") | |||
| @EnumContract(code = DataCodes.ENUM_TYPE_BYTES_VALUE_TYPE, name = "BytesValueType", decription = "") | |||
| public enum BytesValueType { | |||
| /** | |||
| * 空; | |||
| */ | |||
| NIL(DataType.NIL.CODE), | |||
| NIL(PrimitiveType.NIL.CODE), | |||
| /** | |||
| * 布尔型; | |||
| */ | |||
| BOOLEAN((byte) 0x10), | |||
| BOOLEAN(PrimitiveType.BOOLEAN.CODE), | |||
| /** | |||
| * 数值型: | |||
| */ | |||
| INT8((byte) 0x11), | |||
| INT8(PrimitiveType.INT8.CODE), | |||
| INT16((byte) 0x12), | |||
| INT16(PrimitiveType.INT16.CODE), | |||
| INT32((byte) 0x13), | |||
| INT32(PrimitiveType.INT32.CODE), | |||
| INT64((byte) 0x14), | |||
| INT64(PrimitiveType.INT64.CODE), | |||
| /** | |||
| * 日期时间; | |||
| */ | |||
| DATETIME((byte) 0x15), | |||
| DATETIME(PrimitiveType.DATETIME.CODE), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| TEXT((byte) 0x20), | |||
| TEXT(PrimitiveType.TEXT.CODE), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| JSON((byte) 0x21), | |||
| JSON(PrimitiveType.JSON.CODE), | |||
| /** | |||
| * 文本数据; | |||
| */ | |||
| XML((byte) 0x22), | |||
| XML(PrimitiveType.XML.CODE), | |||
| /** | |||
| * 二进制数据; | |||
| */ | |||
| BYTES((byte) 0x40), | |||
| BYTES(PrimitiveType.BYTES.CODE), | |||
| /** | |||
| * 大整数; | |||
| */ | |||
| BIG_INT((byte) 0x41), | |||
| BIG_INT(PrimitiveType.BIG_INT.CODE), | |||
| /** | |||
| * 图片; | |||
| */ | |||
| IMG((byte) 0x42), | |||
| IMG(PrimitiveType.IMG.CODE), | |||
| /** | |||
| * 视频; | |||
| */ | |||
| VIDEO((byte) 0x43), | |||
| VIDEO(PrimitiveType.VIDEO.CODE), | |||
| /** | |||
| * 位置; | |||
| */ | |||
| LOCATION((byte) 0x44); | |||
| // /** | |||
| // * 引用; <br> | |||
| // * | |||
| // * 表示引用区块链系统中的某一个特定的对象,用以下形式的 URI 表示; | |||
| // * | |||
| // * state://ledger/account/key/version <br> | |||
| // * 或 <br> | |||
| // * proof:state://account_merkle_path/key_merkle_path | |||
| // * | |||
| // * proof:tx:// | |||
| // * | |||
| // */ | |||
| // REFERENCE((byte) 0x80); | |||
| @EnumField(type = DataType.INT8) | |||
| LOCATION(PrimitiveType.LOCATION.CODE); | |||
| @EnumField(type = PrimitiveType.INT8) | |||
| public final byte CODE; | |||
| private BytesValueType(byte code) { | |||
| @@ -107,7 +95,7 @@ public enum BytesValueType { | |||
| return dataType; | |||
| } | |||
| } | |||
| throw new IllegalArgumentException("Unsupported code[" + code + "] of DataType!"); | |||
| throw new IllegalArgumentException("Code [" + code + "] not supported by BytesValueType enum!"); | |||
| } | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code= DataCodes.TX_OP_CONTRACT_DEPLOY) | |||
| @@ -11,7 +11,7 @@ public interface ContractCodeDeployOperation extends Operation { | |||
| @DataField(order=2, refContract = true) | |||
| BlockchainIdentity getContractID(); | |||
| @DataField(order=3, primitiveType=DataType.BYTES) | |||
| @DataField(order=3, primitiveType=PrimitiveType.BYTES) | |||
| byte[] getChainCode(); | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @@ -13,14 +13,14 @@ import com.jd.blockchain.utils.Bytes; | |||
| @DataContract(code= DataCodes.TX_OP_CONTRACT_EVENT_SEND) | |||
| public interface ContractEventSendOperation extends Operation { | |||
| @DataField(order=2, primitiveType=DataType.BYTES) | |||
| @DataField(order=2, primitiveType=PrimitiveType.BYTES) | |||
| Bytes getContractAddress(); | |||
| @DataField(order=3, primitiveType=DataType.TEXT) | |||
| @DataField(order=3, primitiveType=PrimitiveType.TEXT) | |||
| String getEvent(); | |||
| @DataField(order=4, primitiveType=DataType.BYTES) | |||
| @DataField(order=4, primitiveType=PrimitiveType.BYTES) | |||
| byte[] getArgs(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| /** | |||
| @@ -23,7 +23,7 @@ public interface CryptoSetting { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.INT16) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.INT16) | |||
| public short getHashAlgorithm(); | |||
| /** | |||
| @@ -35,7 +35,7 @@ public interface CryptoSetting { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 2, primitiveType = DataType.BOOLEAN) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.BOOLEAN) | |||
| public boolean getAutoVerifyHash(); | |||
| } | |||
| @@ -2,14 +2,14 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @DataContract(code= DataCodes.TX_OP_DATA_ACC_SET) | |||
| public interface DataAccountKVSetOperation extends Operation{ | |||
| @DataField(order=2, primitiveType=DataType.BYTES) | |||
| @DataField(order=2, primitiveType=PrimitiveType.BYTES) | |||
| Bytes getAccountAddress(); | |||
| @DataField(order=3, list=true, refContract=true) | |||
| @@ -19,13 +19,13 @@ public interface DataAccountKVSetOperation extends Operation{ | |||
| @DataContract(code=DataCodes.TX_OP_DATA_ACC_SET_KV) | |||
| public static interface KVWriteEntry{ | |||
| @DataField(order=1, primitiveType=DataType.TEXT) | |||
| @DataField(order=1, primitiveType=PrimitiveType.TEXT) | |||
| String getKey(); | |||
| @DataField(order=2, refContract = true) | |||
| BytesValue getValue(); | |||
| @DataField(order=3, primitiveType=DataType.INT64) | |||
| @DataField(order=3, primitiveType=PrimitiveType.INT64) | |||
| long getExpectedVersion(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| import com.jd.blockchain.crypto.SignatureDigest; | |||
| @@ -23,7 +23,7 @@ public interface DigitalSignatureBody { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| /** | |||
| @@ -31,7 +31,7 @@ public interface DigitalSignatureBody { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=2, primitiveType = DataType.BYTES ) | |||
| @DataField(order=2, primitiveType = PrimitiveType.BYTES ) | |||
| SignatureDigest getDigest(); | |||
| } | |||
| @@ -2,14 +2,14 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @DataContract(code= DataCodes.REQUEST_ENDPOINT) | |||
| public interface EndpointRequest { | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getHash(); | |||
| /** | |||
| * 交易内容; | |||
| @@ -1,6 +1,6 @@ | |||
| package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| public interface KVDataEntry { | |||
| @@ -27,7 +27,7 @@ public interface KVDataEntry { | |||
| * | |||
| * @return | |||
| */ | |||
| DataType getType(); | |||
| PrimitiveType getType(); | |||
| /** | |||
| * 值; | |||
| @@ -5,7 +5,7 @@ import java.io.UnsupportedEncodingException; | |||
| import java.math.BigInteger; | |||
| import java.util.Date; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.utils.io.ByteArray; | |||
| import com.jd.blockchain.utils.io.BytesUtils; | |||
| @@ -25,11 +25,11 @@ public class KVDataObject implements KVDataEntry { | |||
| private long version; | |||
| private DataType type; | |||
| private PrimitiveType type; | |||
| private byte[] bytesValue; | |||
| public KVDataObject(String key, long version, DataType type, byte[] bytesValue) { | |||
| public KVDataObject(String key, long version, PrimitiveType type, byte[] bytesValue) { | |||
| this.key = key; | |||
| this.type = type; | |||
| this.version = version < 0 ? -1 : version; | |||
| @@ -62,7 +62,7 @@ public class KVDataObject implements KVDataEntry { | |||
| * @see com.jd.blockchain.ledger.KVDataEntry#getType() | |||
| */ | |||
| @Override | |||
| public DataType getType() { | |||
| public PrimitiveType getType() { | |||
| return type; | |||
| } | |||
| @@ -97,13 +97,13 @@ public class KVDataObject implements KVDataEntry { | |||
| * 是否为空值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#NIL} 时返回 true,其它情况返回 false; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#NIL} 时返回 true,其它情况返回 false; | |||
| * <p> | |||
| * | |||
| * @return | |||
| */ | |||
| public boolean isNil() { | |||
| return DataType.NIL == type; | |||
| return PrimitiveType.NIL == type; | |||
| } | |||
| /** | |||
| @@ -119,7 +119,7 @@ public class KVDataObject implements KVDataEntry { | |||
| * 返回 8 位整数值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#INT8} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#INT8} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -127,17 +127,17 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public byte tinyValue() { | |||
| if (DataType.INT8 == type) { | |||
| if (PrimitiveType.INT8 == type) { | |||
| return bytesValue[0]; | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT8, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.INT8, type)); | |||
| } | |||
| /** | |||
| * 返回 16 位整数值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#INT16} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#INT16} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -145,17 +145,17 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public short shortValue() { | |||
| if (DataType.INT16 == type) { | |||
| if (PrimitiveType.INT16 == type) { | |||
| return BytesUtils.toShort(bytesValue, 0); | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT16, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.INT16, type)); | |||
| } | |||
| /** | |||
| * 返回 32 位整数值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#INT32} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#INT32} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -163,17 +163,17 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public int intValue() { | |||
| if (DataType.INT32 == type) { | |||
| if (PrimitiveType.INT32 == type) { | |||
| return BytesUtils.toInt(bytesValue, 0); | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT32, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.INT32, type)); | |||
| } | |||
| /** | |||
| * 返回 64 位整数值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#INT64} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#INT64} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -181,10 +181,10 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public long longValue() { | |||
| if (DataType.INT64 == type) { | |||
| if (PrimitiveType.INT64 == type) { | |||
| return BytesUtils.toLong(bytesValue, 0); | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT64, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.INT64, type)); | |||
| } | |||
| @@ -192,7 +192,7 @@ public class KVDataObject implements KVDataEntry { | |||
| * 返回大整数值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#BIG_INT} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#BIG_INT} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -200,17 +200,17 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public BigInteger bigIntValue() { | |||
| if (DataType.BIG_INT == type) { | |||
| if (PrimitiveType.BIG_INT == type) { | |||
| return new BigInteger(bytesValue); | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.BIG_INT, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.BIG_INT, type)); | |||
| } | |||
| /** | |||
| * 返回布尔值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#BIG_INT} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#BIG_INT} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -218,17 +218,17 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public boolean boolValue() { | |||
| if (DataType.BOOLEAN == type) { | |||
| if (PrimitiveType.BOOLEAN == type) { | |||
| return bytesValue[0] != 0; | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.BOOLEAN, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.BOOLEAN, type)); | |||
| } | |||
| /** | |||
| * 返回日期时间值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#DATETIME} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#DATETIME} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -236,19 +236,19 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public Date datetimeValue() { | |||
| if (DataType.DATETIME == type) { | |||
| if (PrimitiveType.DATETIME == type) { | |||
| long ts = BytesUtils.toLong(bytesValue); | |||
| return new Date(ts); | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.DATETIME, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s], but [%s]", PrimitiveType.DATETIME, type)); | |||
| } | |||
| /** | |||
| * 返回大整数值; | |||
| * <p> | |||
| * | |||
| * 仅当数据类型 {@link #getType()} 为 {@link DataType#TEXT} / {@link DataType#JSON} / | |||
| * {@link DataType#XML} 有效; | |||
| * 仅当数据类型 {@link #getType()} 为 {@link PrimitiveType#TEXT} / {@link PrimitiveType#JSON} / | |||
| * {@link PrimitiveType#XML} 有效; | |||
| * <p> | |||
| * | |||
| * 无效类型将引发 {@link IllegalStateException} 异常; | |||
| @@ -256,15 +256,15 @@ public class KVDataObject implements KVDataEntry { | |||
| * @return | |||
| */ | |||
| public String stringValue() { | |||
| if (DataType.TEXT == type || DataType.JSON == type || DataType.XML == type) { | |||
| if (PrimitiveType.TEXT == type || PrimitiveType.JSON == type || PrimitiveType.XML == type) { | |||
| try { | |||
| return new String(bytesValue, "UTF-8"); | |||
| } catch (UnsupportedEncodingException e) { | |||
| throw new IllegalStateException(e.getMessage(), e); | |||
| } | |||
| } | |||
| throw new IllegalStateException(String.format("Expected type [%s] or [%s] or [%s] , but [%s]", DataType.TEXT, | |||
| DataType.JSON, DataType.XML, type)); | |||
| throw new IllegalStateException(String.format("Expected type [%s] or [%s] or [%s] , but [%s]", PrimitiveType.TEXT, | |||
| PrimitiveType.JSON, PrimitiveType.XML, type)); | |||
| } | |||
| // // ---------------- | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @@ -19,7 +19,7 @@ public interface LedgerBlock extends BlockBody { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getHash(); | |||
| } | |||
| @@ -2,23 +2,23 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @DataContract(code=DataCodes.DATA_SNAPSHOT) | |||
| public interface LedgerDataSnapshot { | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getAdminAccountHash(); | |||
| @DataField(order=2, primitiveType = DataType.BYTES) | |||
| @DataField(order=2, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getUserAccountSetHash(); | |||
| @DataField(order=3, primitiveType = DataType.BYTES) | |||
| @DataField(order=3, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getDataAccountSetHash(); | |||
| @DataField(order=4, primitiveType = DataType.BYTES) | |||
| @DataField(order=4, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getContractAccountSetHash(); | |||
| // HashDigest getUserPrivilegeHash(); | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @@ -19,7 +19,7 @@ public interface LedgerInitSetting { | |||
| * 账本的种子; | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| byte[] getLedgerSeed(); | |||
| /** | |||
| @@ -39,7 +39,7 @@ public interface LedgerInitSetting { | |||
| CryptoSetting getCryptoSetting(); | |||
| @DataField(order = 4, primitiveType=DataType.TEXT) | |||
| @DataField(order = 4, primitiveType=PrimitiveType.TEXT) | |||
| String getConsensusProvider(); | |||
| /** | |||
| @@ -47,7 +47,7 @@ public interface LedgerInitSetting { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 5, primitiveType=DataType.BYTES) | |||
| @DataField(order = 5, primitiveType=PrimitiveType.BYTES) | |||
| Bytes getConsensusSettings(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.PubKey; | |||
| @@ -29,7 +29,7 @@ public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.TEXT) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.TEXT) | |||
| String getAddress(); | |||
| /** | |||
| @@ -37,7 +37,7 @@ public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 2, primitiveType = DataType.TEXT) | |||
| @DataField(order = 2, primitiveType = PrimitiveType.TEXT) | |||
| String getName(); | |||
| /** | |||
| @@ -45,6 +45,6 @@ public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 3, primitiveType = DataType.BYTES) | |||
| @DataField(order = 3, primitiveType = PrimitiveType.BYTES) | |||
| PubKey getPubKey(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.utils.io.ByteArray; | |||
| @@ -23,7 +23,7 @@ public interface Transaction extends NodeRequest, HashObject { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| @Override | |||
| HashDigest getHash(); | |||
| @@ -32,7 +32,7 @@ public interface Transaction extends NodeRequest, HashObject { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=2, primitiveType=DataType.INT64) | |||
| @DataField(order=2, primitiveType=PrimitiveType.INT64) | |||
| long getBlockHeight(); | |||
| /** | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @@ -15,7 +15,7 @@ import com.jd.blockchain.crypto.HashDigest; | |||
| @DataContract(code= DataCodes.TX_CONTENT) | |||
| public interface TransactionContent extends TransactionContentBody, HashObject { | |||
| @Override | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getHash(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @@ -22,7 +22,7 @@ public interface TransactionContentBody { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order = 1, primitiveType = DataType.BYTES) | |||
| @DataField(order = 1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getLedgerHash(); | |||
| /** | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @@ -21,6 +21,6 @@ public interface TransactionRequest extends NodeRequest, HashObject { | |||
| * @return | |||
| */ | |||
| @Override | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getHash(); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataContract; | |||
| import com.jd.blockchain.binaryproto.DataField; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| @@ -20,7 +20,7 @@ public interface TransactionResponse { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=1, primitiveType = DataType.BYTES) | |||
| @DataField(order=1, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getContentHash(); | |||
| /** | |||
| @@ -36,7 +36,7 @@ public interface TransactionResponse { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=3, primitiveType = DataType.BYTES) | |||
| @DataField(order=3, primitiveType = PrimitiveType.BYTES) | |||
| HashDigest getBlockHash(); | |||
| /** | |||
| @@ -47,10 +47,10 @@ public interface TransactionResponse { | |||
| * | |||
| * @return | |||
| */ | |||
| @DataField(order=4, primitiveType=DataType.INT64) | |||
| @DataField(order=4, primitiveType=PrimitiveType.INT64) | |||
| long getBlockHeight(); | |||
| @DataField(order=5, primitiveType=DataType.BOOLEAN) | |||
| @DataField(order=5, primitiveType=PrimitiveType.BOOLEAN) | |||
| boolean isSuccess(); | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| package com.jd.blockchain.ledger; | |||
| import com.jd.blockchain.binaryproto.DataType; | |||
| import com.jd.blockchain.binaryproto.PrimitiveType; | |||
| import com.jd.blockchain.binaryproto.EnumContract; | |||
| import com.jd.blockchain.binaryproto.EnumField; | |||
| import com.jd.blockchain.consts.DataCodes; | |||
| @@ -39,7 +39,7 @@ public enum TransactionState { | |||
| */ | |||
| TIMEOUT((byte) 0x81); | |||
| @EnumField(type= DataType.INT8) | |||
| @EnumField(type= PrimitiveType.INT8) | |||
| public final byte CODE; | |||
| private TransactionState(byte code) { | |||
| @@ -7,12 +7,6 @@ import com.jd.blockchain.consts.DataCodes; | |||
| @DataContract(code= DataCodes.TX_OP_USER_REG) | |||
| public interface UserRegisterOperation extends Operation { | |||
| // @Override | |||
| // @DataField(order=1, refEnum = true) | |||
| // default OperationType getType() { | |||
| // return OperationType.REGISTER_DATA_ACCOUNT; | |||
| // } | |||
| @DataField(order=2, refContract = true) | |||
| BlockchainIdentity getUserID(); | |||
| @@ -1,7 +1,7 @@ | |||
| package com.jd.blockchain.transaction; | |||
| import com.jd.blockchain.ledger.BytesValue; | |||
| import com.jd.blockchain.ledger.BytesValueImpl; | |||
| import com.jd.blockchain.ledger.BytesValueEntry; | |||
| import com.jd.blockchain.ledger.DataAccountKVSetOperation; | |||
| import com.jd.blockchain.ledger.BytesValueType; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @@ -23,7 +23,7 @@ public class DataAccountKVSetOperationBuilderImpl implements DataAccountKVSetOpe | |||
| @Override | |||
| public DataAccountKVSetOperationBuilder set(String key, byte[] value, long expVersion) { | |||
| BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value); | |||
| BytesValue bytesValue = new BytesValueEntry(BytesValueType.BYTES, value); | |||
| operation.set(key, bytesValue, expVersion); | |||
| return this; | |||
| } | |||
| @@ -32,10 +32,10 @@ public class DataAccountKVSetOperationBuilderImpl implements DataAccountKVSetOpe | |||
| public DataAccountKVSetOperationBuilder set(String key, String value, long expVersion) { | |||
| BytesValue bytesValue; | |||
| if (JSONSerializeUtils.isJSON(value)) { | |||
| bytesValue = new BytesValueImpl(BytesValueType.JSON, value.getBytes()); | |||
| bytesValue = new BytesValueEntry(BytesValueType.JSON, value.getBytes()); | |||
| } | |||
| else { | |||
| bytesValue = new BytesValueImpl(BytesValueType.TEXT, value.getBytes()); | |||
| bytesValue = new BytesValueEntry(BytesValueType.TEXT, value.getBytes()); | |||
| } | |||
| operation.set(key, bytesValue, expVersion); | |||
| return this; | |||
| @@ -43,13 +43,13 @@ public class DataAccountKVSetOperationBuilderImpl implements DataAccountKVSetOpe | |||
| @Override | |||
| public DataAccountKVSetOperationBuilder set(String key, Bytes value, long expVersion) { | |||
| BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value.toBytes()); | |||
| BytesValue bytesValue = new BytesValueEntry(BytesValueType.BYTES, value.toBytes()); | |||
| operation.set(key, bytesValue, expVersion); | |||
| return this; | |||
| } | |||
| @Override | |||
| public DataAccountKVSetOperationBuilder set(String key, long value, long expVersion) { | |||
| BytesValue bytesValue = new BytesValueImpl(BytesValueType.INT64, BytesUtils.toBytes(value)); | |||
| BytesValue bytesValue = new BytesValueEntry(BytesValueType.INT64, BytesUtils.toBytes(value)); | |||
| operation.set(key, bytesValue, expVersion); | |||
| return this; | |||
| } | |||
| @@ -10,7 +10,7 @@ package test.com.jd.blockchain.ledger.data; | |||
| import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
| import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
| import com.jd.blockchain.ledger.BytesValueImpl; | |||
| import com.jd.blockchain.ledger.BytesValueEntry; | |||
| import com.jd.blockchain.ledger.DataAccountKVSetOperation; | |||
| import com.jd.blockchain.ledger.BytesValueType; | |||
| import com.jd.blockchain.ledger.Operation; | |||
| @@ -43,11 +43,11 @@ public class DataAccountKVSetOpTemplateTest { | |||
| String accountAddress = "zhangsandhakhdkah"; | |||
| data = new DataAccountKVSetOpTemplate(Bytes.fromString(accountAddress)); | |||
| KVData kvData1 = | |||
| new KVData("test1", new BytesValueImpl(BytesValueType.TEXT, "zhangsan".getBytes()), 9999L); | |||
| new KVData("test1", new BytesValueEntry(BytesValueType.TEXT, "zhangsan".getBytes()), 9999L); | |||
| KVData kvData2 = | |||
| new KVData("test2", new BytesValueImpl(BytesValueType.TEXT, "lisi".getBytes()), 9990L); | |||
| new KVData("test2", new BytesValueEntry(BytesValueType.TEXT, "lisi".getBytes()), 9990L); | |||
| KVData kvData3 = | |||
| new KVData("test3", new BytesValueImpl(BytesValueType.TEXT, "wangwu".getBytes()), 1990L); | |||
| new KVData("test3", new BytesValueEntry(BytesValueType.TEXT, "wangwu".getBytes()), 1990L); | |||
| data.set(kvData1); | |||
| data.set(kvData2); | |||
| data.set(kvData3); | |||
| @@ -10,7 +10,7 @@ package test.com.jd.blockchain.ledger.data; | |||
| import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
| import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
| import com.jd.blockchain.ledger.BytesValueImpl; | |||
| import com.jd.blockchain.ledger.BytesValueEntry; | |||
| import com.jd.blockchain.ledger.DataAccountKVSetOperation; | |||
| import com.jd.blockchain.ledger.BytesValueType; | |||
| import com.jd.blockchain.transaction.DataAccountKVSetOpTemplate; | |||
| @@ -39,7 +39,7 @@ public class KVDataTest { | |||
| byte[] value = "test-value".getBytes(); | |||
| long expectedVersion = 9999L; | |||
| kvData = new KVData(key, new BytesValueImpl(BytesValueType.BYTES, value), expectedVersion); | |||
| kvData = new KVData(key, new BytesValueEntry(BytesValueType.BYTES, value), expectedVersion); | |||
| } | |||
| @Test | |||