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