Skip to content

Commit

Permalink
FAB-4566 Minor code cleanup
Browse files Browse the repository at this point in the history
Change-Id: I744aada6ad4006eea7ffc08c682091df7156ffc4
Signed-off-by: rickr <cr22rc@gmail.com>
  • Loading branch information
cr22rc committed Jun 12, 2017
1 parent 9992851 commit bedc97c
Show file tree
Hide file tree
Showing 31 changed files with 36 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static SignaturePolicy parsePolicy(IndexedHashMap<String, MSPPrincipal>
throw new ChaincodeEndorsementPolicyParseException(format("%s expected to have list but found %s.", key, String.valueOf(vo)));
}

@SuppressWarnings("unchecked") final List<Map<?, ?>> voList = (List<Map<?, ?>>) vo;
@SuppressWarnings ("unchecked") final List<Map<?, ?>> voList = (List<Map<?, ?>>) vo;

if (voList.size() < matchNo) {

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/hyperledger/fabric/sdk/ChaincodeID.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ public Builder setVersion(String version) {
return this;
}


/**
* Set path of chaincode
*
* @param path of chaincode
* @return Builder
*/


public Builder setPath(String path) {
this.protoBuilder.setPath(path);
return this;
Expand All @@ -94,7 +92,7 @@ public ChaincodeID build() {
}

/**
* Chaincode builder
* Chaincode builder
*
* @return ChaincodeID builder.
*/
Expand All @@ -103,5 +101,4 @@ public static Builder newBuilder() {
return new Builder();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ChaincodeInputDeserializer {

ChaincodeInputDeserializer(ChaincodeInput chaincodeInput) {
this.byteString = chaincodeInput.toByteString();
this.chaincodeInput = new WeakReference<>(chaincodeInput);
this.chaincodeInput = new WeakReference<>(chaincodeInput);
}

ChaincodeInput getChaincodeInput() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.hyperledger.fabric.protos.peer.Chaincode.ChaincodeInvocationSpec;
import org.hyperledger.fabric.sdk.exception.InvalidProtocolBufferRuntimeException;


class ChaincodeInvocationSpecDeserializer {
private final ByteString byteString;
private WeakReference<ChaincodeInvocationSpec> invocationSpec;
Expand Down Expand Up @@ -55,6 +54,7 @@ ChaincodeInvocationSpec getChaincodeInvocationSpec() {
return ret;

}

ChaincodeInputDeserializer getChaincodeInput() {
ChaincodeInputDeserializer ret = null;

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/hyperledger/fabric/sdk/ChaincodeResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public ChaincodeResponse(String transactionID, String chaincodeID, Status status
public ChaincodeResponse(String transactionID, String chaincodeID, int istatus, String message) {

switch (istatus) {
case 200:
this.status = Status.SUCCESS;
break;
case 500:
this.status = Status.FAILURE;
break;
default:
this.status = Status.UNDEFINED;
break;
case 200:
this.status = Status.SUCCESS;
break;
case 500:
this.status = Status.FAILURE;
break;
default:
this.status = Status.UNDEFINED;
break;
}
this.message = message;
this.transactionID = transactionID;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/hyperledger/fabric/sdk/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public Collection<EventHub> getEventHubs() {
private Block genesisBlock;
private final boolean systemChannel;


private Channel(String name, HFClient hfClient, Orderer orderer, ChannelConfiguration channelConfiguration, byte[][] signers) throws InvalidArgumentException, TransactionException {
this(name, hfClient, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ int getType() {
return type;
}


/**
* @return whether this Transaction is marked as TxValidationCode.VALID
*/
public boolean isValid() {


return validcode == FabricTransaction.TxValidationCode.VALID_VALUE;
}

Expand All @@ -110,7 +108,6 @@ public byte validationCode() {
return validcode;
}


static EnvelopeDeserializer newInstance(ByteString byteString, byte b) throws InvalidProtocolBufferException {

EnvelopeDeserializer ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public File getChaincodeSourceLocation() {

/**
* The location of the chaincode.
*
* @param chaincodeSourceLocation
* @throws InvalidArgumentException
*/
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/hyperledger/fabric/sdk/Orderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ Ab.BroadcastResponse sendTransaction(Common.Envelope transaction) throws Excepti

logger.debug(format("Order.sendTransaction name: %s, url: %s", name, url));


OrdererClient localOrdererClient = ordererClient;

if (localOrdererClient == null || !localOrdererClient.isChannelActive()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* TransactionInfo contains the data from a {@link ProcessedTransaction} message
*
*/
public class TransactionInfo {
private final String txID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.google.protobuf.ByteString;

class TransactionPayloadDeserializer extends PayloadDeserializer {
class TransactionPayloadDeserializer extends PayloadDeserializer {

private WeakReference<TransactionDeserializer> transactionDeserialize;

Expand All @@ -31,7 +31,6 @@ class TransactionPayloadDeserializer extends PayloadDeserializer {

TransactionDeserializer getTransaction() {


TransactionDeserializer ret = null;

if (transactionDeserialize != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class TransactionRequest {
/**
* The user context to use on this request.
*
*
* @return User context that is used for signing
*/
User getUserContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
* limitations under the License.
*/


package org.hyperledger.fabric.sdk.exception;


public class ChaincodeEndorsementPolicyParseException extends BaseException {
public ChaincodeEndorsementPolicyParseException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class InvalidArgumentException extends BaseException {
public InvalidArgumentException(String message, Exception parent) {
super(message, parent);
}

public InvalidArgumentException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class InvokeException extends RuntimeException {

private static final long serialVersionUID = 1L;

public InvokeException(String message, Exception parent) {
super(message, parent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

/**
* The exception to be thrown when we receive an event for an invalid Transaction
*
*/
public class TransactionEventException extends TransactionException {

Expand All @@ -27,6 +26,7 @@ public class TransactionEventException extends TransactionException {

/**
* save the TransactionEvent in the exception so that caller can use for debugging
*
* @param message
* @param transactionEvent
*/
Expand All @@ -37,6 +37,7 @@ public TransactionEventException(String message, TransactionEvent transactionEve

/**
* save the TransactionEvent in the exception so that caller can use for debugging
*
* @param message
* @param transactionEvent
* @param throwable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public TransactionException(String message, Throwable parent) {
public TransactionException(String message) {
super(message);
}

public TransactionException(Throwable t) {
super(t);
}
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static String generateDirectoryHash(String rootDir, String chaincodeDir,
* Compress the contents of given directory using Tar and Gzip to an in-memory byte array.
*
* @param sourceDirectory the source directory.
* @param pathPrefix a path to be prepended to every file name in the .tar.gz output, or {@code null} if no prefix is required.
* @param pathPrefix a path to be prepended to every file name in the .tar.gz output, or {@code null} if no prefix is required.
* @return the compressed directory contents.
* @throws IOException
*/
Expand Down Expand Up @@ -322,7 +322,6 @@ public static boolean isNullOrEmpty(String url) {
return url == null || url.isEmpty();
}


/**
* Makes logging strings which can be long or with unprintable characters be logged and trimmed.
*
Expand All @@ -344,7 +343,6 @@ public static String logString(final String string) {

private static final int NONONCE_LENGTH = 24;


private static final SecureRandom RANDOM = new SecureRandom();

public static byte[] generateNonce() {
Expand All @@ -355,8 +353,6 @@ public static byte[] generateNonce() {
return values;
}



public static String toHexString(ByteString byteString) {
if (byteString == null) {
return null;
Expand All @@ -378,6 +374,7 @@ public static String toHexString(byte[] bytes) {
/**
* Private constructor to prevent instantiation.
*/
private Utils() { }
private Utils() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,9 @@ public byte[] certificateToDER(String certricatePEM) {
return pemObject.getContent();

} catch (IOException e) {
// best attempt
// best attempt
}
return null;
return null;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static org.hyperledger.fabric.protos.peer.Chaincode.ChaincodeSpec.Type.GOLANG;


public class CSCCProposalBuilder extends ProposalBuilder {
private static final String CSCC_CHAIN_NAME = "cscc";
private static final Chaincode.ChaincodeID CHAINCODE_ID_CSCC =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package org.hyperledger.fabric.sdk.transaction;


import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,7 +27,6 @@
public class JoinPeerProposalBuilder extends CSCCProposalBuilder {
private static final Log logger = LogFactory.getLog(JoinPeerProposalBuilder.class);


public JoinPeerProposalBuilder genesisBlock(Block genesisBlock) throws ProposalException {

if (genesisBlock == null) {
Expand All @@ -51,13 +49,12 @@ private JoinPeerProposalBuilder() {
@Override
public JoinPeerProposalBuilder context(TransactionContext context) {
super.context(context);
return this;
return this;
}

public static JoinPeerProposalBuilder newBuilder() {
return new JoinPeerProposalBuilder();
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static org.hyperledger.fabric.protos.peer.Chaincode.ChaincodeSpec.Type.GOLANG;


public class LSCCProposalBuilder extends ProposalBuilder {
private static final String LSCC_CHAIN_NAME = "lscc";
private static final Chaincode.ChaincodeID CHAINCODE_ID_LSCC =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package org.hyperledger.fabric.sdk.transaction;


import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -23,7 +22,6 @@

public class QueryInstantiatedChaincodesBuilder extends LSCCProposalBuilder {


private QueryInstantiatedChaincodesBuilder() {

List<ByteString> argList = new ArrayList<>();
Expand All @@ -42,6 +40,5 @@ public static QueryInstantiatedChaincodesBuilder newBuilder() {
return new QueryInstantiatedChaincodesBuilder();
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public class TransactionContext {
private static final Config config = Config.getConfig();
// private static final Log logger = LogFactory.getLog(TransactionContext.class);
// private static final Log logger = LogFactory.getLog(TransactionContext.class);
//TODO right now the server does not care need to figure out
private final ByteString nonce = ByteString.copyFrom(Utils.generateNonce());

Expand Down Expand Up @@ -111,6 +111,7 @@ public Channel getChannel() {

/**
* Get the attribute names associated with this transaction context.
*
* @return the attributes.
*/
public List<String> getAttrs() {
Expand All @@ -119,6 +120,7 @@ public List<String> getAttrs() {

/**
* Set the attributes for this transaction context.
*
* @param attrs the attributes.
*/
public void setAttrs(List<String> attrs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

public class UpgradeProposalBuilder extends InstantiateProposalBuilder {


// private final static Log logger = LogFactory.getLog(UpgradeProposalBuilder.class);


private UpgradeProposalBuilder() {
super();
action = "upgrade";
Expand Down
Loading

0 comments on commit bedc97c

Please sign in to comment.