本文整理汇总了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)
}