gpt4 book ai didi

python - 插入QLDB时摘要不匹配

转载 作者:行者123 更新时间:2023-12-01 20:25:09 24 4
gpt4 key购买 nike

我正在尝试使用Go中的AWS开发工具包将记录插入QLDB分类帐中。我以Python QLDB驱动程序为例,并记录了在那里产生的最终交易哈希。在事务提交期间将其用于与QLDB端生成的哈希进行比较,以验证事务并允许其提交,这是python驱动程序成功完成的。

不过,还没有Go版本的IonHash,因此我在Go中实现了StartTransaction,InsertInto和CommitTransaction步骤,并包括一个Python可执行的IonHash实现,用于计算IonHashes,以便在最后比较摘要。

// Go (pseudocode)
import "github.com/fernomac/ion-go" as ion
import python_hash_module as python

func (client qldbClient) StartTransaction(transactionID string) {
// hash transactionID using python ionhash
}

func (client) InsertInto (statement string, params string) {
// MarshalText using ion module in aws-sdk
ionParam := ion.MarshalText(params)

// hash statement using python executable
client.statementHash = python.ion_hash(statement)

// hash parameters using python executable (only one parameter)
client.paramHash = python.ion_hash(ionParam)

// dot paramHash with statement hash
client.statementHash = client.statementHash.dot(client.paramHash)

// dot statement hash with transactionhash - this transaction hash matches the python calculation!
client.transactionHash = client.transactionHash.dot(statementHash)
}

func (client) Commit() {
res, err := client.execute(statement) // compares calculated transaction hash with AWS calculated transaction hash
if err != nil {
log.Prinln(err)
}

代码在提交步骤中失败,并显示以下错误:
{
Code_: "412",
Message_: "Digests don't match"
}
2020/03/22 11:16:41 xxxx.go:xxx: BadRequestException: Digests don't match
{
Code_: "412",
Message_: "Digests don't match"
}

我不明白为什么摘要在进行中的提交过程中不匹配,当此实现产生与提交的python代码相同的摘要时。当python代码产生与go代码相同的提交时,为什么不提示摘要不匹配?更重要的是,如何通过Go(而不是python或节点驱动程序)成功插入QLDB?

最佳答案

不确定这是否仍然有用,但是亚马逊最近发布了QLDB Go Driver的预览版(https://github.com/awslabs/amazon-qldb-driver-go)。
它具有Ion和Ion Hash作为依存关系,因此在使用QLDB时,这应该使您更轻松。

关于python - 插入QLDB时摘要不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60802667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com