Compare commits

...

2 Commits

Author SHA1 Message Date
lzx ce8efb9890 fix alph height use blockChain height 2025-04-16 16:46:30 +08:00
lzx f5f788bc59 fix gbt bug 2025-04-16 16:30:06 +08:00
1 changed files with 8 additions and 8 deletions

View File

@ -216,19 +216,19 @@ func update_block_confirm(gbt *GbtAlphContext) {
if checkResult { if checkResult {
blockInfo := gbt.GbtCtx.ClientAlphApi.GetBlcokInfo(blockHash) blockInfo := gbt.GbtCtx.ClientAlphApi.GetBlcokInfo(blockHash)
var total_amount float64 = 0 var total_amount float64 = 0
fromGroup, toGroup, nonce, height, input, output := blockInfo.ChainFrom, blockInfo.ChainTo, blockInfo.Nonce, blockInfo.Height, blockInfo.Transactions[len(blockInfo.Transactions)-1].Unsigned.Inputs, blockInfo.Transactions[len(blockInfo.Transactions)-1].Unsigned.FixedOutputs fromGroup, toGroup, nonce, height := blockInfo.ChainFrom, blockInfo.ChainTo, blockInfo.Nonce, blockInfo.Height
if len(input) == 0 { for _, tx := range blockInfo.Transactions {
for v := range output { for _, out := range tx.Unsigned.FixedOutputs {
address, amount := output[v].Address, output[v].AttoAlphAmount if out.Address == addr[fromGroup] && nonce == blockInfo.Nonce {
if address == addr[fromGroup] && nonce == block.Nonce { amount := out.AttoAlphAmount
total_amount += savePoint4(stringToFloat64(amount) / math.Pow(10, 18)) total_amount += savePoint4(stringToFloat64(amount) / math.Pow(10, 18))
fmt.Println(fromGroup, "->", toGroup, "(", height, ")", total_amount, ",", nonce, " ", blockHash, " ", address, " 报块成功") fmt.Println(fromGroup, "->", toGroup, "(", height, ")", total_amount, ",", nonce, " ", blockHash, " ", out.Address, " 报块成功")
} else { } else {
fmt.Println(fromGroup, "->", toGroup, "(", height, ")", total_amount, ",", nonce, "不是报块,实际报块地址为:", address) fmt.Println(fromGroup, "->", toGroup, "(", height, ")", total_amount, ",", nonce, "不是报块,实际报块地址为:", out.Address)
} }
} }
} }
block_height := int64(block.Height) block_height := height // 用区块链返回的height防止某个块成为下一个高度的叔块导致高度变化
dbif.AlphNotifyPoolBlkStatsSuccess(gbt.GbtCtx, uint32(fromGroup), uint32(toGroup), block_height, "", block.Nonce, int64(block.SubIdx), total_amount, 0) dbif.AlphNotifyPoolBlkStatsSuccess(gbt.GbtCtx, uint32(fromGroup), uint32(toGroup), block_height, "", block.Nonce, int64(block.SubIdx), total_amount, 0)
dbif.NotifyAlphBlkDetailSuccess(gbt.GbtCtx, uint32(fromGroup), uint32(toGroup), block_height, "", block.Nonce, int64(block.SubIdx)) dbif.NotifyAlphBlkDetailSuccess(gbt.GbtCtx, uint32(fromGroup), uint32(toGroup), block_height, "", block.Nonce, int64(block.SubIdx))
dbif.NotifyAlphBlkNewDb(gbt.GbtCtx, uint32(fromGroup), uint32(toGroup), block_height, block.Hash, true, block.Nonce, int64(block.SubIdx)) dbif.NotifyAlphBlkNewDb(gbt.GbtCtx, uint32(fromGroup), uint32(toGroup), block_height, block.Hash, true, block.Nonce, int64(block.SubIdx))