// Path: Client/src/main/java/Util/Config.java
// public class Config {
// 
//     public static String USER_NAME = "Client1";
//     public static String USER_PASS = "Pass1";
// 
//     public static int MESSAGE_OUTGOING = 200;
//     public static int MESSAGE_OUTGOING_RESPONSE = 201;
//     public static int MESSAGE_MAX_TRIALS = 4;
//     public static int MESSAGE_ACK = 900;
//     public static int MESSAGE_REQUEST_KEYSET = 301;
//     public static int MESSAGE_REQUEST_BLOCK = 302;
//     public static int MESSAGE_TIMEOUT = 2500;
// 
//     public static int MESSAGE_RESPONSE_INVALIDKEY = 401;
//     public static int MESSAGE_RESPONSE_INVALIDHASH = 402;
//     public static int MESSAGE_RESPONSE_VALID = 403;
// 
//     public static int MESSAGE_SERVER_TEST = 999;
// 
//     public static int UPLOAD_EXPIRATION_TIME = 100000;
//     public static int BLOCKCHAIN_BATCH_TIMEOUT = 10000;
//     public static int BLOCKCHAIN_BATCH_PERIOD = 8000;
//     public static int TRANSACTION_VALIDATION_TIMEOUT = 5000;
//     public static int BLOCK_CREATION_TIMEOUT = 300000;
// 
//     public static String KEY_SPLITTER = "////";
// 
//     public static String DB_TABLE_NAME="blockchain";
// 
//     public static String SERVER_ADDRESS = "46.101.245.232";
//     public static int SERVER_PORT = 4141;
//     public static int SERVER_TIMEOUT = 5000;
// 
//     public static int CLIENT_HEARTBEAT_PORT = 4141;
//     public static int CLIENT_SERVER_PORT = 4142;
//     public static String CLIENT_MESSAGE_SPLITTER = "////";
//     public static String CLIENT_MESSAGE_PEERSIZE = "X";
// 
//     public static int HEARTBEAT_FLAG_CLIENT = 101;
//     public static int HEARTBEAT_FLAG_SERVER = 100;
//     public static int HEARTBEAT_ACK = 102;
//     public static int HEARTBEAT_PERIOD = 5000;
//     public static int HEARTBEAT_TIMEOUT = 10000;
//     public static int HEARTBEAT_MAX_TRIALS = 3;
// 
//     public static int FLAG_BROADCAST_TRANSACTION = 1;
//     public static int FLAG_BROADCAST_HASH = 2;
//     public static int FLAG_BLOCKCHAIN_INVALID = 4;
// 
//     public static String UPLOAD_BUCKETNAME = "crypdist-trial-bucket-mfs";
// 
// 
// 
//     public static String PRIVATE_KEY = "";
// 
// }
// 
// Path: Client/src/main/java/Util/CustomAppender.java
// public class CustomAppender extends AppenderSkeleton {
//     public static LinkedBlockingQueue<LoggingEvent> eventsList = new LinkedBlockingQueue<>();
// 
//     @Override
//     protected void append(LoggingEvent event) {
//         eventsList.add(event);
//     }
// 
//     public static void clear() {
//         eventsList.clear();
//     }
// 
//     public static String getMessages() {
//         StringBuilder stringBuilder = new StringBuilder();
// 
//         for(LoggingEvent event : eventsList) {
//             stringBuilder.append(event.getRenderedMessage() + "\n");
//         }
// 
//         clear();
// 
//         return stringBuilder.toString();
//     }
//     public void close() {
// 
//     }
// 
// 
//     public boolean requiresLayout() {
//         return false;
//     }
// 
// }


import Util.Config;
import Util.CustomAppender;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Appender;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * Created by od on 27.04.2017.
 */
public class Property {
    public Property() {

        PropertyConfigurator.configure(this.getClass().getResourceAsStream("log4j_custom.properties"));
        Logger l1 = Logger.getLogger("P2P");
        Appender a = new CustomAppender();
        l1.addAppender(a);

        l1 = Logger.getLogger("BlockchainManager");
        l1.addAppender(a);

        l1 = Logger.getLogger("DbManager");
        l1.addAppender(a);

        l1 = Logger.getLogger("CrypDist");
        l1.addAppender(a);

        try {
// Path: Client/src/main/java/Util/Config.java
// public class Config {
// 
//     public static String USER_NAME = "Client1";
//     public static String USER_PASS = "Pass1";
// 
//     public static int MESSAGE_OUTGOING = 200;
//     public static int MESSAGE_OUTGOING_RESPONSE = 201;
//     public static int MESSAGE_MAX_TRIALS = 4;
//     public static int MESSAGE_ACK = 900;
//     public static int MESSAGE_REQUEST_KEYSET = 301;
//     public static int MESSAGE_REQUEST_BLOCK = 302;
//     public static int MESSAGE_TIMEOUT = 2500;
// 
//     public static int MESSAGE_RESPONSE_INVALIDKEY = 401;
//     public static int MESSAGE_RESPONSE_INVALIDHASH = 402;
//     public static int MESSAGE_RESPONSE_VALID = 403;
// 
//     public static int MESSAGE_SERVER_TEST = 999;
// 
//     public static int UPLOAD_EXPIRATION_TIME = 100000;
//     public static int BLOCKCHAIN_BATCH_TIMEOUT = 10000;
//     public static int BLOCKCHAIN_BATCH_PERIOD = 8000;
//     public static int TRANSACTION_VALIDATION_TIMEOUT = 5000;
//     public static int BLOCK_CREATION_TIMEOUT = 300000;
// 
//     public static String KEY_SPLITTER = "////";
// 
//     public static String DB_TABLE_NAME="blockchain";
// 
//     public static String SERVER_ADDRESS = "46.101.245.232";
//     public static int SERVER_PORT = 4141;
//     public static int SERVER_TIMEOUT = 5000;
// 
//     public static int CLIENT_HEARTBEAT_PORT = 4141;
//     public static int CLIENT_SERVER_PORT = 4142;
//     public static String CLIENT_MESSAGE_SPLITTER = "////";
//     public static String CLIENT_MESSAGE_PEERSIZE = "X";
// 
//     public static int HEARTBEAT_FLAG_CLIENT = 101;
//     public static int HEARTBEAT_FLAG_SERVER = 100;
//     public static int HEARTBEAT_ACK = 102;
//     public static int HEARTBEAT_PERIOD = 5000;
//     public static int HEARTBEAT_TIMEOUT = 10000;
//     public static int HEARTBEAT_MAX_TRIALS = 3;
// 
//     public static int FLAG_BROADCAST_TRANSACTION = 1;
//     public static int FLAG_BROADCAST_HASH = 2;
//     public static int FLAG_BLOCKCHAIN_INVALID = 4;
// 
//     public static String UPLOAD_BUCKETNAME = "crypdist-trial-bucket-mfs";
// 
// 
// 
//     public static String PRIVATE_KEY = "";
// 
// }
// 
// Path: Client/src/main/java/Util/CustomAppender.java
// public class CustomAppender extends AppenderSkeleton {
//     public static LinkedBlockingQueue<LoggingEvent> eventsList = new LinkedBlockingQueue<>();
// 
//     @Override
//     protected void append(LoggingEvent event) {
//         eventsList.add(event);
//     }
// 
//     public static void clear() {
//         eventsList.clear();
//     }
// 
//     public static String getMessages() {
//         StringBuilder stringBuilder = new StringBuilder();
// 
//         for(LoggingEvent event : eventsList) {
//             stringBuilder.append(event.getRenderedMessage() + "\n");
//         }
// 
//         clear();
// 
//         return stringBuilder.toString();
//     }
//     public void close() {
// 
//     }
// 
// 
//     public boolean requiresLayout() {
//         return false;
//     }
// 
// }


// Path: Client/src/main/java/Property.java
import Util.Config;
import Util.CustomAppender;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Appender;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;


/**
 * Created by od on 27.04.2017.
 */
public class Property {
    public Property() {

        PropertyConfigurator.configure(this.getClass().getResourceAsStream("log4j_custom.properties"));
        Logger l1 = Logger.getLogger("P2P");
        Appender a = new CustomAppender();
        l1.addAppender(a);

        l1 = Logger.getLogger("BlockchainManager");
        l1.addAppender(a);

        l1 = Logger.getLogger("DbManager");
        l1.addAppender(a);

        l1 = Logger.getLogger("CrypDist");
        l1.addAppender(a);

        try {
            Config.PRIVATE_KEY = new String((IOUtils.toByteArray(getClass().getResourceAsStream("private.pem"))) );