Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk-abi/src/main/java/org/fisco/bcos/sdk/abi/TypeDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ static Utf8String decodeUtf8String(String input, int offset) {
* @param input the staticArray need to be decoded
* @param offset the size of the staticArray need to be decoded
* @param type the type of the result
* @param length
* @param <T>
* @param length the length of array
* @param <T> the generic type
* @return the decoded result
*/
@SuppressWarnings("unchecked")
Expand Down
10 changes: 5 additions & 5 deletions sdk-core/src/main/java/org/fisco/bcos/sdk/channel/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,32 @@ static Channel build(ConfigOption configOption) throws ConfigException {
* Add a message handler to handle specific type messages. When one message comes the handler
* will be notified, handler.onMessage(ChannleHandlerContext ctx, Message msg) called.
*
* @param type
* @param handler
* @param type the type of message
* @param handler the message handler
*/
void addMessageHandler(MsgType type, MsgHandler handler);

/**
* Add a connect handler, when one connect success, call handler.onConnect(ChannleHandlerContext
* ctx)is called
*
* @param handler
* @param handler the connect handler
*/
void addConnectHandler(MsgHandler handler);

/**
* Add a establish handler, when the SDK establishes a connection with the node, call the
* handler
*
* @param handler
* @param handler the establish handler
*/
void addEstablishHandler(MsgHandler handler);

/**
* Add a disconnect handler, when one connection disconnect,
* handler.onDisconnect(ChannleHandlerContext ctx) is called
*
* @param handler
* @param handler disconnect handler
*/
void addDisconnectHandler(MsgHandler handler);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface PeerSelectRule {
/**
* PeerSelectRule Customize a rule to select a peer to send message to
*
* @param conns
* @param conns the list of connection info
* @return the selected peer
*/
String select(List<ConnectionInfo> conns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class ResponseCallback {
/**
* OnResponse
*
* @param response
* @param response the response from node
*/
public abstract void onResponse(Response response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static ConfigOption load(String tomlConfigFile) throws ConfigException {
}
/**
* @param tomlConfigFile the toml configuration file path
* @param cryptoType the type of crypto function
* @return ConfigOption the configuration object
* @throws ConfigException the configuration exception
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface Network {
* @param configOption the path of the yaml config file
* @param handler message handler
* @return a Network implementation instance
* @throws ConfigException the configuration exception
*/
static Network build(ConfigOption configOption, MsgHandler handler) throws ConfigException {
return new NetworkImp(configOption, handler);
Expand All @@ -52,6 +53,7 @@ static Network build(ConfigOption configOption, MsgHandler handler) throws Confi
*
* @param out the sent message
* @param peerIpPort the node to receive the message
* @throws NetworkException the network exception
*/
void sendToPeer(Message out, String peerIpPort) throws NetworkException;

Expand Down
38 changes: 35 additions & 3 deletions sdk-core/src/main/java/org/fisco/bcos/sdk/utils/ByteUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public class ByteUtils {
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
public static final byte[] ZERO_BYTE_ARRAY = new byte[] {0};

/** Creates a copy of bytes and appends b to the end of it */
/**
* Creates a copy of bytes and appends b to the end of it
*
* @param bytes the original bytes
* @param b the appended byte
* @return a appended bytes @
*/
public static byte[] appendByte(byte[] bytes, byte b) {
byte[] result = Arrays.copyOf(bytes, bytes.length + 1);
result[result.length - 1] = b;
Expand Down Expand Up @@ -467,6 +473,10 @@ public static byte[] xor(byte[] b1, byte[] b2) {
/**
* XORs byte arrays of different lengths by aligning length of the shortest via adding zeros at
* beginning
*
* @param b1 the first byte array
* @param b2 the second byte array
* @return a byte array contains XORS of b1 and b2
*/
public static byte[] xorAlignRight(byte[] b1, byte[] b2) {
if (b1.length > b2.length) {
Expand Down Expand Up @@ -630,7 +640,12 @@ public static byte[] hexStringToBytes(String data) {
return Hex.decode(data);
}

/** Converts string representation of host/ip to 4-bytes byte[] IPv4 */
/**
* Converts string representation of host/ip to 4-bytes byte[] IPv4
*
* @param ip the ip string of host
* @return a 4-bytes byte[] IPv4
*/
public static byte[] hostToBytes(String ip) {
byte[] bytesIp;
try {
Expand All @@ -642,7 +657,12 @@ public static byte[] hostToBytes(String ip) {
return bytesIp;
}

/** Converts 4 bytes IPv4 IP to String representation */
/**
* Converts 4 bytes IPv4 IP to String representation
*
* @param bytesIp the 4 bytes IPv4 IP
* @return a String representation of the IP
*/
public static String bytesToIp(byte[] bytesIp) {

StringBuilder sb = new StringBuilder();
Expand All @@ -661,6 +681,9 @@ public static String bytesToIp(byte[] bytesIp) {
/**
* Returns a number of zero bits preceding the highest-order ("leftmost") one-bit interpreting
* input array as a big-endian integer value
*
* @param bytes the byte array
* @return the number of leading zeros
*/
public static int numberOfLeadingZeros(byte[] bytes) {

Expand All @@ -679,6 +702,11 @@ public static int numberOfLeadingZeros(byte[] bytes) {
* input} has not enough bytes return array will be right padded with zero bytes. I.e. if {@code
* offset} is higher than {@code input.length} then zero byte array of length {@code len} will
* be returned
*
* @param input the input bytes array
* @param offset an offset in {@code input} array to start parsing from
* @param len the length of zero byte array
* @return a fixed bytes array
*/
public static byte[] parseBytes(byte[] input, int offset, int len) {

Expand All @@ -696,7 +724,9 @@ public static byte[] parseBytes(byte[] input, int offset, int len) {
* thus, result will be right-padded with zero bytes if there is not enough bytes in {@code
* input}
*
* @param input the input bytes array
* @param idx an index of the word starting from {@code 0}
* @return a fixed bytes array
*/
public static byte[] parseWord(byte[] input, int idx) {
return parseBytes(input, 32 * idx, 32);
Expand All @@ -707,8 +737,10 @@ public static byte[] parseWord(byte[] input, int idx) {
* thus, result will be right-padded with zero bytes if there is not enough bytes in {@code
* input}
*
* @param input the input bytes array
* @param idx an index of the word starting from {@code 0}
* @param offset an offset in {@code input} array to start parsing from
* @return a fixed bytes array
*/
public static byte[] parseWord(byte[] input, int offset, int idx) {
return parseBytes(input, offset + 32 * idx, 32);
Expand Down
17 changes: 17 additions & 0 deletions sdk-core/src/main/java/org/fisco/bcos/sdk/utils/Hex.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static String toHexString(byte[] data, int off, int length) {
/**
* encode the input data producing a Hex encoded byte array.
*
* @param data the input data
* @return a byte array containing the Hex encoded data.
*/
public static byte[] encode(byte[] data) {
Expand All @@ -44,6 +45,9 @@ public static byte[] encode(byte[] data) {
/**
* encode the input data producing a Hex encoded byte array.
*
* @param data the input byte array
* @param off the offset of the data to be converted
* @param length the length of the data to be converted
* @return a byte array containing the Hex encoded data.
*/
public static byte[] encode(byte[] data, int off, int length) {
Expand All @@ -61,6 +65,9 @@ public static byte[] encode(byte[] data, int off, int length) {
/**
* Hex encode the byte data writing it to the given output stream.
*
* @param data the byte array
* @param out the output stream
* @throws IOException the I/O exception
* @return the number of bytes produced.
*/
public static int encode(byte[] data, OutputStream out) throws IOException {
Expand All @@ -70,6 +77,11 @@ public static int encode(byte[] data, OutputStream out) throws IOException {
/**
* Hex encode the byte data writing it to the given output stream.
*
* @param data the byte array
* @param off the offset of the data to be converted
* @param length the length of the data to be converted
* @param out the output stream
* @throws IOException the I/O exception
* @return the number of bytes produced.
*/
public static int encode(byte[] data, int off, int length, OutputStream out)
Expand All @@ -80,6 +92,7 @@ public static int encode(byte[] data, int off, int length, OutputStream out)
/**
* decode the Hex encoded input data. It is assumed the input data is valid.
*
* @param data the input byte array
* @return a byte array representing the decoded data.
*/
public static byte[] decode(byte[] data) {
Expand All @@ -97,6 +110,7 @@ public static byte[] decode(byte[] data) {
/**
* decode the Hex encoded String data - whitespace will be ignored.
*
* @param data the input byte array
* @return a byte array representing the decoded data.
*/
public static byte[] decode(String data) {
Expand All @@ -115,6 +129,9 @@ public static byte[] decode(String data) {
* decode the Hex encoded String data writing it to the given output stream, whitespace
* characters will be ignored.
*
* @param data the input byte array
* @param out the output stream
* @throws IOException the I/O exception
* @return the number of bytes produced.
*/
public static int decode(String data, OutputStream out) throws IOException {
Expand Down
13 changes: 13 additions & 0 deletions sdk-core/src/main/java/org/fisco/bcos/sdk/utils/HexEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public HexEncoder() {
/**
* encode the input data producing a Hex output stream.
*
* @param data the input byte array
* @param off the offset of the data to be converted
* @param length the length of the data to be converted
* @param out the output stream
* @throws IOException the I/O exception
* @return the number of bytes produced.
*/
public int encode(byte[] data, int off, int length, OutputStream out) throws IOException {
Expand All @@ -75,6 +80,11 @@ private static boolean ignore(char c) {
* decode the Hex encoded byte data writing it to the given output stream, whitespace characters
* will be ignored.
*
* @param data the input byte array
* @param off the offset of the data to be converted
* @param length the length of the data to be converted
* @param out the output stream
* @throws IOException the I/O exception
* @return the number of bytes produced.
*/
public int decode(byte[] data, int off, int length, OutputStream out) throws IOException {
Expand Down Expand Up @@ -121,6 +131,9 @@ public int decode(byte[] data, int off, int length, OutputStream out) throws IOE
* decode the Hex encoded String data writing it to the given output stream, whitespace
* characters will be ignored.
*
* @param data the input byte array
* @param out the output stream
* @throws IOException the I/O exception
* @return the number of bytes produced.
*/
public int decode(String data, OutputStream out) throws IOException {
Expand Down
8 changes: 4 additions & 4 deletions sdk-core/src/main/java/org/fisco/bcos/sdk/utils/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/** Verify host and port, and extract host or port from string. */
public class Host {
/**
* @param IP
* @param IP the IP string of host
* @return true if IP valid IP string otherwise false
*/
public static boolean validIP(String IP) {
Expand All @@ -32,7 +32,7 @@ public static boolean validIP(String IP) {
}

/**
* @param port
* @param port the port string
* @return true if port valid IP port otherwise false
*/
public static boolean validPort(String port) {
Expand All @@ -47,7 +47,7 @@ public static boolean validPort(String port) {
/**
* Get ip from IPAndPort string
*
* @param IPAndPort
* @param IPAndPort the combine of IP and port string
* @return String of IP address
*/
public static String getIpFromString(String IPAndPort) {
Expand All @@ -59,7 +59,7 @@ public static String getIpFromString(String IPAndPort) {
/**
* Get port from IPAndPort string
*
* @param IPAndPort
* @param IPAndPort the combine of IP and port string
* @return String of port.
*/
public static String getPortFromString(String IPAndPort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public CryptoSuite(int cryptoTypeConfig, ConfigOption configOption) {
/**
* init the common crypto implementation according to the crypto type
*
* @param cryptoTypeConfig
* @param cryptoTypeConfig the crypto type config number
*/
public CryptoSuite(int cryptoTypeConfig) {
this.cryptoTypeConfig = cryptoTypeConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public CryptoKeyPair() {}
/**
* init CryptoKeyPair from the keyPair
*
* @param keyPair
* @param keyPair the original keyPair
*/
public CryptoKeyPair(KeyPair keyPair) {
this.keyPair = keyPair;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public static void storeKeyPairWithP12Format(
*
* @param keyPair the keyPair used to generated the certificate
* @param signatureAlgorithm the signature algorithm of the cert
* @throws NoSuchAlgorithmException no such algorithm exception
* @throws CertificateEncodingException error occurs when encoding certificate
* @throws NoSuchProviderException no such provider exception
* @throws InvalidKeyException invalid key exception
* @throws SignatureException generic signature exception
* @return the generated self-signed certificate object
*/
public static X509Certificate generateSelfSignedCertificate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AmopPublisherPrivateFile {
/**
* @param args topicName, pubKey1, pubKey2, isBroadcast: true/false, fileName, count, timeout.
* if only one public key please fill pubKey2 with null
* @throws Exception
* @throws Exception the exception
*/
public static void main(String[] args) throws Exception {
if (args.length < parameterNum) {
Expand Down
Loading