本文整理匯總了Golang中github.com/FactomProject/factoid/block.FBlock.GetKeyMR方法的典型用法代碼示例。如果您正苦於以下問題:Golang FBlock.GetKeyMR方法的具體用法?Golang FBlock.GetKeyMR怎麽用?Golang FBlock.GetKeyMR使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factoid/block.FBlock
的用法示例。
在下文中一共展示了FBlock.GetKeyMR方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Test_create_genesis_FactoidState
//.........這裏部分代碼省略.........
0) // Expires
}
sec1 := fs.stats.TransactionsPerSec()
sec2 := fs.stats.TotalTransactionsPerSec()
cp.CP.AddUpdate(
"transpersec", // tag
"info", // Category
fmt.Sprintf("Transactions per second %4.2f, (+ bad) %4.2f", sec1, sec2), // Title
"", // Msg
0) // Expires
fmt.Println("Block Check")
blk1 := fs.GetCurrentBlock()
blk1MR := fs.GetCurrentBlock().GetHash()
fmt.Println("ProcessEndOfBlock")
fs.ProcessEndOfBlock() // Process the block.
fmt.Println("Check ProcessEndOfBlock")
blk2PMR := fs.GetCurrentBlock().GetPrevKeyMR()
if !bytes.Equal(blk1MR.Bytes(), blk2PMR.Bytes()) {
fmt.Println("MR's don't match")
test.Fail()
return
}
data, err := blk1.MarshalBinary()
if err != nil {
fmt.Println("Failed to Marshal")
test.Fail()
return
}
blk1b := new(block.FBlock)
err = blk1b.UnmarshalBinary(data)
if err != nil {
fmt.Println("Failed to Unmarshal")
test.Fail()
return
}
if !bytes.Equal(blk2PMR.Bytes(), blk1b.GetKeyMR().Bytes()) {
fmt.Println("Unmarshaled MR doesn't match")
test.Fail()
return
}
c := 1
keys := make([]string, 0, len(fs.stats.errors))
for k := range fs.stats.errors {
keys = append(keys, k)
}
for i := 0; i < len(keys)-1; i++ {
for j := 0; j < len(keys)-i-1; j++ {
if keys[j] < keys[j+1] {
t := keys[j]
keys[j] = keys[j+1]
keys[j+1] = t
}
}
}
var out bytes.Buffer
for _, key := range keys {
ecnt := fs.stats.errors[key]
by := []byte(fs.stats.full[key])
prt := string(by)
if len(prt) > 80 {
prt = string(by[:80]) + "..."
}
prt = strings.Replace(prt, "\n", " ", -1)
out.WriteString(fmt.Sprintf("%6d %s\n", ecnt, prt))
c++
}
cp.CP.AddUpdate(
"transerrors", // tag
"errors", // Category
"Transaction Errors Detected:", // Title
"<pre>"+string(out.Bytes())+"</pre>", // Msg
0) // Expires
}
fmt.Println("\nDone")
// // Get the head of the Factoid Chain
// blk := fs.GetTransactionBlock(fct.FACTOID_CHAINID_HASH)
// hashes := make([]fct.IHash,0,10)
// // First run back from the head back to the genesis block, collecting hashes.
// for {
// h := blk.GetHash()
// hashes = append(hashes,h)
// if bytes.Compare(blk.GetPrevKeyMR().Bytes(),fct.ZERO) == 0 {
// break
// }
// tblk := fs.GetTransactionBlock(blk.GetPrevKeyMR())
// blk = tblk
// time.Sleep(time.Second/100)
// }
//
// // Now run forward, and build our accounting
// for i := len(hashes)-1; i>=0; i-- {
// blk = fs.GetTransactionBlock(hashes[i])
// fmt.Println("Block",blk.GetDBHeight())
// for _,trans := range blk.GetTransactions() {
// PrtTrans(trans)
// }
// }
}