- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
开始之前的相关信息:我已经搜索了 stackoverflow,并发现了类似的标题问题,但我不认为它们是我的重复项,因为它们有一个关键的区别,它们似乎有包含引用的对象给自己,造成圈子。我没有那个。 <-- 请阅读此内容而不是立即将其标记为受骗者 - 我需要这方面的真正帮助。
编辑:我找到了答案,但是 stackoverflow 几天后都不让我发布答案,事实证明 elliptic 只能接受十六进制值——这意味着你必须这样调用它:
this.keyPair.sign(dataHash).toHex();
在下面为可能遇到此问题的其他人留下问题。
我有这个 javascript 对象:
Transaction {
id: '2ec34280-567d-11e9-9685-4903db7a1a5b',
type: 'TRANSACTION',
input:
{ timestamp: 1554343126696,
from:
'6db64cd01c27a723395a833d72b3cc81f9110b5ffb34429d91f45fcbfd87ec9b',
signature:
Signature {
eddsa: [EDDSA],
_R: [Point],
_S: [BN],
_Rencoded: [Array],
_Sencoded: undefined } },
output: { to: 'rand-address', amount: 9, fee: 1 } }
当我尝试对其执行 res.json 时,我似乎收到此错误:
TypeError: Converting circular structure to JSON
一些可能相关的代码:
// Endpoint that a user accesses (the start of the event)
app.post("/transact", (req, res) => {
const { to, amount, type } = req.body;
const transaction = wallet.createTransaction(
to,
amount,
type,
blockchain,
transactionPool
);
res.redirect("/transactions");
});
上面提到的 createTransaction 方法看起来像这样:
createTransaction(to, amount, type, blockchain, transactionPool) {
this.balance = this.getBalance(blockchain);
if (amount > balance) {
console.log(
`Amount: ${amount} exceeds the current balance: ${this.balance}`
);
return;
}
let transaction = Transaction.newTransaction(this, to, amount, type);
transactionPool.addTransaction(transaction);
return transaction;
}
新交易方法:
static newTransaction(senderWallet, to, amount, type) {
if (amount + TRANSACTION_FEE > senderWallet.balance) {
console.log(`Not enough balance`);
return;
}
return Transaction.generateTransaction(senderWallet, to, amount, type);
}
调用下面的 generateTransaction 方法:
static generateTransaction(senderWallet, to, amount, type) {
const transaction = new this();
transaction.type = type;
transaction.output = {
to: to,
amount: amount - TRANSACTION_FEE,
fee: TRANSACTION_FEE
};
Transaction.signTransaction(transaction, senderWallet);
return transaction;
}
依次调用 signTransaction 方法:
static signTransaction(transaction, senderWallet) {
transaction.input = {
timestamp: Date.now(),
from: senderWallet.publicKey,
signature: senderWallet.sign(ChainUtil.hash(transaction.output))
};
}
chainUtil 哈希函数如下所示:
static hash(data){
return SHA256(JSON.stringify(data)).toString();
}
钱包类的签名方法:
sign(dataHash){
return this.keyPair.sign(dataHash);
}
他们都回来了,我得到了我在这个问题顶部提到的对象。我根本看不出问题是循环错误。请教育我。
最佳答案
我找到了答案,原来 Elliptic 只允许你使用十六进制字符串...所以为了使这项工作有效,我的钱包代码中进行了更改,如下所示:
this.keyPair.sign(dataHash).toHex();
代替
this.keyPair.sign(dataHash);
关于javascript - 椭圆形 : TypeError : Converting circular structure to JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55506886/
这是我第一次在结构中使用结构。我在编译我的程序时遇到了这个错误。错误:字段“结果”的类型不完整。 错误是指这行代码。-->结构result_t结果; 有什么帮助吗? :)谢谢。 typedef str
typedef struct mensagem { int sender ; int receiver ; char *text ; } *Item ; typedef str
我正在使用 ExpressionEngine 和 Structure 附加组件的最新版本。 我正在寻找有关生成 4 项导航栏的帮助,其中两项位于不同的结构级别。 我的结构行如下所示: 服务(父) --
我正在处理一个非常大的数据集。本质上,我将处理数百万条记录并将值存储到数据集中。 每次我存储一个值时,我必须首先检查以确保该值不在数据结构中。如果值在数据结构中,我必须更新(或删除/添加)记录以更新计
我正在尝试分别使用视频帧和音频来分析视频,我想出了一个看起来像这样的模型 现在,我将训练数据分成两个生成器 - 一个用于视频,一个用于音频。我必须进一步将生成器分成两半,我认为这是我遇到错误的地方。因
我有一个创建 N 个进程的程序,每个进程创建 M 个线程。 我还有一个结构需要传递给线程函数。 当我像这样创建 M 个线程时: thread_args_t** thread_arg = malloc(
我正在试图弄清楚如何实现一个等待事件发出信号的函数。指针由DLL函数返回,该函数是存储3个项的结构。其中两个是句柄,它们只是指针,最后是一些随机的未使用的指针。我真的不确定这应该如何格式化,因为我两个
根据PLCOpen、IEC-61131标准,是否可以在声明中初始化结构体? 我正在考虑类似于 this C++ question 的事情. 最佳答案 您可以在结构声明时向结构变量添加默认值。您还可以在
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
在纯 C 中工作,将结构嵌套在其他结构或指向结构的指针中更好。使用指针可以更容易地实现良好的对齐,但是访问内部结构需要额外的取消引用。只是具体地说: typedef struct {
我正在使用 Qt Creator 开发应用程序。 我不是一个好的C++程序员,所以可能会有概念上的错误等。 我在复制结构数组并返回结构时遇到问题。 有很多与类似标题相关的解决方案,但无法解决我的问题。
我正在尝试使用带水印的 dropDuplicate 函数对流数据进行重复数据删除。我目前面临的问题是我必须为给定记录设置两个时间戳 一个是事件时间戳 - 从源创建记录的时间戳。 另一个是传输时间戳 -
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 10年前关
我尝试构建一个嵌套循环,用于创建 2 维零矩阵来解决 LCS 问题(动态规划)。这后来用于计算 Rouge-L 分数(输入是张量,而不是字符串),但它总是出错引发 ValueError: The tw
我曾多次使用 HDFS 和 Kafka,我注意到 Kafka 比 HDFS 更可靠。因此,现在使用 Spark-structured-streaming 时,我很惊讶检查点仅适用于 HDFS。使用 K
C11,6.7.2.1 结构和 union 说明符,约束,3(添加了强调): A structure or union shall not contain a member with incomple
在 emacs lisp 中,各种树结构是常见的。 custom.el通过:type提供论据 defcustom定义自定义变量的预期形状的标准方法。但是有没有一种标准的方法来验证一些随机 emacs
我在网上遇到了以下面试问题。 描述一个数据结构,其中 getValue(int index)、setValue(int index, int value) 和 setAllValues(int val
我正在使用 sqldf 对一个巨大的文件进行子集化。以下命令为我提供了一个 100 行和 42 列的 data.frame。 first <- read.csv.sql("first.txt", se
来自这里的 C++ 背景。我需要为我的一门类(class)编写 C 语言,但我从未接触过这一类(class)。这两个声明之间有什么区别?为什么要包含 struct 关键字?有不同的含义吗?它们在 C+
我是一名优秀的程序员,十分优秀!