Transactions 事务的数据保存在哪里?
为了介绍我的问题,我想举一个例子。假设一位顾客想加入健身房。将发送一个事务并包含:Transactions 事务的数据保存在哪里?,transactions,blockchain,ethereum,smartcontracts,Transactions,Blockchain,Ethereum,Smartcontracts,为了介绍我的问题,我想举一个例子。假设一位顾客想加入健身房。将发送一个事务并包含: 客户id 姓名 开始日期 结束日期 智能合约接收交易并在健身房创建会员资格。这些数据保存在哪里?过了一段时间后,我想确认订阅尚未过期,并发送一个检查请求。我是否可以仅指定id,然后通过订阅的id搜索指定智能合约?我的意思是,智能合约可以在知道id的情况下访问订阅吗?智能合约能否接受与发送的id匹配的订阅并进行检查 我无法理解永久保存在区块链上的数据(该数据何时保存?)与保存在智能合约中的数据(智能合约是否有存
- 客户id
- 姓名
- 开始日期
- 结束日期
检查请求
。我是否可以仅指定id,然后通过订阅的id搜索指定智能合约?我的意思是,智能合约可以在知道id的情况下访问订阅吗?智能合约能否接受与发送的id匹配的订阅并进行检查
我无法理解永久保存在区块链上的数据(该数据何时保存?)与保存在智能合约中的数据(智能合约是否有存储?)之间的差异。是否存在差异?我知道这个问题很琐碎,但我无法理解。作为交易一部分传输的数据(方法和参数)存储在区块链中。合同的事务处理结果存储在每个节点的本地存储器中。合同可随时访问其数据 合同示例如下:
- AddCustomer方法以事务方式调用并添加用户
- GetCustomerById方法称为“本地”,并通过其标识符显示用户数据
因此,如果我想验证客户的订阅,我是否必须再次传递所有数据(id、城市、开始日期、结束日期)?是的,如果合同保存了最后一个问题,以确保我正确理解您。什么是合同存储?添加合同样本以回答问题。合同存储是描述合同状态的数据
pragma solidity 0.5.0;
contract Gym
{
address Owner ;
struct Customer
{
bytes32 name ;
bytes32 surname ;
bytes32 start_date ;
bytes32 end_date ;
}
mapping (bytes32 => Customer) Customers ;
constructor() public
{
Owner = tx.origin ;
}
function AddCustomer(bytes32 id_, bytes32 name_, bytes32 surname_, bytes32 start_date_, bytes32 end_date_) public
{
Customers[id_]=Customer({ name: name_,
surname: surname_,
start_date: start_date_,
end_date: end_date_
}) ;
}
function GetCustomerById(bytes32 id_) public view returns (bytes32, bytes32, bytes32, bytes32 retVal)
{
return(Customers[id_].name, Customers[id_].surname, Customers[id_].start_date, Customers[id_].end_date) ;
}
}