Where is Kunlun service center
哈希树的跟节点称为Merkle根,Merkle树可以仅用log2N的时间复杂度检查任何一个数据元素是否包含在树中:
package test;
import java.security.MessageDigest;
import java.uTIl.ArrayList;
import java.uTIl.List;
public class MerkleTrees {
// transacTIon List
ListString txList;
// Merkle Root
String root;
/**
* constructor
* @param txList transacTIon List 交易List
*/
public MerkleTreesListString txList {
this.txList = txList;
root = “”;
}
/**
* execute merkle_tree and set root.
*/
public void merkle_tree {
ListString tempTxList = new ArrayListString;
for int i = 0; i this.txList.size; i++ {
tempTxList.addthis.txList.geti;
}
ListString newTxList = getNewTxListtempTxList;
while newTxList.size = 1 {
newTxList = getNewTxListnewTxList;
}
this.root = newTxList.get0;
}
/**
* return Node Hash List.
* @param tempTxList
* @return
*/
private ListString getNewTxListListString tempTxList {
ListString newTxList = new ArrayListString;
int index = 0;
while index tempTxList.size {
// left
String left = tempTxList.getindex;
index++;
// right
String right = “”;
if index = tempTxList.size {
right = tempTxList.getindex;
}
// sha2 hex value
String sha2HexValue = getSHA2HexValueleft + right;
newTxList.addsha2HexValue;
index++;
}
return newTxList;
}
/**
* Return hex string
* @param str
* @return
*/
public String getSHA2HexValueString str {
byte[] cipher_byte;
try{
MessageDigest md = MessageDigest.getInstance“SHA-256”;
md.updatestr.getBytes;
cipher_byte = md.digest;
StringBuilder sb = new StringBuilder2 * cipher_byte.length;
forbyte b: cipher_byte {
sb.appendString.format“%02x”, b&0xff ;
}
return sb.toString;
} catch Exception e {
e.printStackTrace;
}
return “”;
}
/**
* Get Root
* @return
*/
public String getRoot {
return this.root;
}
}
try to choose better blockchain companies.
In the coming 2017, if you want to ask which asset has the highest return on investment in the world, the answer is undoubtedly bitcoin
at the beginning of this year, the price of a bitcoin was less than US $1000, and on Monday (December 18), US Eastern time, the bitcoin futures of Chicago Mercantile Exchange officially began trading, of which the opening price of the contract in January exceeded US $20000. It also means that the price of bitcoin has risen more than 20 times in less than a year. If the timeline is extended to the past eight years, the price of bitcoin will increase by an amazing 22 million times P>
despite the fact that bitcoin has launched another round of wealth building campaign, many people who question the bitcoin bubble have been "hit". But if we look at the past 3 major bitcoin market callbacks, we can see that the bitcoin making wealth myth is also associated with a great deal of destruction of wealth. A very simple truth, we should be able to understand - in the speculative asset market, the vast majority of people can not really make money
at the beginning of 2011, the price of each bitcoin was only US $0.3, and it reached US $31.5 on June 8, with a 100 fold increase in less than half a year. Then, in less than a month, the price of bitcoin plummeted to $11, then to $7.8 in less than a month, and then continued to fall back to $4.77. In other words, in just two or three months, the price of bitcoin has plummeted by 85%
because there is no "anchor" of a pricing system, the initial bitcoin market is more driven by liquidity. The biggest day of decline was after prices peaked, with a decline of more than 30%. During the whole decline, bitcoin fell more than 20% in a single day for seven days. The whole process of decline lasted for three months before it really bottomed out. I believe most people can hardly hold it firmly any more
in 2013, bitcoin rose more than 100 times again, but it was also accompanied by two sharp drops, especially the second one, which took several years to repair. Most Chinese investors actually began to participate in bitcoin trading in 2013. It can be said that the 100 fold surge in 2013 and the subsequent sharp drop have really brought bitcoin into the vision of the Chinese public
judging from the trend of bitcoin in 2013, the first sharp drop was after the price hit a high of $266, and bitcoin dropped 77.4% to $54.25 in three days. I'm afraid that any "value investor" will be shocked by such a drastic collapse
then came the second round of sharp decline in that year, which was also the most wealth destroying decline in the history of bitcoin. The sharp rise and fall of bitcoin attracted a large number of "RMB players" to enter the market. Some people even joked that it was the "Chinese aunt" who entered the market to sweep the goods that led to the second wave of "main wave" of bitcoin in 2013. However, on December 5, the regulatory department headed by the Central Bank of China issued the notice on preventing bitcoin risks, which clearly pointed out that bitcoin was not a currency, It should not be used as currency in the market. Ordinary people have the freedom to participate at their own risk. Financial institutions and Payment institutions should not price procts or services with bitcoin. The announcement also led to the biggest drop in bitcoin's history: a 92.5% drop in price within 83 days, almost destroying the market
the sharp drop in 2013 has brought bitcoin into a long-term bear market. From 2013 to 2015, bitcoin prices basically went down in shock, with only a short-term rebound. It is difficult for anyone to maintain his faith in a bear market for a long time. Especially this time, after the rapid decline in the early stage, it did not continue to reach a new high, but continued to go down. That's why bitcoin seems to be forgotten by Chinese investors by 2015 P>
many people once regarded bitcoin market as the largest asset bubble in history, compared with the tulip bubble nearly 400 years ago. Of course, it is also possible that our vision is not broad enough to see the value of bitcoin
for bitcoin, both the short and the long sides have their own reasons, so there is no need to argue too much. But by comparing several bubbles analysis, it can be found that the volatility of this asset is very large, and there has also been a relatively long bear market. Based on this, it is suggested that investors should not participate in the game too much if they do not have enough knowledge of its fundamentals
back to the essence of investment (or speculation) - investment, there are always people who will make money; And any speculation, there must be someone who can make a lot of money. It's like buying lottery tickets, which will always give you a vision of becoming rich, but every time you win the lottery, it's not you
in terms of investment, we should have "rich thinking", know how to give up, and try to invest within our own ability circle, that is to say, we should buy assets that we can understand. Through data review, we can see that although bitcoin has a huge increase, there are several huge fluctuations and long-term bear markets. In the end, how many people can earn from the beginning to the end
if you are not a friend of time, you must be an enemy of time - bitcoin, like many speculative procts, seems to have experienced a huge rise, but how many people can successfully take profits, how many people have sold them, and how many people give up in the bottom years of bear market? The key is that investors must have a knowledge of the varieties they hold, and only with this knowledge can they have confidence and make value judgments. Otherwise, in the end, it is to hand over one's destiny to others and to the market fluctuation every day
in the words of Warren Buffett, there will always be the champion of "coin toss contest" in the market. The most important thing is to know how to give up and believe in value. Because only value, is the best friend of time, can bring the biggest leverage