本文整理匯總了Golang中github.com/c-darwin/dcoin-go/packages/dcparser.Parser.ParseDataFront方法的典型用法代碼示例。如果您正苦於以下問題:Golang Parser.ParseDataFront方法的具體用法?Golang Parser.ParseDataFront怎麽用?Golang Parser.ParseDataFront使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/c-darwin/dcoin-go/packages/dcparser.Parser
的用法示例。
在下文中一共展示了Parser.ParseDataFront方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestblockIsReady
//.........這裏部分代碼省略.........
p := new(dcparser.Parser)
p.DCDB = d.DCDB
// проверяем подпись
_, err = utils.CheckSign([][]byte{nodePublicKey}, forSign, []byte(testBlockData["signature"]), true)
if err != nil {
log.Error("incorrect signature %v")
p.RollbackTransactionsTestblock(true)
err = d.ExecSql("DELETE FROM testblock")
if err != nil {
if d.unlockPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
if d.unlockPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
// БАГ
if utils.StrToInt64(testBlockData["block_id"]) == prevBlock.BlockId {
log.Error("testBlockData block_id = prevBlock.BlockId (%v=%v)", testBlockData["block_id"], prevBlock.BlockId)
err = p.RollbackTransactionsTestblock(true)
if err != nil {
if d.unlockPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
err = d.ExecSql("DELETE FROM testblock")
if err != nil {
if d.unlockPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
if d.unlockPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
// готовим заголовок
newBlockIdBinary := utils.DecToBin(utils.StrToInt64(testBlockData["block_id"]), 4)
timeBinary := utils.DecToBin(utils.StrToInt64(testBlockData["time"]), 4)
userIdBinary := utils.DecToBin(utils.StrToInt64(testBlockData["user_id"]), 5)
levelBinary := utils.DecToBin(utils.StrToInt64(testBlockData["level"]), 1)
//prevBlockHashBinary := prevBlock.Hash
//merkleRootBinary := testBlockData["mrklRoot"];
// заголовок
blockHeader := utils.DecToBin(0, 1)
blockHeader = append(blockHeader, newBlockIdBinary...)
blockHeader = append(blockHeader, timeBinary...)
blockHeader = append(blockHeader, userIdBinary...)
blockHeader = append(blockHeader, levelBinary...)
blockHeader = append(blockHeader, utils.EncodeLengthPlusData([]byte(testBlockData["signature"]))...)
// сам блок
block := append(blockHeader, testBlockDataTx...)
log.Debug("block %x", block)
// теперь нужно разнести блок по таблицам и после этого мы будем его слать всем нодам скриптом disseminator.php
p.BinaryData = block
err = p.ParseDataFront()
if err != nil {
if d.dPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
// и можно удалять данные о тестблоке, т.к. они перешел в нормальный блок
err = d.ExecSql("DELETE FROM transactions_testblock")
if err != nil {
if d.dPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
err = d.ExecSql("DELETE FROM testblock")
if err != nil {
if d.dPrintSleep(utils.ErrInfo(err), d.sleepTime) {
break BEGIN
}
continue BEGIN
}
// между testblock_generator и testbock_is_ready
p.RollbackTransactionsTestblock(false)
d.dbUnlock()
if d.dSleep(d.sleepTime) {
break BEGIN
}
}
log.Debug("break BEGIN %v", GoroutineName)
}