Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
327 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/bash | ||
|
||
java -jar SnowBlossomClient_deploy.jar configs/client.conf $1 $2 $3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/bash | ||
|
||
java -jar SnowBlossomMiner_deploy.jar configs/miner.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/bash | ||
|
||
java -jar SnowBlossomNode_deploy.jar configs/node.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Snowblossom Explorer | ||
After=network.target | ||
|
||
[Service] | ||
User=snowblossom | ||
WorkingDirectory=/var/snowblossom | ||
ExecStart=/var/snowblossom/source/bazel-bin/ShackletonExplorer configs/explorer.conf | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package snowblossom.node; | ||
import snowblossom.lib.db.DB; | ||
import snowblossom.proto.*; | ||
import com.google.protobuf.ByteString; | ||
import com.google.common.collect.TreeMultimap; | ||
import snowblossom.lib.db.DBMapMutationSet; | ||
import snowblossom.lib.*; | ||
import java.nio.ByteBuffer; | ||
import java.util.List; | ||
|
||
public class AddressHistoryUtil | ||
{ | ||
public static void saveAddressHistory(Block blk, DB db) | ||
{ | ||
TreeMultimap<ByteString, ByteString> map = DBMapMutationSet.createMap(); | ||
int height = blk.getHeader().getBlockHeight(); | ||
|
||
ChainHash blk_id = new ChainHash(blk.getHeader().getSnowHash()); | ||
|
||
for(Transaction tx : blk.getTransactionsList()) | ||
{ | ||
ChainHash tx_id = new ChainHash(tx.getTxHash()); | ||
ByteString val = getValue(blk_id, tx_id, height); | ||
TransactionInner inner = TransactionUtil.getInner(tx); | ||
|
||
for(TransactionInput in : inner.getInputsList()) | ||
{ | ||
ByteString addr = in.getSpecHash(); | ||
map.put(addr, val); | ||
} | ||
for(TransactionOutput out : inner.getOutputsList()) | ||
{ | ||
ByteString addr = out.getRecipientSpecHash(); | ||
map.put(addr, val); | ||
} | ||
|
||
} | ||
db.getAddressHistoryMap().addAll(map); | ||
} | ||
|
||
public static ByteString getValue(ChainHash blk_id, ChainHash tx_id, int height) | ||
{ | ||
byte[] buff = new byte[4 + Globals.BLOCKCHAIN_HASH_LEN * 2]; | ||
|
||
ByteBuffer bb = ByteBuffer.wrap(buff); | ||
bb.putInt(height); | ||
bb.put(blk_id.toByteArray()); | ||
bb.put(tx_id.toByteArray()); | ||
|
||
return ByteString.copyFrom(buff); | ||
|
||
} | ||
|
||
|
||
public static HistoryList getHistory(AddressSpecHash spec_hash, DB db, BlockHeightCache cache) | ||
{ | ||
List<ByteString> value_set = db.getAddressHistoryMap().getSet(spec_hash.getBytes(), Globals.ADDRESS_HISTORY_MAX_REPLY); | ||
|
||
HistoryList.Builder hist_list = HistoryList.newBuilder(); | ||
|
||
for(ByteString val : value_set) | ||
{ | ||
ByteBuffer bb = ByteBuffer.wrap(val.toByteArray()); | ||
int height = bb.getInt(); | ||
|
||
byte[] b = new byte[Globals.BLOCKCHAIN_HASH_LEN]; | ||
|
||
bb.get(b); | ||
ChainHash blk_hash = new ChainHash(b); | ||
|
||
bb.get(b); | ||
ChainHash tx_hash = new ChainHash(b); | ||
|
||
if (blk_hash.equals(cache.getHash(height))) | ||
{ | ||
hist_list.addEntries(HistoryEntry | ||
.newBuilder() | ||
.setBlockHeight(height) | ||
.setTxHash(tx_hash.getBytes()) | ||
.setBlockHash(blk_hash.getBytes()) | ||
.build()); | ||
} | ||
} | ||
|
||
return hist_list.build(); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package snowblossom.node; | ||
|
||
|
||
import java.util.TreeMap; | ||
import snowblossom.lib.ChainHash; | ||
|
||
public class BlockHeightCache | ||
{ | ||
private TreeMap<Integer, ChainHash> map = new TreeMap<>(); | ||
private SnowBlossomNode node; | ||
|
||
public BlockHeightCache(SnowBlossomNode node) | ||
{ | ||
this.node = node; | ||
} | ||
|
||
public synchronized void setHash(int height, ChainHash hash) | ||
{ | ||
map.put(height, hash); | ||
} | ||
|
||
public synchronized ChainHash getHash(int height) | ||
{ | ||
ChainHash hash = map.get(height); | ||
if (hash == null) | ||
{ | ||
hash = node.getDB().getBlockHashAtHeight(height); | ||
map.put(height, hash); | ||
} | ||
return hash; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.