@@ -1,10 +1,12 @@ | |||||
package com.jd.blockchain.consts; | package com.jd.blockchain.consts; | ||||
/** | /** | ||||
* A const registeration of codes of all data contracts in ledger model; | |||||
* | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
public interface TypeCodes { | |||||
public interface DataCodes { | |||||
public static final int BYTES_VALUE = 0x80; | public static final int BYTES_VALUE = 0x80; | ||||
@@ -59,11 +61,11 @@ public interface TypeCodes { | |||||
public static final int METADATA_CONSENSUS_PARTICIPANT = 0x621; | public static final int METADATA_CONSENSUS_PARTICIPANT = 0x621; | ||||
// public static final int METADATA_CONSENSUS_NODE = 0x630; | |||||
// public static final int METADATA_CONSENSUS_NODE = 0x630; | |||||
public static final int METADATA_CONSENSUS_SETTING = 0x631; | public static final int METADATA_CONSENSUS_SETTING = 0x631; | ||||
// public static final int METADATA_PARTICIPANT_INFO = 0x640; | |||||
// public static final int METADATA_PARTICIPANT_INFO = 0x640; | |||||
public static final int METADATA_CRYPTO_SETTING = 0x642; | public static final int METADATA_CRYPTO_SETTING = 0x642; | ||||
@@ -87,7 +89,7 @@ public interface TypeCodes { | |||||
public static final int ENUM_TYPE_TRANSACTION_STATE = 0xB22; | public static final int ENUM_TYPE_TRANSACTION_STATE = 0xB22; | ||||
public static final int ENUM_TYPE_DATA_TYPE= 0xB23; | |||||
public static final int ENUM_TYPE_DATA_TYPE = 0xB23; | |||||
public static final int DIGITALSIGNATURE = 0xB30; | public static final int DIGITALSIGNATURE = 0xB30; | ||||
@@ -103,8 +105,6 @@ public interface TypeCodes { | |||||
public static final int REQUEST_ENDPOINT = 0xD20; | public static final int REQUEST_ENDPOINT = 0xD20; | ||||
// ------------------ 共识相关 ---------------- | // ------------------ 共识相关 ---------------- | ||||
public static final int CONSENSUS = 0x1000; | public static final int CONSENSUS = 0x1000; | ||||
@@ -112,12 +112,11 @@ public interface TypeCodes { | |||||
public static final int CONSENSUS_ACTION_REQUEST = CONSENSUS | 0x01; | public static final int CONSENSUS_ACTION_REQUEST = CONSENSUS | 0x01; | ||||
public static final int CONSENSUS_ACTION_RESPONSE = CONSENSUS | 0x02; | public static final int CONSENSUS_ACTION_RESPONSE = CONSENSUS | 0x02; | ||||
public static final int CONSENSUS_SETTINGS = CONSENSUS | 0x03; | public static final int CONSENSUS_SETTINGS = CONSENSUS | 0x03; | ||||
public static final int CONSENSUS_NODE_SETTINGS = CONSENSUS | 0x04; | public static final int CONSENSUS_NODE_SETTINGS = CONSENSUS | 0x04; | ||||
public static final int CONSENSUS_CLI_INCOMING_SETTINGS = CONSENSUS | 0x05; | public static final int CONSENSUS_CLI_INCOMING_SETTINGS = CONSENSUS | 0x05; | ||||
// ------------------ 共识相关(BFTSMART) ---------------- | // ------------------ 共识相关(BFTSMART) ---------------- | ||||
@@ -126,7 +125,7 @@ public interface TypeCodes { | |||||
public static final int CONSENSUS_BFTSMART_SETTINGS = CONSENSUS_BFTSMART | 0x01; | public static final int CONSENSUS_BFTSMART_SETTINGS = CONSENSUS_BFTSMART | 0x01; | ||||
public static final int CONSENSUS_BFTSMART_NODE_SETTINGS = CONSENSUS_BFTSMART | 0x02; | public static final int CONSENSUS_BFTSMART_NODE_SETTINGS = CONSENSUS_BFTSMART | 0x02; | ||||
public static final int CONSENSUS_BFTSMART_CLI_INCOMING_SETTINGS = CONSENSUS_BFTSMART | 0x03; | public static final int CONSENSUS_BFTSMART_CLI_INCOMING_SETTINGS = CONSENSUS_BFTSMART | 0x03; | ||||
public static final int CONSENSUS_BFTSMART_BLOCK_SETTINGS = CONSENSUS_BFTSMART | 0x04; | public static final int CONSENSUS_BFTSMART_BLOCK_SETTINGS = CONSENSUS_BFTSMART | 0x04; | ||||
@@ -144,5 +143,4 @@ public interface TypeCodes { | |||||
public static final int CONSENSUS_MSGQUEUE_BLOCK_SETTINGS = CONSENSUS_MSGQUEUE | 0x05; | public static final int CONSENSUS_MSGQUEUE_BLOCK_SETTINGS = CONSENSUS_MSGQUEUE | 0x05; | ||||
} | } |
@@ -5,8 +5,6 @@ import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | import java.lang.annotation.RetentionPolicy; | ||||
import java.lang.annotation.Target; | import java.lang.annotation.Target; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 标记一个接口的字段作为数据契约的字段; | * 标记一个接口的字段作为数据契约的字段; | ||||
* <p> | * <p> | ||||
@@ -39,11 +37,11 @@ public @interface DataField { | |||||
* 基本数据类型; | * 基本数据类型; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 如果字段的类型属于 {@link ValueType} 枚举中的基本数据类型,则需要显式指定一种具体的类型; | |||||
* 如果字段的类型属于 {@link DataType} 枚举中的基本数据类型,则需要显式指定一种具体的类型; | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
ValueType primitiveType() default ValueType.NIL; | |||||
DataType primitiveType() default DataType.NIL; | |||||
/** | /** | ||||
* 是否是枚举类型; | * 是否是枚举类型; | ||||
@@ -80,8 +78,8 @@ public @interface DataField { | |||||
/** | /** | ||||
* 最大长度,单位为“byte” | * 最大长度,单位为“byte” | ||||
* <p> | * <p> | ||||
* 仅对于文本、字节数组、大整数等相关的数据类型有效(即:{@link ValueType} 枚举中编码大于等于 0x20 | |||||
* {@link ValueType#TEXT}的数据类型); | |||||
* 仅对于文本、字节数组、大整数等相关的数据类型有效(即:{@link DataType} 枚举中编码大于等于 0x20 | |||||
* {@link DataType#TEXT}的数据类型); | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@@ -1,4 +1,4 @@ | |||||
package com.jd.blockchain.utils; | |||||
package com.jd.blockchain.binaryproto; | |||||
/** | /** | ||||
* 键值操作的数据类型; | * 键值操作的数据类型; | ||||
@@ -6,7 +6,7 @@ package com.jd.blockchain.utils; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
public enum ValueType { | |||||
public enum DataType { | |||||
/** | /** | ||||
* 空; | * 空; | ||||
@@ -98,12 +98,12 @@ public enum ValueType { | |||||
public final byte CODE; | public final byte CODE; | ||||
private ValueType(byte code) { | |||||
private DataType(byte code) { | |||||
this.CODE = code; | this.CODE = code; | ||||
} | } | ||||
public static ValueType valueOf(byte code) { | |||||
for (ValueType dataType : ValueType.values()) { | |||||
public static DataType valueOf(byte code) { | |||||
for (DataType dataType : DataType.values()) { | |||||
if (dataType.CODE == code) { | if (dataType.CODE == code) { | ||||
return dataType; | return dataType; | ||||
} | } |
@@ -5,8 +5,6 @@ import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | import java.lang.annotation.RetentionPolicy; | ||||
import java.lang.annotation.Target; | import java.lang.annotation.Target; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@Target({ ElementType.FIELD, ElementType.METHOD }) | @Target({ ElementType.FIELD, ElementType.METHOD }) | ||||
@Retention(RetentionPolicy.RUNTIME) | @Retention(RetentionPolicy.RUNTIME) | ||||
public @interface EnumField { | public @interface EnumField { | ||||
@@ -15,11 +13,11 @@ public @interface EnumField { | |||||
* 枚举值的类型; | * 枚举值的类型; | ||||
* | * | ||||
* <p> | * <p> | ||||
* 注:只支持 {@link ValueType#INT8} ~ {@link ValueType#INT32} 这几种类型; | |||||
* 注:只支持 {@link DataType#INT8} ~ {@link DataType#INT32} 这几种类型; | |||||
* | * | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
ValueType type(); | |||||
DataType type(); | |||||
} | } |
@@ -1,9 +1,5 @@ | |||||
package com.jd.blockchain.binaryproto; | package com.jd.blockchain.binaryproto; | ||||
import java.util.Set; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
public interface EnumSpecification { | public interface EnumSpecification { | ||||
int getCode(); | int getCode(); | ||||
@@ -14,7 +10,7 @@ public interface EnumSpecification { | |||||
long getVersion(); | long getVersion(); | ||||
ValueType getValueType(); | |||||
DataType getValueType(); | |||||
int[] getItemValues(); | int[] getItemValues(); | ||||
@@ -1,7 +1,5 @@ | |||||
package com.jd.blockchain.binaryproto; | package com.jd.blockchain.binaryproto; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 表示数据契约字段的格式标准; | * 表示数据契约字段的格式标准; | ||||
* | * | ||||
@@ -35,11 +33,11 @@ public interface FieldSpec { | |||||
* 字段的值的类型; | * 字段的值的类型; | ||||
* <p> | * <p> | ||||
* 如果不是字段的值不是基本类型,则返回 null(即: {@link DataField#primitiveType()} 设置为 | * 如果不是字段的值不是基本类型,则返回 null(即: {@link DataField#primitiveType()} 设置为 | ||||
* {@link ValueType#NIL}); | |||||
* {@link DataType#NIL}); | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
ValueType getPrimitiveType(); | |||||
DataType getPrimitiveType(); | |||||
/** | /** | ||||
* 字段的值引用的枚举契约; | * 字段的值引用的枚举契约; | ||||
@@ -5,7 +5,6 @@ import java.lang.reflect.Method; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Collections; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -18,12 +17,12 @@ import com.jd.blockchain.binaryproto.DataContractEncoder; | |||||
import com.jd.blockchain.binaryproto.DataContractException; | import com.jd.blockchain.binaryproto.DataContractException; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataSpecification; | import com.jd.blockchain.binaryproto.DataSpecification; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumContract; | import com.jd.blockchain.binaryproto.EnumContract; | ||||
import com.jd.blockchain.binaryproto.EnumField; | import com.jd.blockchain.binaryproto.EnumField; | ||||
import com.jd.blockchain.binaryproto.EnumSpecification; | import com.jd.blockchain.binaryproto.EnumSpecification; | ||||
import com.jd.blockchain.binaryproto.FieldSpec; | import com.jd.blockchain.binaryproto.FieldSpec; | ||||
import com.jd.blockchain.binaryproto.impl.EnumSpecificationInfo.EnumConstant; | import com.jd.blockchain.binaryproto.impl.EnumSpecificationInfo.EnumConstant; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.utils.io.BytesSerializable; | import com.jd.blockchain.utils.io.BytesSerializable; | ||||
import com.jd.blockchain.utils.io.BytesUtils; | import com.jd.blockchain.utils.io.BytesUtils; | ||||
import com.jd.blockchain.utils.security.SHA256Hash; | import com.jd.blockchain.utils.security.SHA256Hash; | ||||
@@ -66,23 +65,23 @@ public class DataContractContext { | |||||
private static Map<Class<?>, EnumSpecification> enumContractSpecMap = new ConcurrentHashMap<>(); | private static Map<Class<?>, EnumSpecification> enumContractSpecMap = new ConcurrentHashMap<>(); | ||||
private static Map<ValueType, Map<Class<?>, ValueConverter>> primitiveTypeConverters = new HashMap<>(); | |||||
private static Map<DataType, Map<Class<?>, ValueConverter>> primitiveTypeConverters = new HashMap<>(); | |||||
static { | static { | ||||
addConverterMapping(ValueType.BOOLEAN, boolean.class, new BoolConverter()); | |||||
addConverterMapping(ValueType.BOOLEAN, Boolean.class, new BoolWrapperConverter()); | |||||
addConverterMapping(ValueType.INT8, byte.class, new Int8ByteConverter()); | |||||
addConverterMapping(ValueType.INT8, Byte.class, new Int8ByteWrapperConverter()); | |||||
addConverterMapping(ValueType.INT16, short.class, new Int16ShortConverter()); | |||||
addConverterMapping(ValueType.INT16, Short.class, new Int16ShortWrapperConverter()); | |||||
addConverterMapping(ValueType.INT16, char.class, new Int16CharConverter()); | |||||
addConverterMapping(ValueType.INT16, Character.class, new Int16CharWrapperConverter()); | |||||
addConverterMapping(ValueType.INT32, int.class, new Int32IntConverter()); | |||||
addConverterMapping(ValueType.INT32, Integer.class, new Int32IntWrapperConverter()); | |||||
addConverterMapping(ValueType.INT64, long.class, new Int64LongConverter()); | |||||
addConverterMapping(ValueType.INT64, Long.class, new Int64LongWrapperConverter()); | |||||
addConverterMapping(ValueType.TEXT, String.class, new StringValueConverter()); | |||||
addConverterMapping(ValueType.BYTES, byte[].class, new BytesValueConverter()); | |||||
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()); | |||||
ENCODER_LOOKUP = new DataContractEncoderLookup() { | ENCODER_LOOKUP = new DataContractEncoderLookup() { | ||||
@Override | @Override | ||||
@@ -102,7 +101,7 @@ public class DataContractContext { | |||||
}; | }; | ||||
} | } | ||||
private static void addConverterMapping(ValueType protocalType, Class<?> javaType, ValueConverter converter) { | |||||
private static void addConverterMapping(DataType protocalType, Class<?> javaType, ValueConverter converter) { | |||||
Map<Class<?>, ValueConverter> converterMap = primitiveTypeConverters.get(protocalType); | Map<Class<?>, ValueConverter> converterMap = primitiveTypeConverters.get(protocalType); | ||||
if (converterMap == null) { | if (converterMap == null) { | ||||
converterMap = new HashMap<>(); | converterMap = new HashMap<>(); | ||||
@@ -111,14 +110,14 @@ public class DataContractContext { | |||||
converterMap.put(javaType, converter); | converterMap.put(javaType, converter); | ||||
} | } | ||||
private static ValueConverter getPrimitiveTypeConverter(ValueType protocalType, Class<?> javaType) { | |||||
private static ValueConverter getPrimitiveTypeConverter(DataType protocalType, Class<?> javaType) { | |||||
Map<Class<?>, ValueConverter> converterMap = primitiveTypeConverters.get(protocalType); | Map<Class<?>, ValueConverter> converterMap = primitiveTypeConverters.get(protocalType); | ||||
if (converterMap != null) { | if (converterMap != null) { | ||||
ValueConverter converter = converterMap.get(javaType); | ValueConverter converter = converterMap.get(javaType); | ||||
if (converter != null) { | if (converter != null) { | ||||
return converter; | return converter; | ||||
} | } | ||||
if (ValueType.BYTES == protocalType && BytesSerializable.class.isAssignableFrom(javaType)) { | |||||
if (DataType.BYTES == protocalType && BytesSerializable.class.isAssignableFrom(javaType)) { | |||||
converter = new BytesSerializableValueConverter(javaType); | converter = new BytesSerializableValueConverter(javaType); | ||||
converterMap.put(javaType, converter); | converterMap.put(javaType, converter); | ||||
return converter; | return converter; | ||||
@@ -367,7 +366,7 @@ public class DataContractContext { | |||||
EnumSpecificationInfo enumSpec = (EnumSpecificationInfo) fieldInfo.fieldSpec.getRefEnum(); | EnumSpecificationInfo enumSpec = (EnumSpecificationInfo) fieldInfo.fieldSpec.getRefEnum(); | ||||
int[] values = enumSpec.getItemValues(); | int[] values = enumSpec.getItemValues(); | ||||
Object[] constants = enumSpec.getConstants(); | Object[] constants = enumSpec.getConstants(); | ||||
ValueType codeType = enumSpec.getValueType(); | |||||
DataType codeType = enumSpec.getValueType(); | |||||
ValueConverter baseConverter = getPrimitiveTypeConverter(codeType, enumSpec.getDataType()); | ValueConverter baseConverter = getPrimitiveTypeConverter(codeType, enumSpec.getDataType()); | ||||
@@ -411,8 +410,8 @@ public class DataContractContext { | |||||
private static BinarySliceSpec buildSlice(FieldSpecInfo fieldSpec) { | private static BinarySliceSpec buildSlice(FieldSpecInfo fieldSpec) { | ||||
boolean fixed = false; | boolean fixed = false; | ||||
int len = -1; | int len = -1; | ||||
ValueType fixedValueType = null; | |||||
if (fieldSpec.getPrimitiveType() != null && fieldSpec.getPrimitiveType() != ValueType.NIL) { | |||||
DataType fixedValueType = null; | |||||
if (fieldSpec.getPrimitiveType() != null && fieldSpec.getPrimitiveType() != DataType.NIL) { | |||||
fixedValueType = fieldSpec.getPrimitiveType(); | fixedValueType = fieldSpec.getPrimitiveType(); | ||||
} else if (fieldSpec.getRefEnum() != null) { | } else if (fieldSpec.getRefEnum() != null) { | ||||
fixedValueType = fieldSpec.getRefEnum().getValueType(); | fixedValueType = fieldSpec.getRefEnum().getValueType(); | ||||
@@ -547,7 +546,7 @@ public class DataContractContext { | |||||
} | } | ||||
int maxSize = annoField.maxSize(); | int maxSize = annoField.maxSize(); | ||||
ValueType primitiveType = annoField.primitiveType(); | |||||
DataType primitiveType = annoField.primitiveType(); | |||||
if (primitiveType != null) { | if (primitiveType != null) { | ||||
primitiveType = verifyPrimitiveType(primitiveType, dataType, accessor); | primitiveType = verifyPrimitiveType(primitiveType, dataType, accessor); | ||||
} | } | ||||
@@ -651,7 +650,7 @@ public class DataContractContext { | |||||
* @param dataType | * @param dataType | ||||
* @return | * @return | ||||
*/ | */ | ||||
private static ValueType verifyPrimitiveType(ValueType primitiveType, Class<?> dataType, Method accessor) { | |||||
private static DataType verifyPrimitiveType(DataType primitiveType, Class<?> dataType, Method accessor) { | |||||
switch (primitiveType) { | switch (primitiveType) { | ||||
case NIL: | case NIL: | ||||
return null; | return null; | ||||
@@ -3,15 +3,15 @@ package com.jd.blockchain.binaryproto.impl; | |||||
import java.util.LinkedHashSet; | import java.util.LinkedHashSet; | ||||
import java.util.Set; | import java.util.Set; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumSpecification; | import com.jd.blockchain.binaryproto.EnumSpecification; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/6/21. | * Created by zhangshuang3 on 2018/6/21. | ||||
*/ | */ | ||||
public class EnumSpecificationInfo implements EnumSpecification { | public class EnumSpecificationInfo implements EnumSpecification { | ||||
private ValueType valueType; | |||||
private DataType valueType; | |||||
private Class<?> dataType; | private Class<?> dataType; | ||||
@@ -24,7 +24,7 @@ public class EnumSpecificationInfo implements EnumSpecification { | |||||
// private Map<Object, Object> itemCodeMapping = new HashMap<>(); | // private Map<Object, Object> itemCodeMapping = new HashMap<>(); | ||||
// private Map<Object, Object> codeItemMapping = new HashMap<>(); | // private Map<Object, Object> codeItemMapping = new HashMap<>(); | ||||
public EnumSpecificationInfo(ValueType valueType, int code, long version, String name, String description, Class<?> dataType) { | |||||
public EnumSpecificationInfo(DataType valueType, int code, long version, String name, String description, Class<?> dataType) { | |||||
this.valueType = valueType; | this.valueType = valueType; | ||||
this.code = code; | this.code = code; | ||||
this.version = version; | this.version = version; | ||||
@@ -54,7 +54,7 @@ public class EnumSpecificationInfo implements EnumSpecification { | |||||
} | } | ||||
@Override | @Override | ||||
public ValueType getValueType() { | |||||
public DataType getValueType() { | |||||
return this.valueType; | return this.valueType; | ||||
} | } | ||||
@@ -1,14 +1,14 @@ | |||||
package com.jd.blockchain.binaryproto.impl; | package com.jd.blockchain.binaryproto.impl; | ||||
import com.jd.blockchain.binaryproto.DataContractException; | import com.jd.blockchain.binaryproto.DataContractException; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.utils.io.BytesSlice; | import com.jd.blockchain.utils.io.BytesSlice; | ||||
public class EnumValueConverter implements FixedValueConverter { | public class EnumValueConverter implements FixedValueConverter { | ||||
private Class<?> enumType; | private Class<?> enumType; | ||||
private ValueType codeType; | |||||
private DataType codeType; | |||||
private int[] values; | private int[] values; | ||||
@@ -16,7 +16,7 @@ public class EnumValueConverter implements FixedValueConverter { | |||||
private FixedValueConverter valueConverter; | private FixedValueConverter valueConverter; | ||||
public EnumValueConverter(Class<?> enumType, ValueType codeType, int[] values, Object[] constants, FixedValueConverter valueConverter) { | |||||
public EnumValueConverter(Class<?> enumType, DataType codeType, int[] values, Object[] constants, FixedValueConverter valueConverter) { | |||||
this.enumType = enumType; | this.enumType = enumType; | ||||
this.values = values; | this.values = values; | ||||
this.constants = constants; | this.constants = constants; | ||||
@@ -1,9 +1,9 @@ | |||||
package com.jd.blockchain.binaryproto.impl; | package com.jd.blockchain.binaryproto.impl; | ||||
import com.jd.blockchain.binaryproto.DataSpecification; | import com.jd.blockchain.binaryproto.DataSpecification; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumSpecification; | import com.jd.blockchain.binaryproto.EnumSpecification; | ||||
import com.jd.blockchain.binaryproto.FieldSpec; | import com.jd.blockchain.binaryproto.FieldSpec; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
public class FieldSpecInfo implements FieldSpec { | public class FieldSpecInfo implements FieldSpec { | ||||
@@ -15,7 +15,7 @@ public class FieldSpecInfo implements FieldSpec { | |||||
private boolean repeatable; | private boolean repeatable; | ||||
private ValueType primitiveType; | |||||
private DataType primitiveType; | |||||
private EnumSpecification enumSpec; | private EnumSpecification enumSpec; | ||||
@@ -27,7 +27,7 @@ public class FieldSpecInfo implements FieldSpec { | |||||
private boolean isGenericContract = false; | private boolean isGenericContract = false; | ||||
public FieldSpecInfo(int order, String name, String decription, ValueType primitiveType, boolean repeatable, | |||||
public FieldSpecInfo(int order, String name, String decription, DataType primitiveType, boolean repeatable, | |||||
int maxSize, Class<?> dataType) { | int maxSize, Class<?> dataType) { | ||||
if (primitiveType == null) { | if (primitiveType == null) { | ||||
throw new IllegalArgumentException("primitiveType is null!"); | throw new IllegalArgumentException("primitiveType is null!"); | ||||
@@ -71,7 +71,7 @@ public class FieldSpecInfo implements FieldSpec { | |||||
} | } | ||||
@Override | @Override | ||||
public ValueType getPrimitiveType() { | |||||
public DataType getPrimitiveType() { | |||||
return primitiveType; | return primitiveType; | ||||
} | } | ||||
@@ -2,8 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.Bytes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/11/30. | * Created by zhangshuang3 on 2018/11/30. | ||||
@@ -11,7 +10,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = 0xc, name = "CompositeDatas", description = "") | @DataContract(code = 0xc, name = "CompositeDatas", description = "") | ||||
public interface CompositeDatas { | public interface CompositeDatas { | ||||
@DataField(order = 1, primitiveType = ValueType.BOOLEAN) | |||||
@DataField(order = 1, primitiveType = DataType.BOOLEAN) | |||||
boolean isEnable(); | boolean isEnable(); | ||||
@DataField(order = 2, refEnum = true) | @DataField(order = 2, refEnum = true) | ||||
@@ -23,7 +22,7 @@ public interface CompositeDatas { | |||||
@DataField(order=4, list = true, refContract=true, genericContract = true) | @DataField(order=4, list = true, refContract=true, genericContract = true) | ||||
Operation[] getOperations(); | Operation[] getOperations(); | ||||
@DataField(order = 5, primitiveType = ValueType.INT16) | |||||
@DataField(order = 5, primitiveType = DataType.INT16) | |||||
short getAge(); | short getAge(); | ||||
} | } |
@@ -1,8 +1,8 @@ | |||||
package test.com.jd.blockchain.binaryproto; | package test.com.jd.blockchain.binaryproto; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumContract; | import com.jd.blockchain.binaryproto.EnumContract; | ||||
import com.jd.blockchain.binaryproto.EnumField; | import com.jd.blockchain.binaryproto.EnumField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/11/29. | * Created by zhangshuang3 on 2018/11/29. | ||||
@@ -14,7 +14,7 @@ public enum EnumLevel { | |||||
V2((byte) 2); | V2((byte) 2); | ||||
@EnumField(type= ValueType.INT8) | |||||
@EnumField(type= DataType.INT8) | |||||
public final byte CODE; | public final byte CODE; | ||||
public byte getCode() { | public byte getCode() { | ||||
return CODE; | return CODE; | ||||
@@ -2,8 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.Bytes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/7/11. | * Created by zhangshuang3 on 2018/7/11. | ||||
@@ -11,22 +10,22 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = 0x06, name = "Primitive", description = "") | @DataContract(code = 0x06, name = "Primitive", description = "") | ||||
public interface FieldOrderConflictedDatas { | public interface FieldOrderConflictedDatas { | ||||
@DataField(order = 2, primitiveType = ValueType.BOOLEAN) | |||||
@DataField(order = 2, primitiveType = DataType.BOOLEAN) | |||||
boolean isEnable(); | boolean isEnable(); | ||||
@DataField(order = 3, primitiveType = ValueType.INT8) | |||||
@DataField(order = 3, primitiveType = DataType.INT8) | |||||
byte isBoy(); | byte isBoy(); | ||||
@DataField(order = 7, primitiveType = ValueType.INT16) | |||||
@DataField(order = 7, primitiveType = DataType.INT16) | |||||
short getAge(); | short getAge(); | ||||
@DataField(order = -1, primitiveType = ValueType.INT32) | |||||
@DataField(order = -1, primitiveType = DataType.INT32) | |||||
int getId(); | int getId(); | ||||
@DataField(order = 6, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 6, primitiveType = DataType.TEXT) | |||||
String getName(); | String getName(); | ||||
@DataField(order = 7, primitiveType = ValueType.INT64) | |||||
@DataField(order = 7, primitiveType = DataType.INT64) | |||||
long getValue(); | long getValue(); | ||||
@@ -2,8 +2,8 @@ package test.com.jd.blockchain.binaryproto; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.utils.net.NetworkAddress; | import com.jd.blockchain.utils.net.NetworkAddress; | ||||
/** | /** | ||||
@@ -12,37 +12,37 @@ import com.jd.blockchain.utils.net.NetworkAddress; | |||||
@DataContract(code = 0x05, name = "Primitive", description = "") | @DataContract(code = 0x05, name = "Primitive", description = "") | ||||
public interface PrimitiveDatas { | public interface PrimitiveDatas { | ||||
@DataField(order = 2, primitiveType = ValueType.BOOLEAN) | |||||
@DataField(order = 2, primitiveType = DataType.BOOLEAN) | |||||
boolean isEnable(); | boolean isEnable(); | ||||
@DataField(order = 3, primitiveType = ValueType.INT8) | |||||
@DataField(order = 3, primitiveType = DataType.INT8) | |||||
byte isBoy(); | byte isBoy(); | ||||
@DataField(order = 4, primitiveType = ValueType.INT16) | |||||
@DataField(order = 4, primitiveType = DataType.INT16) | |||||
short getAge(); | short getAge(); | ||||
@DataField(order = -1, primitiveType = ValueType.INT32) | |||||
@DataField(order = -1, primitiveType = DataType.INT32) | |||||
int getId(); | int getId(); | ||||
@DataField(order = 6, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 6, primitiveType = DataType.TEXT) | |||||
String getName(); | String getName(); | ||||
@DataField(order = 7, primitiveType = ValueType.INT64) | |||||
@DataField(order = 7, primitiveType = DataType.INT64) | |||||
long getValue(); | long getValue(); | ||||
@DataField(order = 12, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 12, primitiveType = DataType.BYTES) | |||||
byte[] getImage(); | byte[] getImage(); | ||||
@DataField(order = 100, primitiveType = ValueType.INT16) | |||||
@DataField(order = 100, primitiveType = DataType.INT16) | |||||
char getFlag(); | char getFlag(); | ||||
@DataField(order = 200, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 200, primitiveType = DataType.BYTES) | |||||
Bytes getConfig(); | Bytes getConfig(); | ||||
@DataField(order = 201, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 201, primitiveType = DataType.BYTES) | |||||
Bytes getSetting(); | Bytes getSetting(); | ||||
@DataField(order = 202, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 202, primitiveType = DataType.BYTES) | |||||
NetworkAddress getNetworkAddr(); | NetworkAddress getNetworkAddr(); | ||||
} | } |
@@ -2,7 +2,6 @@ package test.com.jd.blockchain.binaryproto; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/11/29. | * Created by zhangshuang3 on 2018/11/29. | ||||
@@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/11/29. | * Created by zhangshuang3 on 2018/11/29. | ||||
@@ -10,7 +10,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = 0xa, name = "SubOperation", description = "") | @DataContract(code = 0xa, name = "SubOperation", description = "") | ||||
public interface SubOperation extends Operation { | public interface SubOperation extends Operation { | ||||
@DataField(order=1, primitiveType = ValueType.TEXT) | |||||
@DataField(order=1, primitiveType = DataType.TEXT) | |||||
String getUserName(); | String getUserName(); | ||||
} | } |
@@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/7/9. | * Created by zhangshuang3 on 2018/7/9. | ||||
@@ -10,10 +10,10 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code=0x02, name="Address" , description="") | @DataContract(code=0x02, name="Address" , description="") | ||||
public interface AddressCodeDuplicate { | public interface AddressCodeDuplicate { | ||||
@DataField(order=1, primitiveType= ValueType.TEXT) | |||||
@DataField(order=1, primitiveType= DataType.TEXT) | |||||
String getStreet(); | String getStreet(); | ||||
@DataField(order=2, primitiveType=ValueType.INT32) | |||||
@DataField(order=2, primitiveType=DataType.INT32) | |||||
int getNumber(); | int getNumber(); | ||||
} | } |
@@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/7/9. | * Created by zhangshuang3 on 2018/7/9. | ||||
@@ -10,10 +10,10 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code=0x03, name="Address" , description="") | @DataContract(code=0x03, name="Address" , description="") | ||||
public interface AddressOrderDuplicate { | public interface AddressOrderDuplicate { | ||||
@DataField(order=1, primitiveType= ValueType.TEXT) | |||||
@DataField(order=1, primitiveType= DataType.TEXT) | |||||
String getStreet(); | String getStreet(); | ||||
@DataField(order=1, primitiveType=ValueType.INT32) | |||||
@DataField(order=1, primitiveType=DataType.INT32) | |||||
int getNumber(); | int getNumber(); | ||||
} | } |
@@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/7/11. | * Created by zhangshuang3 on 2018/7/11. | ||||
@@ -10,16 +10,16 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code=0x08, name="Array" , description="") | @DataContract(code=0x08, name="Array" , description="") | ||||
public interface Array { | public interface Array { | ||||
@DataField(order=1, primitiveType= ValueType.INT32, list=true) | |||||
@DataField(order=1, primitiveType= DataType.INT32, list=true) | |||||
int[] getScores(); | int[] getScores(); | ||||
@DataField(order=2, primitiveType=ValueType.TEXT, list=true) | |||||
@DataField(order=2, primitiveType=DataType.TEXT, list=true) | |||||
String[] getFeatures(); | String[] getFeatures(); | ||||
@DataField(order=3, primitiveType=ValueType.BYTES) | |||||
@DataField(order=3, primitiveType=DataType.BYTES) | |||||
byte[] getFamilyMemberAges(); | byte[] getFamilyMemberAges(); | ||||
@DataField(order=4, primitiveType=ValueType.INT64, list=true) | |||||
@DataField(order=4, primitiveType=DataType.INT64, list=true) | |||||
long[] getFamilyMemberIds(); | long[] getFamilyMemberIds(); | ||||
} | } |
@@ -1,8 +1,8 @@ | |||||
package test.com.jd.blockchain.binaryproto.contract; | package test.com.jd.blockchain.binaryproto.contract; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumContract; | import com.jd.blockchain.binaryproto.EnumContract; | ||||
import com.jd.blockchain.binaryproto.EnumField; | import com.jd.blockchain.binaryproto.EnumField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@EnumContract(code=0x0100) | @EnumContract(code=0x0100) | ||||
public enum Level { | public enum Level { | ||||
@@ -11,7 +11,7 @@ public enum Level { | |||||
V2((byte) 2); | V2((byte) 2); | ||||
@EnumField(type=ValueType.INT8) | |||||
@EnumField(type=DataType.INT8) | |||||
public final byte CODE; | public final byte CODE; | ||||
public byte getCode() { | public byte getCode() { | ||||
return CODE; | return CODE; | ||||
@@ -2,7 +2,7 @@ package test.com.jd.blockchain.binaryproto.contract; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
/** | /** | ||||
* Created by zhangshuang3 on 2018/7/30. | * Created by zhangshuang3 on 2018/7/30. | ||||
@@ -10,7 +10,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code=0x0f, name="PrivilegeModelSetting", description ="Privilege Model setting") | @DataContract(code=0x0f, name="PrivilegeModelSetting", description ="Privilege Model setting") | ||||
public interface PrivilegeModelSetting { | public interface PrivilegeModelSetting { | ||||
@DataField(order=1, primitiveType= ValueType.INT64) | |||||
@DataField(order=1, primitiveType= DataType.INT64) | |||||
long getLatestVersion(); | long getLatestVersion(); | ||||
//@DataField(order=2, refContract=true) | //@DataField(order=2, refContract=true) | ||||
@@ -2,21 +2,21 @@ package com.jd.blockchain.consensus.bftsmart; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consensus.ClientIncomingSettings; | import com.jd.blockchain.consensus.ClientIncomingSettings; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = TypeCodes.CONSENSUS_BFTSMART_CLI_INCOMING_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_BFTSMART_CLI_INCOMING_SETTINGS) | |||||
public interface BftsmartClientIncomingSettings extends ClientIncomingSettings { | public interface BftsmartClientIncomingSettings extends ClientIncomingSettings { | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
byte[] getTopology(); | byte[] getTopology(); | ||||
@DataField(order = 2, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 2, primitiveType = DataType.BYTES) | |||||
byte[] getTomConfig(); | byte[] getTomConfig(); | ||||
@DataField(order = 3, primitiveType=ValueType.BYTES) | |||||
@DataField(order = 3, primitiveType=DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
} | } |
@@ -2,16 +2,16 @@ package com.jd.blockchain.consensus.bftsmart; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code = TypeCodes.CONSENSUS_BFTSMART_BLOCK_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_BFTSMART_BLOCK_SETTINGS) | |||||
public interface BftsmartCommitBlockSettings { | public interface BftsmartCommitBlockSettings { | ||||
@DataField(order = 0, primitiveType = ValueType.INT32) | |||||
@DataField(order = 0, primitiveType = DataType.INT32) | |||||
int getTxSizePerBlock(); | int getTxSizePerBlock(); | ||||
@DataField(order = 1, primitiveType = ValueType.INT64) | |||||
@DataField(order = 1, primitiveType = DataType.INT64) | |||||
long getMaxDelayMilliSecondsPerBlock(); | long getMaxDelayMilliSecondsPerBlock(); | ||||
} | } |
@@ -2,16 +2,16 @@ package com.jd.blockchain.consensus.bftsmart; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consensus.ConsensusSettings; | import com.jd.blockchain.consensus.ConsensusSettings; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.Property; | import com.jd.blockchain.utils.Property; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils; | import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils; | ||||
@DataContract(code = TypeCodes.CONSENSUS_BFTSMART_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_BFTSMART_SETTINGS) | |||||
public interface BftsmartConsensusSettings extends ConsensusSettings { | public interface BftsmartConsensusSettings extends ConsensusSettings { | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES, list=true) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES, list=true) | |||||
Property[] getSystemConfigs(); | Property[] getSystemConfigs(); | ||||
@DataField(order = 2, refContract = true) | @DataField(order = 2, refContract = true) | ||||
@@ -2,13 +2,13 @@ package com.jd.blockchain.consensus.bftsmart; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consensus.NodeSettings; | import com.jd.blockchain.consensus.NodeSettings; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.utils.net.NetworkAddress; | import com.jd.blockchain.utils.net.NetworkAddress; | ||||
@DataContract(code = TypeCodes.CONSENSUS_BFTSMART_NODE_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_BFTSMART_NODE_SETTINGS) | |||||
public interface BftsmartNodeSettings extends NodeSettings { | public interface BftsmartNodeSettings extends NodeSettings { | ||||
/** | /** | ||||
@@ -31,7 +31,7 @@ public interface BftsmartNodeSettings extends NodeSettings { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 2, primitiveType = ValueType.INT32) | |||||
@DataField(order = 2, primitiveType = DataType.INT32) | |||||
int getId(); | int getId(); | ||||
/** | /** | ||||
@@ -39,7 +39,7 @@ public interface BftsmartNodeSettings extends NodeSettings { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 3, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 3, primitiveType = DataType.BYTES) | |||||
NetworkAddress getNetworkAddress(); | NetworkAddress getNetworkAddress(); | ||||
} | } |
@@ -2,10 +2,10 @@ package com.jd.blockchain.consensus; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.crypto.SignatureDigest; | import com.jd.blockchain.crypto.SignatureDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 客户端的身份证明; | * 客户端的身份证明; | ||||
@@ -13,7 +13,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CLIENT_IDENTIFICATION) | |||||
@DataContract(code = DataCodes.CLIENT_IDENTIFICATION) | |||||
public interface ClientIdentification { | public interface ClientIdentification { | ||||
/** | /** | ||||
@@ -21,7 +21,7 @@ public interface ClientIdentification { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 0, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 0, primitiveType = DataType.BYTES) | |||||
byte[] getIdentityInfo(); | byte[] getIdentityInfo(); | ||||
/** | /** | ||||
@@ -29,7 +29,7 @@ public interface ClientIdentification { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
/** | /** | ||||
@@ -37,7 +37,7 @@ public interface ClientIdentification { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 2, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 2, primitiveType = DataType.BYTES) | |||||
SignatureDigest getSignature(); | SignatureDigest getSignature(); | ||||
/** | /** | ||||
@@ -45,6 +45,6 @@ public interface ClientIdentification { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 3, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 3, primitiveType = DataType.TEXT) | |||||
String getProviderName(); | String getProviderName(); | ||||
} | } |
@@ -10,7 +10,7 @@ package com.jd.blockchain.consensus; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* | * | ||||
@@ -18,7 +18,7 @@ import com.jd.blockchain.consts.TypeCodes; | |||||
* @create 2018/12/19 | * @create 2018/12/19 | ||||
* @since 1.0.0 | * @since 1.0.0 | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CLIENT_IDENTIFICATIONS) | |||||
@DataContract(code = DataCodes.CLIENT_IDENTIFICATIONS) | |||||
public interface ClientIdentifications { | public interface ClientIdentifications { | ||||
@DataField(order = 0, list = true, refContract = true, genericContract = true) | @DataField(order = 0, list = true, refContract = true, genericContract = true) | ||||
@@ -2,8 +2,8 @@ package com.jd.blockchain.consensus; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 共识网络的客户接入参数; | * 共识网络的客户接入参数; | ||||
@@ -11,7 +11,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CONSENSUS_CLI_INCOMING_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_CLI_INCOMING_SETTINGS) | |||||
public interface ClientIncomingSettings { | public interface ClientIncomingSettings { | ||||
/** | /** | ||||
@@ -19,7 +19,7 @@ public interface ClientIncomingSettings { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 0, primitiveType = ValueType.INT32) | |||||
@DataField(order = 0, primitiveType = DataType.INT32) | |||||
int getClientId(); | int getClientId(); | ||||
/** | /** | ||||
@@ -27,7 +27,7 @@ public interface ClientIncomingSettings { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 1, primitiveType = DataType.TEXT) | |||||
String getProviderName(); | String getProviderName(); | ||||
/** | /** | ||||
@@ -2,7 +2,7 @@ package com.jd.blockchain.consensus; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 共识网络的配置参数; | * 共识网络的配置参数; | ||||
@@ -10,7 +10,7 @@ import com.jd.blockchain.consts.TypeCodes; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CONSENSUS_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_SETTINGS) | |||||
public interface ConsensusSettings { | public interface ConsensusSettings { | ||||
/** | /** | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.consensus; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 节点的配置参数; | * 节点的配置参数; | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code=TypeCodes.CONSENSUS_NODE_SETTINGS) | |||||
@DataContract(code=DataCodes.CONSENSUS_NODE_SETTINGS) | |||||
public interface NodeSettings { | public interface NodeSettings { | ||||
/** | /** | ||||
@@ -22,7 +22,7 @@ public interface NodeSettings { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=0, primitiveType=ValueType.TEXT) | |||||
@DataField(order=0, primitiveType=DataType.TEXT) | |||||
String getAddress(); | String getAddress(); | ||||
/** | /** | ||||
@@ -30,6 +30,6 @@ public interface NodeSettings { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
} | } |
@@ -2,27 +2,27 @@ package com.jd.blockchain.consensus.action; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.CONSENSUS_ACTION_REQUEST) | |||||
@DataContract(code= DataCodes.CONSENSUS_ACTION_REQUEST) | |||||
public interface ActionRequest { | public interface ActionRequest { | ||||
@DataField(order=1, list=true, primitiveType= ValueType.INT8) | |||||
@DataField(order=1, list=true, primitiveType= DataType.INT8) | |||||
byte[] getGroupId(); | byte[] getGroupId(); | ||||
@DataField(order=2, primitiveType=ValueType.TEXT) | |||||
@DataField(order=2, primitiveType=DataType.TEXT) | |||||
String getHandleType(); | String getHandleType(); | ||||
@DataField(order=3, primitiveType=ValueType.TEXT) | |||||
@DataField(order=3, primitiveType=DataType.TEXT) | |||||
String getHandleMethod(); | String getHandleMethod(); | ||||
// String getMessageType(); | // String getMessageType(); | ||||
@DataField(order=4, list=true, primitiveType= ValueType.INT8) | |||||
@DataField(order=4, list=true, primitiveType= DataType.INT8) | |||||
byte[] getMessageBody(); | byte[] getMessageBody(); | ||||
@DataField(order=5, primitiveType= ValueType.TEXT) | |||||
@DataField(order=5, primitiveType= DataType.TEXT) | |||||
String getTransactionType(); | String getTransactionType(); | ||||
// String getReponseType(); | // String getReponseType(); | ||||
@@ -2,22 +2,22 @@ package com.jd.blockchain.consensus.action; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.CONSENSUS_ACTION_RESPONSE) | |||||
@DataContract(code= DataCodes.CONSENSUS_ACTION_RESPONSE) | |||||
public interface ActionResponse { | public interface ActionResponse { | ||||
@DataField(order=1, list=true, primitiveType= ValueType.INT8) | |||||
@DataField(order=1, list=true, primitiveType= DataType.INT8) | |||||
byte[] getMessage(); | byte[] getMessage(); | ||||
@DataField(order=2, primitiveType=ValueType.BOOLEAN) | |||||
@DataField(order=2, primitiveType=DataType.BOOLEAN) | |||||
boolean getError(); | boolean getError(); | ||||
@DataField(order=3, primitiveType=ValueType.TEXT) | |||||
@DataField(order=3, primitiveType=DataType.TEXT) | |||||
String getErrorMessage(); | String getErrorMessage(); | ||||
@DataField(order=4, primitiveType=ValueType.TEXT) | |||||
@DataField(order=4, primitiveType=DataType.TEXT) | |||||
String getErrorType(); | String getErrorType(); | ||||
} | } |
@@ -10,8 +10,8 @@ package com.jd.blockchain.consensus.mq.settings; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* | * | ||||
@@ -19,12 +19,12 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @create 2018/12/13 | * @create 2018/12/13 | ||||
* @since 1.0.0 | * @since 1.0.0 | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CONSENSUS_MSGQUEUE_BLOCK_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_BLOCK_SETTINGS) | |||||
public interface MsgQueueBlockSettings { | public interface MsgQueueBlockSettings { | ||||
@DataField(order = 0, primitiveType = ValueType.INT32) | |||||
@DataField(order = 0, primitiveType = DataType.INT32) | |||||
int getTxSizePerBlock(); | int getTxSizePerBlock(); | ||||
@DataField(order = 1, primitiveType = ValueType.INT64) | |||||
@DataField(order = 1, primitiveType = DataType.INT64) | |||||
long getMaxDelayMilliSecondsPerBlock(); | long getMaxDelayMilliSecondsPerBlock(); | ||||
} | } |
@@ -10,11 +10,11 @@ package com.jd.blockchain.consensus.mq.settings; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consensus.ClientIncomingSettings; | import com.jd.blockchain.consensus.ClientIncomingSettings; | ||||
import com.jd.blockchain.consensus.ConsensusSettings; | import com.jd.blockchain.consensus.ConsensusSettings; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* | * | ||||
@@ -22,9 +22,9 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @create 2018/12/13 | * @create 2018/12/13 | ||||
* @since 1.0.0 | * @since 1.0.0 | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CONSENSUS_MSGQUEUE_CLI_INCOMING_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_CLI_INCOMING_SETTINGS) | |||||
public interface MsgQueueClientIncomingSettings extends ClientIncomingSettings { | public interface MsgQueueClientIncomingSettings extends ClientIncomingSettings { | ||||
@DataField(order = 1, primitiveType=ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType=DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
} | } |
@@ -10,11 +10,11 @@ package com.jd.blockchain.consensus.mq.settings; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consensus.ConsensusSettings; | import com.jd.blockchain.consensus.ConsensusSettings; | ||||
import com.jd.blockchain.consensus.mq.config.MsgQueueBlockConfig; | import com.jd.blockchain.consensus.mq.config.MsgQueueBlockConfig; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.Property; | import com.jd.blockchain.utils.Property; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* | * | ||||
@@ -22,7 +22,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @create 2018/12/13 | * @create 2018/12/13 | ||||
* @since 1.0.0 | * @since 1.0.0 | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CONSENSUS_MSGQUEUE_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_SETTINGS) | |||||
public interface MsgQueueConsensusSettings extends ConsensusSettings { | public interface MsgQueueConsensusSettings extends ConsensusSettings { | ||||
@DataField(order = 0, refContract = true) | @DataField(order = 0, refContract = true) | ||||
@@ -10,8 +10,8 @@ package com.jd.blockchain.consensus.mq.settings; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* | * | ||||
@@ -19,18 +19,18 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @create 2018/12/12 | * @create 2018/12/12 | ||||
* @since 1.0.0 | * @since 1.0.0 | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.CONSENSUS_MSGQUEUE_NETWORK_SETTINGS) | |||||
@DataContract(code = DataCodes.CONSENSUS_MSGQUEUE_NETWORK_SETTINGS) | |||||
public interface MsgQueueNetworkSettings { | public interface MsgQueueNetworkSettings { | ||||
@DataField(order = 0, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 0, primitiveType = DataType.TEXT) | |||||
String getServer(); | String getServer(); | ||||
@DataField(order = 1, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 1, primitiveType = DataType.TEXT) | |||||
String getTxTopic(); | String getTxTopic(); | ||||
@DataField(order = 2, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 2, primitiveType = DataType.TEXT) | |||||
String getBlTopic(); | String getBlTopic(); | ||||
@DataField(order = 3, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 3, primitiveType = DataType.TEXT) | |||||
String getMsgTopic(); | String getMsgTopic(); | ||||
} | } |
@@ -10,7 +10,7 @@ package com.jd.blockchain.consensus.mq.settings; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.consensus.NodeSettings; | import com.jd.blockchain.consensus.NodeSettings; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* | * | ||||
@@ -19,7 +19,7 @@ import com.jd.blockchain.consts.TypeCodes; | |||||
* @since 1.0.0 | * @since 1.0.0 | ||||
*/ | */ | ||||
@DataContract(code=TypeCodes.CONSENSUS_MSGQUEUE_NODE_SETTINGS) | |||||
@DataContract(code=DataCodes.CONSENSUS_MSGQUEUE_NODE_SETTINGS) | |||||
public interface MsgQueueNodeSettings extends NodeSettings { | public interface MsgQueueNodeSettings extends NodeSettings { | ||||
} | } |
@@ -5,11 +5,11 @@ import java.io.OutputStream; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.io.BytesUtils; | import com.jd.blockchain.utils.io.BytesUtils; | ||||
@DataContract(code = TypeCodes.CRYPTO_ALGORITHM) | |||||
@DataContract(code = DataCodes.CRYPTO_ALGORITHM) | |||||
public interface CryptoAlgorithm { | public interface CryptoAlgorithm { | ||||
/** | /** | ||||
@@ -63,7 +63,7 @@ public interface CryptoAlgorithm { | |||||
* {@link #EXT_ALGORITHM}) 5 种); 接下来4位标识密钥类型(包括:{@link #SYMMETRIC_KEY}, | * {@link #EXT_ALGORITHM}) 5 种); 接下来4位标识密钥类型(包括:{@link #SYMMETRIC_KEY}, | ||||
* {@link #ASYMMETRIC_KEY}); 最后8位是算法唯一ID; | * {@link #ASYMMETRIC_KEY}); 最后8位是算法唯一ID; | ||||
*/ | */ | ||||
@DataField(primitiveType = ValueType.INT16, order = 0) | |||||
@DataField(primitiveType = DataType.INT16, order = 0) | |||||
short code(); | short code(); | ||||
/** | /** | ||||
@@ -1,6 +1,7 @@ | |||||
package com.jd.blockchain.ledger.core; | package com.jd.blockchain.ledger.core; | ||||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.ledger.AccountHeader; | import com.jd.blockchain.ledger.AccountHeader; | ||||
@@ -8,7 +9,6 @@ import com.jd.blockchain.ledger.BytesValue; | |||||
import com.jd.blockchain.ledger.KVDataEntry; | import com.jd.blockchain.ledger.KVDataEntry; | ||||
import com.jd.blockchain.ledger.KVDataObject; | import com.jd.blockchain.ledger.KVDataObject; | ||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils; | import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils; | ||||
public class DataAccount implements AccountHeader, MerkleProvable { | public class DataAccount implements AccountHeader, MerkleProvable { | ||||
@@ -142,7 +142,7 @@ public class DataAccount implements AccountHeader, MerkleProvable { | |||||
key = baseAccount.dataset.getKeyAtIndex(fromIndex); | key = baseAccount.dataset.getKeyAtIndex(fromIndex); | ||||
ver = baseAccount.dataset.getVersion(key); | ver = baseAccount.dataset.getVersion(key); | ||||
BytesValue decodeData = BinaryEncodingUtils.decode(value); | BytesValue decodeData = BinaryEncodingUtils.decode(value); | ||||
kvDataEntries[i] = new KVDataObject(key, ver, ValueType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||||
kvDataEntries[i] = new KVDataObject(key, ver, DataType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||||
fromIndex++; | fromIndex++; | ||||
} | } | ||||
@@ -2,10 +2,10 @@ package com.jd.blockchain.ledger.core; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.crypto.SignatureDigest; | import com.jd.blockchain.crypto.SignatureDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 账本初始化决定; | * 账本初始化决定; | ||||
@@ -13,7 +13,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.METADATA_INIT_DECISION) | |||||
@DataContract(code = DataCodes.METADATA_INIT_DECISION) | |||||
public interface LedgerInitDecision { | public interface LedgerInitDecision { | ||||
/** | /** | ||||
@@ -21,14 +21,14 @@ public interface LedgerInitDecision { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=1, primitiveType=ValueType.INT32) | |||||
@DataField(order=1, primitiveType=DataType.INT32) | |||||
int getParticipantId(); | int getParticipantId(); | ||||
/** | /** | ||||
* 新建账本的哈希; | * 新建账本的哈希; | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=2, primitiveType = ValueType.BYTES) | |||||
@DataField(order=2, primitiveType = DataType.BYTES) | |||||
HashDigest getLedgerHash(); | HashDigest getLedgerHash(); | ||||
/** | /** | ||||
@@ -40,7 +40,7 @@ public interface LedgerInitDecision { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=3, primitiveType = ValueType.BYTES) | |||||
@DataField(order=3, primitiveType = DataType.BYTES) | |||||
SignatureDigest getSignature(); | SignatureDigest getSignature(); | ||||
} | } |
@@ -2,10 +2,10 @@ package com.jd.blockchain.ledger.core; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.SignatureDigest; | import com.jd.blockchain.crypto.SignatureDigest; | ||||
import com.jd.blockchain.ledger.LedgerInitOperation; | import com.jd.blockchain.ledger.LedgerInitOperation; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 账本初始化许可; | * 账本初始化许可; | ||||
@@ -13,7 +13,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.METADATA_INIT_PERMISSION) | |||||
@DataContract(code = DataCodes.METADATA_INIT_PERMISSION) | |||||
public interface LedgerInitPermission { | public interface LedgerInitPermission { | ||||
/** | /** | ||||
@@ -21,7 +21,7 @@ public interface LedgerInitPermission { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.INT32) | |||||
@DataField(order = 1, primitiveType = DataType.INT32) | |||||
int getParticipantId(); | int getParticipantId(); | ||||
/** | /** | ||||
@@ -39,7 +39,7 @@ public interface LedgerInitPermission { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 2, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 2, primitiveType = DataType.BYTES) | |||||
SignatureDigest getTransactionSignature(); | SignatureDigest getTransactionSignature(); | ||||
} | } |
@@ -2,11 +2,11 @@ package com.jd.blockchain.ledger.core; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = TypeCodes.METADATA) | |||||
@DataContract(code = DataCodes.METADATA) | |||||
public interface LedgerMetadata { | public interface LedgerMetadata { | ||||
/** | /** | ||||
@@ -14,7 +14,7 @@ public interface LedgerMetadata { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
byte[] getSeed(); | byte[] getSeed(); | ||||
/** | /** | ||||
@@ -22,7 +22,7 @@ public interface LedgerMetadata { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 2, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 2, primitiveType = DataType.BYTES) | |||||
HashDigest getParticipantsHash(); | HashDigest getParticipantsHash(); | ||||
/** | /** | ||||
@@ -2,18 +2,18 @@ package com.jd.blockchain.ledger.core; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.ledger.CryptoSetting; | import com.jd.blockchain.ledger.CryptoSetting; | ||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = TypeCodes.METADATA_LEDGER_SETTING) | |||||
@DataContract(code = DataCodes.METADATA_LEDGER_SETTING) | |||||
public interface LedgerSetting { | public interface LedgerSetting { | ||||
@DataField(order=0, primitiveType=ValueType.TEXT) | |||||
@DataField(order=0, primitiveType=DataType.TEXT) | |||||
String getConsensusProvider(); | String getConsensusProvider(); | ||||
@DataField(order=1, primitiveType=ValueType.BYTES) | |||||
@DataField(order=1, primitiveType=DataType.BYTES) | |||||
Bytes getConsensusSetting(); | Bytes getConsensusSetting(); | ||||
@DataField(order=2, refContract=true) | @DataField(order=2, refContract=true) | ||||
@@ -1,6 +1,7 @@ | |||||
package com.jd.blockchain.ledger.core.impl; | package com.jd.blockchain.ledger.core.impl; | ||||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.ledger.AccountHeader; | import com.jd.blockchain.ledger.AccountHeader; | ||||
import com.jd.blockchain.ledger.BytesValue; | import com.jd.blockchain.ledger.BytesValue; | ||||
@@ -23,7 +24,6 @@ import com.jd.blockchain.ledger.core.UserAccountSet; | |||||
import com.jd.blockchain.transaction.BlockchainQueryService; | import com.jd.blockchain.transaction.BlockchainQueryService; | ||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.QueryUtil; | import com.jd.blockchain.utils.QueryUtil; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
public class LedgerQueryService implements BlockchainQueryService { | public class LedgerQueryService implements BlockchainQueryService { | ||||
@@ -271,11 +271,11 @@ public class LedgerQueryService implements BlockchainQueryService { | |||||
for (int i = 0; i < entries.length; i++) { | for (int i = 0; i < entries.length; i++) { | ||||
ver = dataAccount.getDataVersion(Bytes.fromString(keys[i])); | ver = dataAccount.getDataVersion(Bytes.fromString(keys[i])); | ||||
if (ver < 0) { | if (ver < 0) { | ||||
entries[i] = new KVDataObject(keys[i], -1, ValueType.NIL, null); | |||||
entries[i] = new KVDataObject(keys[i], -1, DataType.NIL, null); | |||||
}else { | }else { | ||||
byte[] value = dataAccount.getBytes(Bytes.fromString(keys[i]), ver); | byte[] value = dataAccount.getBytes(Bytes.fromString(keys[i]), ver); | ||||
BytesValue decodeData = BinaryEncodingUtils.decode(value); | BytesValue decodeData = BinaryEncodingUtils.decode(value); | ||||
entries[i] = new KVDataObject(keys[i], ver, ValueType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||||
entries[i] = new KVDataObject(keys[i], ver, DataType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||||
} | } | ||||
} | } | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.ledger.BytesValue; | |||||
import com.jd.blockchain.ledger.BytesValueImpl; | import com.jd.blockchain.ledger.BytesValueImpl; | ||||
import com.jd.blockchain.ledger.DataAccountKVSetOperation; | import com.jd.blockchain.ledger.DataAccountKVSetOperation; | ||||
import com.jd.blockchain.ledger.DataAccountRegisterOperation; | import com.jd.blockchain.ledger.DataAccountRegisterOperation; | ||||
import com.jd.blockchain.ledger.DataType; | |||||
import com.jd.blockchain.ledger.BytesValueType; | |||||
import com.jd.blockchain.ledger.KVDataEntry; | import com.jd.blockchain.ledger.KVDataEntry; | ||||
import com.jd.blockchain.ledger.LedgerBlock; | import com.jd.blockchain.ledger.LedgerBlock; | ||||
import com.jd.blockchain.ledger.LedgerInfo; | import com.jd.blockchain.ledger.LedgerInfo; | ||||
@@ -273,7 +273,7 @@ public class ContractLedgerContext implements LedgerContext { | |||||
@Override | @Override | ||||
public DataAccountKVSetOperationBuilder set(String key, byte[] value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, byte[] value, long expVersion) { | ||||
BytesValue bytesValue = new BytesValueImpl(DataType.BYTES, value); | |||||
BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value); | |||||
this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | ||||
generatedOpList.add(op); | generatedOpList.add(op); | ||||
opHandleContext.handle(op); | opHandleContext.handle(op); | ||||
@@ -283,10 +283,10 @@ public class ContractLedgerContext implements LedgerContext { | |||||
public DataAccountKVSetOperationBuilder set(String key, String value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, String value, long expVersion) { | ||||
BytesValue bytesValue; | BytesValue bytesValue; | ||||
if (isJson(value)) { | if (isJson(value)) { | ||||
bytesValue = new BytesValueImpl(DataType.JSON, value.getBytes()); | |||||
bytesValue = new BytesValueImpl(BytesValueType.JSON, value.getBytes()); | |||||
} | } | ||||
else { | else { | ||||
bytesValue = new BytesValueImpl(DataType.TEXT, value.getBytes()); | |||||
bytesValue = new BytesValueImpl(BytesValueType.TEXT, value.getBytes()); | |||||
} | } | ||||
this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | ||||
generatedOpList.add(op); | generatedOpList.add(op); | ||||
@@ -295,7 +295,7 @@ public class ContractLedgerContext implements LedgerContext { | |||||
} | } | ||||
@Override | @Override | ||||
public DataAccountKVSetOperationBuilder set(String key, Bytes value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, Bytes value, long expVersion) { | ||||
BytesValue bytesValue = new BytesValueImpl(DataType.BYTES, value.toBytes()); | |||||
BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value.toBytes()); | |||||
this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | ||||
generatedOpList.add(op); | generatedOpList.add(op); | ||||
opHandleContext.handle(op); | opHandleContext.handle(op); | ||||
@@ -303,7 +303,7 @@ public class ContractLedgerContext implements LedgerContext { | |||||
} | } | ||||
@Override | @Override | ||||
public DataAccountKVSetOperationBuilder set(String key, long value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, long value, long expVersion) { | ||||
BytesValue bytesValue = new BytesValueImpl(DataType.INT64, BytesUtils.toBytes(value)); | |||||
BytesValue bytesValue = new BytesValueImpl(BytesValueType.INT64, BytesUtils.toBytes(value)); | |||||
this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | this.op = new SingleKVSetOpTemplate(key, bytesValue, expVersion); | ||||
generatedOpList.add(op); | generatedOpList.add(op); | ||||
opHandleContext.handle(op); | opHandleContext.handle(op); | ||||
@@ -2,22 +2,22 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code= TypeCodes.ACCOUNT_HEADER) | |||||
@DataContract(code= DataCodes.ACCOUNT_HEADER) | |||||
public interface AccountHeader { | public interface AccountHeader { | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
Bytes getAddress(); | Bytes getAddress(); | ||||
@DataField(order=2, primitiveType = ValueType.BYTES) | |||||
@DataField(order=2, primitiveType = DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
@DataField(order=3, primitiveType = ValueType.BYTES) | |||||
@DataField(order=3, primitiveType = DataType.BYTES) | |||||
HashDigest getRootHash(); | HashDigest getRootHash(); | ||||
} | } |
@@ -2,22 +2,22 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code= TypeCodes.BLOCK_BODY) | |||||
@DataContract(code= DataCodes.BLOCK_BODY) | |||||
public interface BlockBody extends LedgerDataSnapshot{ | public interface BlockBody extends LedgerDataSnapshot{ | ||||
@DataField(order=2, primitiveType = ValueType.BYTES) | |||||
@DataField(order=2, primitiveType = DataType.BYTES) | |||||
HashDigest getPreviousHash(); | HashDigest getPreviousHash(); | ||||
@DataField(order=3, primitiveType = ValueType.BYTES) | |||||
@DataField(order=3, primitiveType = DataType.BYTES) | |||||
HashDigest getLedgerHash(); | HashDigest getLedgerHash(); | ||||
@DataField(order=4, primitiveType= ValueType.INT64) | |||||
@DataField(order=4, primitiveType= DataType.INT64) | |||||
long getHeight(); | long getHeight(); | ||||
@DataField(order=5, primitiveType = ValueType.BYTES) | |||||
@DataField(order=5, primitiveType = DataType.BYTES) | |||||
HashDigest getTransactionSetHash(); | HashDigest getTransactionSetHash(); | ||||
} | } |
@@ -2,18 +2,18 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code= TypeCodes.BLOCK_CHAIN_IDENTITY) | |||||
@DataContract(code= DataCodes.BLOCK_CHAIN_IDENTITY) | |||||
public interface BlockchainIdentity { | public interface BlockchainIdentity { | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
Bytes getAddress(); | Bytes getAddress(); | ||||
@DataField(order = 2, primitiveType=ValueType.BYTES) | |||||
@DataField(order = 2, primitiveType=DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
} | } |
@@ -2,11 +2,11 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.io.BytesSlice; | import com.jd.blockchain.utils.io.BytesSlice; | ||||
@DataContract(code = TypeCodes.BYTES_VALUE) | |||||
@DataContract(code = DataCodes.BYTES_VALUE) | |||||
public interface BytesValue { | public interface BytesValue { | ||||
/** | /** | ||||
@@ -15,14 +15,14 @@ public interface BytesValue { | |||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 0, refEnum = true) | @DataField(order = 0, refEnum = true) | ||||
DataType getType(); | |||||
BytesValueType getType(); | |||||
/** | /** | ||||
* 数据值的二进制序列; | * 数据值的二进制序列; | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
BytesSlice getValue(); | BytesSlice getValue(); | ||||
} | } |
@@ -6,20 +6,20 @@ import com.jd.blockchain.utils.io.BytesSlice; | |||||
* Created by zhangshuang3 on 2018/12/3. | * Created by zhangshuang3 on 2018/12/3. | ||||
*/ | */ | ||||
public class BytesValueImpl implements BytesValue{ | public class BytesValueImpl implements BytesValue{ | ||||
DataType type; | |||||
BytesValueType type; | |||||
BytesSlice slice; | BytesSlice slice; | ||||
public BytesValueImpl(DataType type, byte[] bytes) { | |||||
public BytesValueImpl(BytesValueType type, byte[] bytes) { | |||||
this.type = type; | this.type = type; | ||||
this.slice = new BytesSlice(bytes); | this.slice = new BytesSlice(bytes); | ||||
} | } | ||||
@Override | @Override | ||||
public DataType getType() { | |||||
public BytesValueType getType() { | |||||
return this.type; | return this.type; | ||||
} | } | ||||
public void setType(DataType type) { | |||||
public void setType(BytesValueType type) { | |||||
this.type = type; | this.type = type; | ||||
} | } | ||||
@@ -1,9 +1,9 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumContract; | import com.jd.blockchain.binaryproto.EnumContract; | ||||
import com.jd.blockchain.binaryproto.EnumField; | import com.jd.blockchain.binaryproto.EnumField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 键值操作的数据类型; | * 键值操作的数据类型; | ||||
@@ -11,13 +11,13 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@EnumContract(code= TypeCodes.ENUM_TYPE_DATA_TYPE, name = "DataType", decription = "") | |||||
public enum DataType { | |||||
@EnumContract(code = DataCodes.ENUM_TYPE_DATA_TYPE, name = "DataType", decription = "") | |||||
public enum BytesValueType { | |||||
/** | /** | ||||
* 空; | * 空; | ||||
*/ | */ | ||||
NIL((byte) 0x00), | |||||
NIL(DataType.NIL.CODE), | |||||
/** | /** | ||||
* 布尔型; | * 布尔型; | ||||
@@ -81,28 +81,28 @@ public enum DataType { | |||||
*/ | */ | ||||
LOCATION((byte) 0x44); | 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= ValueType.INT8) | |||||
// /** | |||||
// * 引用; <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) | |||||
public final byte CODE; | public final byte CODE; | ||||
private DataType(byte code) { | |||||
private BytesValueType(byte code) { | |||||
this.CODE = code; | this.CODE = code; | ||||
} | } | ||||
public static DataType valueOf(byte code) { | |||||
for (DataType dataType : DataType.values()) { | |||||
public static BytesValueType valueOf(byte code) { | |||||
for (BytesValueType dataType : BytesValueType.values()) { | |||||
if (dataType.CODE == code) { | if (dataType.CODE == code) { | ||||
return dataType; | return dataType; | ||||
} | } |
@@ -2,16 +2,16 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.TX_OP_CONTRACT_DEPLOY) | |||||
@DataContract(code= DataCodes.TX_OP_CONTRACT_DEPLOY) | |||||
public interface ContractCodeDeployOperation extends Operation { | public interface ContractCodeDeployOperation extends Operation { | ||||
@DataField(order=2, refContract = true) | @DataField(order=2, refContract = true) | ||||
BlockchainIdentity getContractID(); | BlockchainIdentity getContractID(); | ||||
@DataField(order=3, primitiveType=ValueType.BYTES) | |||||
@DataField(order=3, primitiveType=DataType.BYTES) | |||||
byte[] getChainCode(); | byte[] getChainCode(); | ||||
@@ -2,25 +2,25 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.TX_OP_CONTRACT_EVENT_SEND) | |||||
@DataContract(code= DataCodes.TX_OP_CONTRACT_EVENT_SEND) | |||||
public interface ContractEventSendOperation extends Operation { | public interface ContractEventSendOperation extends Operation { | ||||
@DataField(order=2, primitiveType=ValueType.BYTES) | |||||
@DataField(order=2, primitiveType=DataType.BYTES) | |||||
Bytes getContractAddress(); | Bytes getContractAddress(); | ||||
@DataField(order=3, primitiveType=ValueType.TEXT) | |||||
@DataField(order=3, primitiveType=DataType.TEXT) | |||||
String getEvent(); | String getEvent(); | ||||
@DataField(order=4, primitiveType=ValueType.BYTES) | |||||
@DataField(order=4, primitiveType=DataType.BYTES) | |||||
byte[] getArgs(); | byte[] getArgs(); | ||||
} | } |
@@ -2,8 +2,8 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 默克尔树算法相关的配置; | * 默克尔树算法相关的配置; | ||||
@@ -11,7 +11,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.METADATA_CRYPTO_SETTING) | |||||
@DataContract(code = DataCodes.METADATA_CRYPTO_SETTING) | |||||
public interface CryptoSetting { | public interface CryptoSetting { | ||||
/** | /** | ||||
@@ -23,7 +23,7 @@ public interface CryptoSetting { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.INT16) | |||||
@DataField(order = 1, primitiveType = DataType.INT16) | |||||
public short getHashAlgorithm(); | public short getHashAlgorithm(); | ||||
/** | /** | ||||
@@ -35,7 +35,7 @@ public interface CryptoSetting { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 2, primitiveType = ValueType.BOOLEAN) | |||||
@DataField(order = 2, primitiveType = DataType.BOOLEAN) | |||||
public boolean getAutoVerifyHash(); | public boolean getAutoVerifyHash(); | ||||
} | } |
@@ -2,30 +2,30 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code= TypeCodes.TX_OP_DATA_ACC_SET) | |||||
@DataContract(code= DataCodes.TX_OP_DATA_ACC_SET) | |||||
public interface DataAccountKVSetOperation extends Operation{ | public interface DataAccountKVSetOperation extends Operation{ | ||||
@DataField(order=2, primitiveType=ValueType.BYTES) | |||||
@DataField(order=2, primitiveType=DataType.BYTES) | |||||
Bytes getAccountAddress(); | Bytes getAccountAddress(); | ||||
@DataField(order=3, list=true, refContract=true) | @DataField(order=3, list=true, refContract=true) | ||||
KVWriteEntry[] getWriteSet(); | KVWriteEntry[] getWriteSet(); | ||||
@DataContract(code=TypeCodes.TX_OP_DATA_ACC_SET_KV) | |||||
@DataContract(code=DataCodes.TX_OP_DATA_ACC_SET_KV) | |||||
public static interface KVWriteEntry{ | public static interface KVWriteEntry{ | ||||
@DataField(order=1, primitiveType=ValueType.TEXT) | |||||
@DataField(order=1, primitiveType=DataType.TEXT) | |||||
String getKey(); | String getKey(); | ||||
@DataField(order=2, refContract = true) | @DataField(order=2, refContract = true) | ||||
BytesValue getValue(); | BytesValue getValue(); | ||||
@DataField(order=3, primitiveType=ValueType.INT64) | |||||
@DataField(order=3, primitiveType=DataType.INT64) | |||||
long getExpectedVersion(); | long getExpectedVersion(); | ||||
} | } | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.TX_OP_DATA_ACC_REG) | |||||
@DataContract(code= DataCodes.TX_OP_DATA_ACC_REG) | |||||
public interface DataAccountRegisterOperation extends Operation { | public interface DataAccountRegisterOperation extends Operation { | ||||
@DataField(order=1, refContract = true) | @DataField(order=1, refContract = true) | ||||
@@ -1,7 +1,7 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 数字签名; | * 数字签名; | ||||
@@ -9,7 +9,7 @@ import com.jd.blockchain.consts.TypeCodes; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.DIGITALSIGNATURE) | |||||
@DataContract(code= DataCodes.DIGITALSIGNATURE) | |||||
public interface DigitalSignature extends DigitalSignatureBody { | public interface DigitalSignature extends DigitalSignatureBody { | ||||
} | } |
@@ -2,10 +2,10 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.crypto.SignatureDigest; | import com.jd.blockchain.crypto.SignatureDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 数字签名; | * 数字签名; | ||||
@@ -13,7 +13,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.DIGITALSIGNATURE_BODY) | |||||
@DataContract(code= DataCodes.DIGITALSIGNATURE_BODY) | |||||
public interface DigitalSignatureBody { | public interface DigitalSignatureBody { | ||||
/** | /** | ||||
@@ -23,7 +23,7 @@ public interface DigitalSignatureBody { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
/** | /** | ||||
@@ -31,7 +31,7 @@ public interface DigitalSignatureBody { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=2, primitiveType = ValueType.BYTES ) | |||||
@DataField(order=2, primitiveType = DataType.BYTES ) | |||||
SignatureDigest getDigest(); | SignatureDigest getDigest(); | ||||
} | } |
@@ -2,14 +2,14 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code= TypeCodes.REQUEST_ENDPOINT) | |||||
@DataContract(code= DataCodes.REQUEST_ENDPOINT) | |||||
public interface EndpointRequest { | public interface EndpointRequest { | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
HashDigest getHash(); | HashDigest getHash(); | ||||
/** | /** | ||||
* 交易内容; | * 交易内容; | ||||
@@ -1,7 +1,7 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
/** | /** | ||||
@@ -10,7 +10,7 @@ import com.jd.blockchain.crypto.HashDigest; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.HASH_OBJECT) | |||||
@DataContract(code= DataCodes.HASH_OBJECT) | |||||
public interface HashObject { | public interface HashObject { | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
public interface KVDataEntry { | public interface KVDataEntry { | ||||
@@ -27,7 +27,7 @@ public interface KVDataEntry { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
ValueType getType(); | |||||
DataType getType(); | |||||
/** | /** | ||||
* 值; | * 值; | ||||
@@ -5,7 +5,7 @@ import java.io.UnsupportedEncodingException; | |||||
import java.math.BigInteger; | import java.math.BigInteger; | ||||
import java.util.Date; | import java.util.Date; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.utils.io.ByteArray; | import com.jd.blockchain.utils.io.ByteArray; | ||||
import com.jd.blockchain.utils.io.BytesUtils; | import com.jd.blockchain.utils.io.BytesUtils; | ||||
@@ -25,11 +25,11 @@ public class KVDataObject implements KVDataEntry { | |||||
private long version; | private long version; | ||||
private ValueType type; | |||||
private DataType type; | |||||
private byte[] bytesValue; | private byte[] bytesValue; | ||||
public KVDataObject(String key, long version, ValueType type, byte[] bytesValue) { | |||||
public KVDataObject(String key, long version, DataType type, byte[] bytesValue) { | |||||
this.key = key; | this.key = key; | ||||
this.type = type; | this.type = type; | ||||
this.version = version < 0 ? -1 : version; | this.version = version < 0 ? -1 : version; | ||||
@@ -62,7 +62,7 @@ public class KVDataObject implements KVDataEntry { | |||||
* @see com.jd.blockchain.ledger.KVDataEntry#getType() | * @see com.jd.blockchain.ledger.KVDataEntry#getType() | ||||
*/ | */ | ||||
@Override | @Override | ||||
public ValueType getType() { | |||||
public DataType getType() { | |||||
return type; | return type; | ||||
} | } | ||||
@@ -97,13 +97,13 @@ public class KVDataObject implements KVDataEntry { | |||||
* 是否为空值; | * 是否为空值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#NIL} 时返回 true,其它情况返回 false; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#NIL} 时返回 true,其它情况返回 false; | |||||
* <p> | * <p> | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public boolean isNil() { | public boolean isNil() { | ||||
return ValueType.NIL == type; | |||||
return DataType.NIL == type; | |||||
} | } | ||||
/** | /** | ||||
@@ -119,7 +119,7 @@ public class KVDataObject implements KVDataEntry { | |||||
* 返回 8 位整数值; | * 返回 8 位整数值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#INT8} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#INT8} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -127,17 +127,17 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public byte tinyValue() { | public byte tinyValue() { | ||||
if (ValueType.INT8 == type) { | |||||
if (DataType.INT8 == type) { | |||||
return bytesValue[0]; | return bytesValue[0]; | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.INT8, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT8, type)); | |||||
} | } | ||||
/** | /** | ||||
* 返回 16 位整数值; | * 返回 16 位整数值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#INT16} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#INT16} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -145,17 +145,17 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public short shortValue() { | public short shortValue() { | ||||
if (ValueType.INT16 == type) { | |||||
if (DataType.INT16 == type) { | |||||
return BytesUtils.toShort(bytesValue, 0); | return BytesUtils.toShort(bytesValue, 0); | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.INT16, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT16, type)); | |||||
} | } | ||||
/** | /** | ||||
* 返回 32 位整数值; | * 返回 32 位整数值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#INT32} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#INT32} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -163,17 +163,17 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public int intValue() { | public int intValue() { | ||||
if (ValueType.INT32 == type) { | |||||
if (DataType.INT32 == type) { | |||||
return BytesUtils.toInt(bytesValue, 0); | return BytesUtils.toInt(bytesValue, 0); | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.INT32, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT32, type)); | |||||
} | } | ||||
/** | /** | ||||
* 返回 64 位整数值; | * 返回 64 位整数值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#INT64} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#INT64} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -181,10 +181,10 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public long longValue() { | public long longValue() { | ||||
if (ValueType.INT64 == type) { | |||||
if (DataType.INT64 == type) { | |||||
return BytesUtils.toLong(bytesValue, 0); | return BytesUtils.toLong(bytesValue, 0); | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.INT64, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.INT64, type)); | |||||
} | } | ||||
@@ -192,7 +192,7 @@ public class KVDataObject implements KVDataEntry { | |||||
* 返回大整数值; | * 返回大整数值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#BIG_INT} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#BIG_INT} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -200,17 +200,17 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public BigInteger bigIntValue() { | public BigInteger bigIntValue() { | ||||
if (ValueType.BIG_INT == type) { | |||||
if (DataType.BIG_INT == type) { | |||||
return new BigInteger(bytesValue); | return new BigInteger(bytesValue); | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.BIG_INT, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.BIG_INT, type)); | |||||
} | } | ||||
/** | /** | ||||
* 返回布尔值; | * 返回布尔值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#BIG_INT} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#BIG_INT} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -218,17 +218,17 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public boolean boolValue() { | public boolean boolValue() { | ||||
if (ValueType.BOOLEAN == type) { | |||||
if (DataType.BOOLEAN == type) { | |||||
return bytesValue[0] != 0; | return bytesValue[0] != 0; | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.BOOLEAN, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.BOOLEAN, type)); | |||||
} | } | ||||
/** | /** | ||||
* 返回日期时间值; | * 返回日期时间值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#DATETIME} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#DATETIME} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -236,19 +236,19 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public Date datetimeValue() { | public Date datetimeValue() { | ||||
if (ValueType.DATETIME == type) { | |||||
if (DataType.DATETIME == type) { | |||||
long ts = BytesUtils.toLong(bytesValue); | long ts = BytesUtils.toLong(bytesValue); | ||||
return new Date(ts); | return new Date(ts); | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", ValueType.DATETIME, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s], but [%s]", DataType.DATETIME, type)); | |||||
} | } | ||||
/** | /** | ||||
* 返回大整数值; | * 返回大整数值; | ||||
* <p> | * <p> | ||||
* | * | ||||
* 仅当数据类型 {@link #getType()} 为 {@link ValueType#TEXT} / {@link ValueType#JSON} / | |||||
* {@link ValueType#XML} 有效; | |||||
* 仅当数据类型 {@link #getType()} 为 {@link DataType#TEXT} / {@link DataType#JSON} / | |||||
* {@link DataType#XML} 有效; | |||||
* <p> | * <p> | ||||
* | * | ||||
* 无效类型将引发 {@link IllegalStateException} 异常; | * 无效类型将引发 {@link IllegalStateException} 异常; | ||||
@@ -256,15 +256,15 @@ public class KVDataObject implements KVDataEntry { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public String stringValue() { | public String stringValue() { | ||||
if (ValueType.TEXT == type || ValueType.JSON == type || ValueType.XML == type) { | |||||
if (DataType.TEXT == type || DataType.JSON == type || DataType.XML == type) { | |||||
try { | try { | ||||
return new String(bytesValue, "UTF-8"); | return new String(bytesValue, "UTF-8"); | ||||
} catch (UnsupportedEncodingException e) { | } catch (UnsupportedEncodingException e) { | ||||
throw new IllegalStateException(e.getMessage(), e); | throw new IllegalStateException(e.getMessage(), e); | ||||
} | } | ||||
} | } | ||||
throw new IllegalStateException(String.format("Expected type [%s] or [%s] or [%s] , but [%s]", ValueType.TEXT, | |||||
ValueType.JSON, ValueType.XML, type)); | |||||
throw new IllegalStateException(String.format("Expected type [%s] or [%s] or [%s] , but [%s]", DataType.TEXT, | |||||
DataType.JSON, DataType.XML, type)); | |||||
} | } | ||||
// // ---------------- | // // ---------------- | ||||
@@ -2,11 +2,11 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code = TypeCodes.BLOCK) | |||||
@DataContract(code = DataCodes.BLOCK) | |||||
public interface LedgerBlock extends BlockBody { | public interface LedgerBlock extends BlockBody { | ||||
/** | /** | ||||
@@ -19,7 +19,7 @@ public interface LedgerBlock extends BlockBody { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
HashDigest getHash(); | HashDigest getHash(); | ||||
} | } |
@@ -2,23 +2,23 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@DataContract(code=TypeCodes.DATA_SNAPSHOT) | |||||
@DataContract(code=DataCodes.DATA_SNAPSHOT) | |||||
public interface LedgerDataSnapshot { | public interface LedgerDataSnapshot { | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
HashDigest getAdminAccountHash(); | HashDigest getAdminAccountHash(); | ||||
@DataField(order=2, primitiveType = ValueType.BYTES) | |||||
@DataField(order=2, primitiveType = DataType.BYTES) | |||||
HashDigest getUserAccountSetHash(); | HashDigest getUserAccountSetHash(); | ||||
@DataField(order=3, primitiveType = ValueType.BYTES) | |||||
@DataField(order=3, primitiveType = DataType.BYTES) | |||||
HashDigest getDataAccountSetHash(); | HashDigest getDataAccountSetHash(); | ||||
@DataField(order=4, primitiveType = ValueType.BYTES) | |||||
@DataField(order=4, primitiveType = DataType.BYTES) | |||||
HashDigest getContractAccountSetHash(); | HashDigest getContractAccountSetHash(); | ||||
// HashDigest getUserPrivilegeHash(); | // HashDigest getUserPrivilegeHash(); | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.TX_OP_LEDGER_INIT) | |||||
@DataContract(code= DataCodes.TX_OP_LEDGER_INIT) | |||||
public interface LedgerInitOperation extends Operation{ | public interface LedgerInitOperation extends Operation{ | ||||
@DataField(order=1, refContract=true) | @DataField(order=1, refContract=true) | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 账本初始化配置; | * 账本初始化配置; | ||||
@@ -12,14 +12,14 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.METADATA_INIT_SETTING) | |||||
@DataContract(code = DataCodes.METADATA_INIT_SETTING) | |||||
public interface LedgerInitSetting { | public interface LedgerInitSetting { | ||||
/** | /** | ||||
* 账本的种子; | * 账本的种子; | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
byte[] getLedgerSeed(); | byte[] getLedgerSeed(); | ||||
/** | /** | ||||
@@ -39,7 +39,7 @@ public interface LedgerInitSetting { | |||||
CryptoSetting getCryptoSetting(); | CryptoSetting getCryptoSetting(); | ||||
@DataField(order = 4, primitiveType=ValueType.TEXT) | |||||
@DataField(order = 4, primitiveType=DataType.TEXT) | |||||
String getConsensusProvider(); | String getConsensusProvider(); | ||||
/** | /** | ||||
@@ -47,7 +47,7 @@ public interface LedgerInitSetting { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 5, primitiveType=ValueType.BYTES) | |||||
@DataField(order = 5, primitiveType=DataType.BYTES) | |||||
Bytes getConsensusSettings(); | Bytes getConsensusSettings(); | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 账本的事务; | * 账本的事务; | ||||
@@ -11,7 +11,7 @@ import com.jd.blockchain.consts.TypeCodes; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code=TypeCodes.TX_LEDGER) | |||||
@DataContract(code=DataCodes.TX_LEDGER) | |||||
public interface LedgerTransaction extends Transaction, LedgerDataSnapshot { | public interface LedgerTransaction extends Transaction, LedgerDataSnapshot { | ||||
} | } |
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code = TypeCodes.REQUEST_NODE) | |||||
@DataContract(code = DataCodes.REQUEST_NODE) | |||||
public interface NodeRequest extends EndpointRequest { | public interface NodeRequest extends EndpointRequest { | ||||
@@ -1,9 +1,9 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.TX_OP) | |||||
@DataContract(code= DataCodes.TX_OP) | |||||
public interface Operation { | public interface Operation { | ||||
} | } |
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 参与方节点; | * 参与方节点; | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.METADATA_CONSENSUS_PARTICIPANT) | |||||
@DataContract(code = DataCodes.METADATA_CONSENSUS_PARTICIPANT) | |||||
public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | ||||
/** | /** | ||||
@@ -29,7 +29,7 @@ public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 1, primitiveType = DataType.TEXT) | |||||
String getAddress(); | String getAddress(); | ||||
/** | /** | ||||
@@ -37,7 +37,7 @@ public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 2, primitiveType = ValueType.TEXT) | |||||
@DataField(order = 2, primitiveType = DataType.TEXT) | |||||
String getName(); | String getName(); | ||||
/** | /** | ||||
@@ -45,6 +45,6 @@ public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 3, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 3, primitiveType = DataType.BYTES) | |||||
PubKey getPubKey(); | PubKey getPubKey(); | ||||
} | } |
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.utils.io.ByteArray; | import com.jd.blockchain.utils.io.ByteArray; | ||||
/** | /** | ||||
@@ -13,7 +13,7 @@ import com.jd.blockchain.utils.io.ByteArray; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.TX) | |||||
@DataContract(code= DataCodes.TX) | |||||
public interface Transaction extends NodeRequest, HashObject { | public interface Transaction extends NodeRequest, HashObject { | ||||
/** | /** | ||||
@@ -23,7 +23,7 @@ public interface Transaction extends NodeRequest, HashObject { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
@Override | @Override | ||||
HashDigest getHash(); | HashDigest getHash(); | ||||
@@ -32,7 +32,7 @@ public interface Transaction extends NodeRequest, HashObject { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=2, primitiveType=ValueType.INT64) | |||||
@DataField(order=2, primitiveType=DataType.INT64) | |||||
long getBlockHeight(); | long getBlockHeight(); | ||||
/** | /** | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 交易内容; | * 交易内容; | ||||
@@ -12,10 +12,10 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.TX_CONTENT) | |||||
@DataContract(code= DataCodes.TX_CONTENT) | |||||
public interface TransactionContent extends TransactionContentBody, HashObject { | public interface TransactionContent extends TransactionContentBody, HashObject { | ||||
@Override | @Override | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
HashDigest getHash(); | HashDigest getHash(); | ||||
} | } |
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 交易内容; | * 交易内容; | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code = TypeCodes.TX_CONTENT_BODY) | |||||
@DataContract(code = DataCodes.TX_CONTENT_BODY) | |||||
public interface TransactionContentBody { | public interface TransactionContentBody { | ||||
/** | /** | ||||
@@ -22,7 +22,7 @@ public interface TransactionContentBody { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 1, primitiveType = ValueType.BYTES) | |||||
@DataField(order = 1, primitiveType = DataType.BYTES) | |||||
HashDigest getLedgerHash(); | HashDigest getLedgerHash(); | ||||
/** | /** | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 交易请求; | * 交易请求; | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.REQUEST) | |||||
@DataContract(code= DataCodes.REQUEST) | |||||
public interface TransactionRequest extends NodeRequest, HashObject { | public interface TransactionRequest extends NodeRequest, HashObject { | ||||
/** | /** | ||||
@@ -21,6 +21,6 @@ public interface TransactionRequest extends NodeRequest, HashObject { | |||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
HashDigest getHash(); | HashDigest getHash(); | ||||
} | } |
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
/** | /** | ||||
* 交易请求 {@link TransactionRequest} 的回复; | * 交易请求 {@link TransactionRequest} 的回复; | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@DataContract(code= TypeCodes.TX_RESPONSE) | |||||
@DataContract(code= DataCodes.TX_RESPONSE) | |||||
public interface TransactionResponse { | public interface TransactionResponse { | ||||
/** | /** | ||||
@@ -20,7 +20,7 @@ public interface TransactionResponse { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=1, primitiveType = ValueType.BYTES) | |||||
@DataField(order=1, primitiveType = DataType.BYTES) | |||||
HashDigest getContentHash(); | HashDigest getContentHash(); | ||||
/** | /** | ||||
@@ -36,7 +36,7 @@ public interface TransactionResponse { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=3, primitiveType = ValueType.BYTES) | |||||
@DataField(order=3, primitiveType = DataType.BYTES) | |||||
HashDigest getBlockHash(); | HashDigest getBlockHash(); | ||||
/** | /** | ||||
@@ -47,10 +47,10 @@ public interface TransactionResponse { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order=4, primitiveType=ValueType.INT64) | |||||
@DataField(order=4, primitiveType=DataType.INT64) | |||||
long getBlockHeight(); | long getBlockHeight(); | ||||
@DataField(order=5, primitiveType=ValueType.BOOLEAN) | |||||
@DataField(order=5, primitiveType=DataType.BOOLEAN) | |||||
boolean isSuccess(); | boolean isSuccess(); | ||||
} | } |
@@ -1,9 +1,9 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.binaryproto.EnumContract; | import com.jd.blockchain.binaryproto.EnumContract; | ||||
import com.jd.blockchain.binaryproto.EnumField; | import com.jd.blockchain.binaryproto.EnumField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.utils.ValueType; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
/** | /** | ||||
* 交易(事务)执行状态; | * 交易(事务)执行状态; | ||||
@@ -11,7 +11,7 @@ import com.jd.blockchain.utils.ValueType; | |||||
* @author huanghaiquan | * @author huanghaiquan | ||||
* | * | ||||
*/ | */ | ||||
@EnumContract(code= TypeCodes.ENUM_TYPE_TRANSACTION_STATE) | |||||
@EnumContract(code= DataCodes.ENUM_TYPE_TRANSACTION_STATE) | |||||
public enum TransactionState { | public enum TransactionState { | ||||
/** | /** | ||||
@@ -39,7 +39,7 @@ public enum TransactionState { | |||||
*/ | */ | ||||
TIMEOUT((byte) 0x81); | TIMEOUT((byte) 0x81); | ||||
@EnumField(type= ValueType.INT8) | |||||
@EnumField(type= DataType.INT8) | |||||
public final byte CODE; | public final byte CODE; | ||||
private TransactionState(byte code) { | private TransactionState(byte code) { | ||||
@@ -1,10 +1,10 @@ | |||||
package com.jd.blockchain.ledger; | package com.jd.blockchain.ledger; | ||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
import com.jd.blockchain.crypto.PubKey; | import com.jd.blockchain.crypto.PubKey; | ||||
@DataContract(code= TypeCodes.USER) | |||||
@DataContract(code= DataCodes.USER) | |||||
public interface UserInfo extends AccountHeader { | public interface UserInfo extends AccountHeader { | ||||
PubKey getDataPubKey(); | PubKey getDataPubKey(); | ||||
@@ -2,9 +2,9 @@ package com.jd.blockchain.ledger; | |||||
import com.jd.blockchain.binaryproto.DataContract; | import com.jd.blockchain.binaryproto.DataContract; | ||||
import com.jd.blockchain.binaryproto.DataField; | import com.jd.blockchain.binaryproto.DataField; | ||||
import com.jd.blockchain.consts.TypeCodes; | |||||
import com.jd.blockchain.consts.DataCodes; | |||||
@DataContract(code= TypeCodes.TX_OP_USER_REG) | |||||
@DataContract(code= DataCodes.TX_OP_USER_REG) | |||||
public interface UserRegisterOperation extends Operation { | public interface UserRegisterOperation extends Operation { | ||||
// @Override | // @Override | ||||
@@ -3,7 +3,7 @@ package com.jd.blockchain.transaction; | |||||
import com.jd.blockchain.ledger.BytesValue; | import com.jd.blockchain.ledger.BytesValue; | ||||
import com.jd.blockchain.ledger.BytesValueImpl; | import com.jd.blockchain.ledger.BytesValueImpl; | ||||
import com.jd.blockchain.ledger.DataAccountKVSetOperation; | import com.jd.blockchain.ledger.DataAccountKVSetOperation; | ||||
import com.jd.blockchain.ledger.DataType; | |||||
import com.jd.blockchain.ledger.BytesValueType; | |||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.io.BytesUtils; | import com.jd.blockchain.utils.io.BytesUtils; | ||||
import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; | import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; | ||||
@@ -23,7 +23,7 @@ public class DataAccountKVSetOperationBuilderImpl implements DataAccountKVSetOpe | |||||
@Override | @Override | ||||
public DataAccountKVSetOperationBuilder set(String key, byte[] value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, byte[] value, long expVersion) { | ||||
BytesValue bytesValue = new BytesValueImpl(DataType.BYTES, value); | |||||
BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value); | |||||
operation.set(key, bytesValue, expVersion); | operation.set(key, bytesValue, expVersion); | ||||
return this; | return this; | ||||
} | } | ||||
@@ -32,10 +32,10 @@ public class DataAccountKVSetOperationBuilderImpl implements DataAccountKVSetOpe | |||||
public DataAccountKVSetOperationBuilder set(String key, String value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, String value, long expVersion) { | ||||
BytesValue bytesValue; | BytesValue bytesValue; | ||||
if (JSONSerializeUtils.isJSON(value)) { | if (JSONSerializeUtils.isJSON(value)) { | ||||
bytesValue = new BytesValueImpl(DataType.JSON, value.getBytes()); | |||||
bytesValue = new BytesValueImpl(BytesValueType.JSON, value.getBytes()); | |||||
} | } | ||||
else { | else { | ||||
bytesValue = new BytesValueImpl(DataType.TEXT, value.getBytes()); | |||||
bytesValue = new BytesValueImpl(BytesValueType.TEXT, value.getBytes()); | |||||
} | } | ||||
operation.set(key, bytesValue, expVersion); | operation.set(key, bytesValue, expVersion); | ||||
return this; | return this; | ||||
@@ -43,13 +43,13 @@ public class DataAccountKVSetOperationBuilderImpl implements DataAccountKVSetOpe | |||||
@Override | @Override | ||||
public DataAccountKVSetOperationBuilder set(String key, Bytes value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, Bytes value, long expVersion) { | ||||
BytesValue bytesValue = new BytesValueImpl(DataType.BYTES, value.toBytes()); | |||||
BytesValue bytesValue = new BytesValueImpl(BytesValueType.BYTES, value.toBytes()); | |||||
operation.set(key, bytesValue, expVersion); | operation.set(key, bytesValue, expVersion); | ||||
return this; | return this; | ||||
} | } | ||||
@Override | @Override | ||||
public DataAccountKVSetOperationBuilder set(String key, long value, long expVersion) { | public DataAccountKVSetOperationBuilder set(String key, long value, long expVersion) { | ||||
BytesValue bytesValue = new BytesValueImpl(DataType.INT64, BytesUtils.toBytes(value)); | |||||
BytesValue bytesValue = new BytesValueImpl(BytesValueType.INT64, BytesUtils.toBytes(value)); | |||||
operation.set(key, bytesValue, expVersion); | operation.set(key, bytesValue, expVersion); | ||||
return this; | return this; | ||||
} | } | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||||
import com.jd.blockchain.binaryproto.DataContractRegistry; | import com.jd.blockchain.binaryproto.DataContractRegistry; | ||||
import com.jd.blockchain.ledger.BytesValueImpl; | import com.jd.blockchain.ledger.BytesValueImpl; | ||||
import com.jd.blockchain.ledger.DataAccountKVSetOperation; | import com.jd.blockchain.ledger.DataAccountKVSetOperation; | ||||
import com.jd.blockchain.ledger.DataType; | |||||
import com.jd.blockchain.ledger.BytesValueType; | |||||
import com.jd.blockchain.ledger.Operation; | import com.jd.blockchain.ledger.Operation; | ||||
import com.jd.blockchain.transaction.DataAccountKVSetOpTemplate; | import com.jd.blockchain.transaction.DataAccountKVSetOpTemplate; | ||||
import com.jd.blockchain.transaction.KVData; | import com.jd.blockchain.transaction.KVData; | ||||
@@ -43,11 +43,11 @@ public class DataAccountKVSetOpTemplateTest { | |||||
String accountAddress = "zhangsandhakhdkah"; | String accountAddress = "zhangsandhakhdkah"; | ||||
data = new DataAccountKVSetOpTemplate(Bytes.fromString(accountAddress)); | data = new DataAccountKVSetOpTemplate(Bytes.fromString(accountAddress)); | ||||
KVData kvData1 = | KVData kvData1 = | ||||
new KVData("test1", new BytesValueImpl(DataType.TEXT, "zhangsan".getBytes()), 9999L); | |||||
new KVData("test1", new BytesValueImpl(BytesValueType.TEXT, "zhangsan".getBytes()), 9999L); | |||||
KVData kvData2 = | KVData kvData2 = | ||||
new KVData("test2", new BytesValueImpl(DataType.TEXT, "lisi".getBytes()), 9990L); | |||||
new KVData("test2", new BytesValueImpl(BytesValueType.TEXT, "lisi".getBytes()), 9990L); | |||||
KVData kvData3 = | KVData kvData3 = | ||||
new KVData("test3", new BytesValueImpl(DataType.TEXT, "wangwu".getBytes()), 1990L); | |||||
new KVData("test3", new BytesValueImpl(BytesValueType.TEXT, "wangwu".getBytes()), 1990L); | |||||
data.set(kvData1); | data.set(kvData1); | ||||
data.set(kvData2); | data.set(kvData2); | ||||
data.set(kvData3); | data.set(kvData3); | ||||
@@ -12,7 +12,7 @@ import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||||
import com.jd.blockchain.binaryproto.DataContractRegistry; | import com.jd.blockchain.binaryproto.DataContractRegistry; | ||||
import com.jd.blockchain.ledger.BytesValueImpl; | import com.jd.blockchain.ledger.BytesValueImpl; | ||||
import com.jd.blockchain.ledger.DataAccountKVSetOperation; | import com.jd.blockchain.ledger.DataAccountKVSetOperation; | ||||
import com.jd.blockchain.ledger.DataType; | |||||
import com.jd.blockchain.ledger.BytesValueType; | |||||
import com.jd.blockchain.transaction.DataAccountKVSetOpTemplate; | import com.jd.blockchain.transaction.DataAccountKVSetOpTemplate; | ||||
import com.jd.blockchain.transaction.KVData; | import com.jd.blockchain.transaction.KVData; | ||||
@@ -39,7 +39,7 @@ public class KVDataTest { | |||||
byte[] value = "test-value".getBytes(); | byte[] value = "test-value".getBytes(); | ||||
long expectedVersion = 9999L; | long expectedVersion = 9999L; | ||||
kvData = new KVData(key, new BytesValueImpl(DataType.BYTES, value), expectedVersion); | |||||
kvData = new KVData(key, new BytesValueImpl(BytesValueType.BYTES, value), expectedVersion); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam; | |||||
import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | ||||
import com.jd.blockchain.binaryproto.DataType; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.ledger.AccountHeader; | import com.jd.blockchain.ledger.AccountHeader; | ||||
import com.jd.blockchain.ledger.BytesValue; | import com.jd.blockchain.ledger.BytesValue; | ||||
@@ -31,7 +32,6 @@ import com.jd.blockchain.ledger.core.UserAccountSet; | |||||
import com.jd.blockchain.transaction.BlockchainQueryService; | import com.jd.blockchain.transaction.BlockchainQueryService; | ||||
import com.jd.blockchain.utils.Bytes; | import com.jd.blockchain.utils.Bytes; | ||||
import com.jd.blockchain.utils.QueryUtil; | import com.jd.blockchain.utils.QueryUtil; | ||||
import com.jd.blockchain.utils.ValueType; | |||||
@RestController | @RestController | ||||
@RequestMapping(path = "/") | @RequestMapping(path = "/") | ||||
@@ -339,11 +339,11 @@ public class LedgerQueryController implements BlockchainQueryService { | |||||
for (int i = 0; i < entries.length; i++) { | for (int i = 0; i < entries.length; i++) { | ||||
ver = dataAccount.getDataVersion(Bytes.fromString(keys[i])); | ver = dataAccount.getDataVersion(Bytes.fromString(keys[i])); | ||||
if (ver < 0) { | if (ver < 0) { | ||||
entries[i] = new KVDataObject(keys[i], -1, ValueType.NIL, null); | |||||
entries[i] = new KVDataObject(keys[i], -1, DataType.NIL, null); | |||||
}else { | }else { | ||||
byte[] value = dataAccount.getBytes(Bytes.fromString(keys[i]), ver); | byte[] value = dataAccount.getBytes(Bytes.fromString(keys[i]), ver); | ||||
BytesValue decodeData = BinaryEncodingUtils.decode(value); | BytesValue decodeData = BinaryEncodingUtils.decode(value); | ||||
entries[i] = new KVDataObject(keys[i], ver, ValueType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||||
entries[i] = new KVDataObject(keys[i], ver, DataType.valueOf(decodeData.getType().CODE), decodeData.getValue().toBytes()); | |||||
} | } | ||||
} | } | ||||