Skip to content

Commit

Permalink
Updating for RC3; fixing bugs in MasterNodeVote
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Jun 16, 2014
1 parent c9a8611 commit acc54b9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 19 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--------------limecoinj
--------------darkcoinj
HashEngineering <[email protected]>

--------------digitalcoinj
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ find your unzipped Maven install directory.
Now try running one of the example apps:

cd examples
mvn exec:java -Dexec.mainClass=com.google.bitcoin.examples.ForwardingService -Dexec.args="<insert a bitcoin address here>"
mvn exec:java -Dexec.mainClass=com.google.bitcoin.examples.ForwardingService -Dexec.args="<insert a darkcoin address here>"

It will download the block chain and eventually print a Bitcoin address. If you send coins to it,
It will download the block chain and eventually print a Darkcoin address. If you send coins to it,
it will forward them on to the address you specified. Note that this example app does not use
checkpointing, so the initial chain sync will be pretty slow. You can make an app that starts up and
does the initial sync much faster by including a checkpoints file; see the documentation for
Expand Down
21 changes: 15 additions & 6 deletions core/src/main/java/com/google/bitcoin/core/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,20 @@ private void parseTransactions() throws ProtocolException {
parseMasterNodeVotes();
}

private final long START_MASTERNODE_PAYMENTS = 1401033600; //Sun, 25 May 2014 16:00:00 GMT
private final long START_MASTERNODE_PAYMENTS_STOP = 1401134533; // Mon, 26 May 2014 20:02:13 GMT
private static final long START_MASTERNODE_PAYMENTS_1 = 1401033600L; //Sun, 25 May 2014 16:00:00 GMT
private static final long START_MASTERNODE_PAYMENTS_STOP_1 = 1401134533L; // Mon, 26 May 2014 20:02:13 GMT

private static final long START_MASTERNODE_PAYMENTS = 1403280000; //Fri, 20 Jun 2014 16:00:00 GMT
//private static final long START_MASTERNODE_PAYMENTS_STOP = ?

private static final long START_MASTERNODE_PAYMENTS_TESTNET_1 = 1401757793;
private static final long START_MASTERNODE_PAYMENTS_TESTNET = 1402440553;
//
// only call from parseTransactions
//
void parseMasterNodeVotes() throws ProtocolException {

if(getTimeSeconds() < START_MASTERNODE_PAYMENTS || getTimeSeconds() > START_MASTERNODE_PAYMENTS_STOP)
if(shouldHaveMasterNodeVotes() == false)
return;

if (masterNodeVotesParsed)
Expand All @@ -256,7 +262,7 @@ void parseMasterNodeVotes() throws ProtocolException {
//optimalEncodingMessageSize = HEADER_SIZE;

//This must be done first to ensure that cursor and offset are set correctly
parseTransactions();
//parseTransactions();

if (bytes.length == cursor) {
// This message is just a header, it has no master node votes.
Expand Down Expand Up @@ -501,7 +507,7 @@ private void writeTransactions(OutputStream stream) throws IOException {
//
private void writeMasterNodeVotes(OutputStream stream) throws IOException {

if(getTimeSeconds() < START_MASTERNODE_PAYMENTS || getTimeSeconds() > START_MASTERNODE_PAYMENTS_STOP)
if(shouldHaveMasterNodeVotes() == false)
return;

// check for no transaction conditions first
Expand Down Expand Up @@ -1242,6 +1248,9 @@ boolean isMasterNodeVotesBytesValid() {
}

boolean shouldHaveMasterNodeVotes() {
return (getTimeSeconds() >= START_MASTERNODE_PAYMENTS && getTimeSeconds() < START_MASTERNODE_PAYMENTS_STOP);
if(getParams().getId().equals(CoinDefinition.ID_MAINNET))
return (getTimeSeconds() > START_MASTERNODE_PAYMENTS/* && getTimeSeconds() < START_MASTERNODE_PAYMENTS_STOP*/);
else
return getTimeSeconds() > START_MASTERNODE_PAYMENTS_TESTNET;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ void parse() throws ProtocolException {
if(newBlockHeader.shouldHaveMasterNodeVotes())
{
byte[] mnv = readBytes(1);
if(mnv[0] != 0)
if(mnv[0] != 0 /* && !params.getId().equals(CoinDefinition.ID_MAINNET)*/)
throw new ProtocolException("Block header does not end with two null bytes");
//else cursor--;
}

blockHeaders.add(newBlockHeader);
Expand Down
24 changes: 18 additions & 6 deletions core/src/main/java/com/google/bitcoin/core/MasterNodeVote.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2014 Hash Engineering Solutions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.bitcoin.core;

import com.google.bitcoin.core.ChildMessage;
Expand All @@ -12,9 +27,6 @@
import static com.google.bitcoin.core.Utils.int64ToByteStreamLE;
import static com.google.bitcoin.core.Utils.uint32ToByteStreamLE;

/**
* Created by Eric on 5/28/14.
*/
public class MasterNodeVote extends ChildMessage implements Serializable {
public int votes;
public Script pubkey;
Expand Down Expand Up @@ -84,12 +96,12 @@ void parse() throws ProtocolException {
return;

cursor = offset;
//version = (int)readUint32();
version = CURRENT_VERSION;

blockHeight = readInt64();
optimalEncodingMessageSize = 8;
//TODO: not finished
//pubkey = ?


long scriptSize = readVarInt();
optimalEncodingMessageSize += VarInt.sizeOf(scriptSize);
byte [] scriptBytes = readBytes((int)scriptSize);
Expand Down
5 changes: 5 additions & 0 deletions jni/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This directory contains the required files to build the native libraries for the hashing algorithm.

The hashing code is taken directly from the C++ client for darkcoin.

One file "hashblock.cpp" was added to wrap the Hash9 function so it can be called from Java.
6 changes: 3 additions & 3 deletions tools/wallet-tool
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
set -e

# Check if the jar has been built.
if [ ! -e target/digitalcoinj-tools-*.jar ] || [[ "$ALWAYS_BUILD_WALLETTOOL" != "" ]]; then
if [ ! -e target/darkcoinj-tools-*.jar ] || [[ "$ALWAYS_BUILD_WALLETTOOL" != "" ]]; then
echo "Compiling WalletTool to a JAR"
cd ../core
mvn install -DskipTests
cd ../tools
[ -e target/digitalcoinj-tools-*.jar ] && rm target/digitalcoinj-tools-*.jar
[ -e target/darkcoinj-tools-*.jar ] && rm target/darkcoinj-tools-*.jar
mvn package -DskipTests
fi

java -server -jar target/digitalcoinj-tools-*.jar $*
java -server -jar target/darkcoinj-tools-*.jar $*

0 comments on commit acc54b9

Please sign in to comment.