//通道ID
type ChannelID *big.Int
//区块高度
type BlockHeight *big.Int
//签名
type Signature []byte
//支付收据
type SpendVoucher struct {
Channel ChannelID
Amount *TokenAmount
Sig Signature
}
type PaymentBroker interface {
//用以创建微支付通道
CreateChannel(target Address, eol BlockHeight) ChannelID
//用以更新微支付通道金额数量
Update(channel ChannelID, amt *TokenAmount, sig Signature)
//用以关闭微支付通道
Close(channel ChannelID, amt *TokenAmount, sig Signature)
//用以增加资金
Extend(target Address, channel ChannelID, eol BlockHeight)
//用以收回未使用的资金
Reclaim(target Address, channel ChannelID)
}
// 生成收据信息
func MakeSpendVoucher(ch ChannelID, amt *TokenAmount, sk PrivateKey) *SpendVoucher {
data := concatBytes(ch, amt)
sig := sk.Sign(data)
return &SpendVoucher{
Channel: ch,
Amount: amt,
Sig: sig,
}
}
5.6.1 通过CID检索数据内容 USAGE
filecoin retr get - Retrieve a piece from a miner.
SYNOPSIS
filecoin retr get [--price=] [--miner=] [--]
ARGUMENTS
- Content ID of piece to retrieve.
OPTIONS
--price string - Amount of filecoin to offer for this data.
--miner string - Optional Peer ID of miner to connect to. (If unspecified, the chain routing service will be used)
5.6.2 根据CID查看被检索数据的所有检索报价 USAGE
filecoin retr lookup - Print a list of miners who have the given piece.
SYNOPSIS
filecoin retr lookup [--sort=] [--]
ARGUMENTS
... - Content ID of piece to find.
OPTIONS
--sort string - Output sorting scheme.
5.6.3 通过矿工ID查询该检索矿工的信息 USAGE
filecoin retr query [] - Query the given retrieval miner.
SYNOPSIS
filecoin retr query [--] []
ARGUMENTS
- ID of miner to query.
[] - Optional cid of piece to query for.