本文整理汇总了Golang中github.com/stellar/horizon/render/hal.LinkBuilder类的典型用法代码示例。如果您正苦于以下问题:Golang LinkBuilder类的具体用法?Golang LinkBuilder怎么用?Golang LinkBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinkBuilder类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Populate
// Populate fills out the details
func (res *TransactionSuccess) Populate(ctx context.Context, result txsub.Result) {
res.Hash = result.Hash
res.Ledger = result.LedgerSequence
res.Env = result.EnvelopeXDR
res.Result = result.ResultXDR
res.Meta = result.ResultMetaXDR
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
res.Links.Transaction = lb.Link("/transactions", result.Hash)
return
}
开发者ID:zenododobird,项目名称:horizon,代码行数:12,代码来源:transaction_success.go
示例2: Populate
func (this *Base) Populate(ctx context.Context, row db.EffectRecord) {
this.ID = row.ID()
this.PT = row.PagingToken()
this.Account = row.Account
this.populateType(row)
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
this.Links.Operation = lb.Linkf("/operations/%d", row.HistoryOperationID)
this.Links.Succeeds = lb.Linkf("/effects?order=desc&cursor=%s", this.PT)
this.Links.Precedes = lb.Linkf("/effects?order=asc&cursor=%s", this.PT)
}
开发者ID:zenododobird,项目名称:horizon,代码行数:11,代码来源:base.go
示例3: Populate
func (this *Offer) Populate(ctx context.Context, row db.CoreOfferRecord) {
this.ID = row.OfferID
this.PT = row.PagingToken()
this.Seller = row.SellerID
this.Amount = amount.String(row.Amount)
this.PriceR.N = row.Pricen
this.PriceR.D = row.Priced
this.Price = row.PriceAsString()
this.Buying = Asset{
Type: assets.MustString(row.BuyingAssetType),
Code: row.BuyingAssetCode.String,
Issuer: row.BuyingIssuer.String,
}
this.Selling = Asset{
Type: assets.MustString(row.SellingAssetType),
Code: row.SellingAssetCode.String,
Issuer: row.SellingIssuer.String,
}
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
this.Links.Self = lb.Linkf("/offers/%d", row.OfferID)
this.Links.OfferMaker = lb.Linkf("/accounts/%s", row.SellerID)
return
}
开发者ID:zenododobird,项目名称:horizon,代码行数:24,代码来源:offer.go
示例4: Populate
// Populate fills out the details
func (res *Trade) Populate(ctx context.Context, row history.Effect) (err error) {
if row.Type != history.EffectTrade {
err = errors.New("invalid effect; not a trade")
return
}
row.UnmarshalDetails(res)
res.ID = row.PagingToken()
res.PT = row.PagingToken()
res.Buyer = row.Account
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
res.Links.Self = lb.Link("/accounts", res.Seller)
res.Links.Seller = lb.Link("/accounts", res.Seller)
res.Links.Buyer = lb.Link("/accounts", res.Buyer)
return
}
开发者ID:irisli,项目名称:horizon,代码行数:17,代码来源:trade.go
示例5: Populate
// Populate fills in the details
func (res *Root) Populate(ctx context.Context, row db.LedgerState, hVersion string, cVersion string) {
res.HorizonSequence = row.HorizonSequence
res.StellarCoreSequence = row.StellarCoreSequence
res.HorizonVersion = hVersion
res.StellarCoreVersion = cVersion
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
res.Links.Account = lb.Link("/accounts/{address}")
res.Links.AccountTransactions = lb.PagedLink("/accounts/{address}/transactions")
res.Links.Friendbot = lb.Link("/friendbot{?addr}")
res.Links.Metrics = lb.Link("/metrics")
res.Links.OrderBook = lb.Link("/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer}")
res.Links.Self = lb.Link("/")
res.Links.Transaction = lb.Link("/transactions/{hash}")
res.Links.Transactions = lb.PagedLink("/transactions")
}
开发者ID:masonforest,项目名称:horizon,代码行数:17,代码来源:root.go
示例6: Populate
func (this *Ledger) Populate(ctx context.Context, row db.LedgerRecord) {
this.ID = row.LedgerHash
this.PT = row.PagingToken()
this.Hash = row.LedgerHash
this.PrevHash = row.PreviousLedgerHash.String
this.Sequence = row.Sequence
this.TransactionCount = row.TransactionCount
this.OperationCount = row.OperationCount
this.ClosedAt = row.ClosedAt
this.TotalCoins = amount.String(xdr.Int64(row.TotalCoins))
this.FeePool = amount.String(xdr.Int64(row.FeePool))
this.BaseFee = row.BaseFee
this.BaseReserve = amount.String(xdr.Int64(row.BaseReserve))
this.MaxTxSetSize = row.MaxTxSetSize
self := fmt.Sprintf("/ledgers/%d", row.Sequence)
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
this.Links.Self = lb.Link(self)
this.Links.Transactions = lb.PagedLink(self, "transactions")
this.Links.Operations = lb.PagedLink(self, "operations")
this.Links.Payments = lb.PagedLink(self, "payments")
this.Links.Effects = lb.PagedLink(self, "effects")
return
}
开发者ID:zenododobird,项目名称:horizon,代码行数:25,代码来源:ledger.go
示例7: Populate
func (this *Account) Populate(ctx context.Context, row db.AccountRecord) (err error) {
this.ID = row.Accountid
this.PT = row.PagingToken()
this.Address = row.Accountid
this.Sequence = row.Seqnum
this.SubentryCount = row.Numsubentries
this.InflationDestination = row.Inflationdest.String
this.HomeDomain = row.HomeDomain.String
this.Flags.Populate(ctx, row)
this.Thresholds.Populate(ctx, row)
// populate balances
this.Balances = make([]Balance, len(row.Trustlines)+1)
for i, tl := range row.Trustlines {
err = this.Balances[i].Populate(ctx, tl)
if err != nil {
return
}
}
// add native balance
err = this.Balances[len(this.Balances)-1].PopulateNative(row.Balance)
if err != nil {
return
}
// populate signers
this.Signers = make([]Signer, len(row.Signers)+1)
for i, s := range row.Signers {
this.Signers[i].Populate(ctx, s)
}
this.Signers[len(this.Signers)-1].PopulateMaster(row)
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
self := fmt.Sprintf("/accounts/%s", row.Address)
this.Links.Self = lb.Link(self)
this.Links.Transactions = lb.PagedLink(self, "transactions")
this.Links.Operations = lb.PagedLink(self, "operations")
this.Links.Payments = lb.PagedLink(self, "payments")
this.Links.Effects = lb.PagedLink(self, "effects")
this.Links.Offers = lb.PagedLink(self, "Offers")
return
}
开发者ID:masonforest,项目名称:horizon,代码行数:46,代码来源:account.go
示例8: Populate
// Populate fills out the details
func (res *Transaction) Populate(
ctx context.Context,
row history.Transaction,
) (err error) {
res.ID = row.TransactionHash
res.PT = row.PagingToken()
res.Hash = row.TransactionHash
res.Ledger = row.LedgerSequence
res.LedgerCloseTime = row.LedgerCloseTime
res.Account = row.Account
res.AccountSequence = row.AccountSequence
res.FeePaid = row.FeePaid
res.OperationCount = row.OperationCount
res.EnvelopeXdr = row.TxEnvelope
res.ResultXdr = row.TxResult
res.ResultMetaXdr = row.TxMeta
res.FeeMetaXdr = row.TxFeeMeta
res.MemoType = row.MemoType
res.Memo = row.Memo.String
res.Signatures = strings.Split(row.SignatureString, ",")
res.ValidBefore = res.timeString(row.ValidBefore)
res.ValidAfter = res.timeString(row.ValidAfter)
lb := hal.LinkBuilder{Base: httpx.BaseURL(ctx)}
res.Links.Account = lb.Link("/accounts", res.Account)
res.Links.Ledger = lb.Link("/ledgers", fmt.Sprintf("%d", res.Ledger))
res.Links.Operations = lb.PagedLink("/transactions", res.ID, "operations")
res.Links.Effects = lb.PagedLink("/transactions", res.ID, "effects")
res.Links.Self = lb.Link("/transactions", res.ID)
res.Links.Succeeds = lb.Linkf("/transactions?order=desc&cursor=%s", res.PT)
res.Links.Precedes = lb.Linkf("/transactions?order=asc&cursor=%s", res.PT)
return
}
开发者ID:irisli,项目名称:horizon,代码行数:35,代码来源:transaction.go
示例9: Populate
func (this *Base) Populate(ctx context.Context, row history.Operation) {
this.ID = fmt.Sprintf("%d", row.ID)
this.PT = row.PagingToken()
this.SourceAccount = row.SourceAccount
this.populateType(row)
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
self := fmt.Sprintf("/operations/%d", row.ID)
this.Links.Self = lb.Link(self)
this.Links.Succeeds = lb.Linkf("/effects?order=desc&cursor=%s", this.PT)
this.Links.Precedes = lb.Linkf("/effects?order=asc&cursor=%s", this.PT)
this.Links.Transaction = lb.Linkf("/transactions/%s", row.TransactionHash)
this.Links.Effects = lb.Link(self, "effects")
}
开发者ID:irisli,项目名称:horizon,代码行数:14,代码来源:base.go
示例10: Populate
// Populate fills in the details
func (res *Root) Populate(ctx context.Context, hSeq, cSeq int32, hVersion, cVersion string, passphrase string) {
res.HorizonSequence = hSeq
res.StellarCoreSequence = cSeq
res.HorizonVersion = hVersion
res.StellarCoreVersion = cVersion
res.NetworkPassphrase = passphrase
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
res.Links.Account = lb.Link("/accounts/{account_id}")
res.Links.AccountTransactions = lb.PagedLink("/accounts/{account_id}/transactions")
res.Links.Friendbot = lb.Link("/friendbot{?addr}")
res.Links.Metrics = lb.Link("/metrics")
res.Links.OrderBook = lb.Link("/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer}")
res.Links.Self = lb.Link("/")
res.Links.Transaction = lb.Link("/transactions/{hash}")
res.Links.Transactions = lb.PagedLink("/transactions")
}
开发者ID:FihlaTV,项目名称:horizon,代码行数:18,代码来源:root.go
示例11: Populate
// Populate fills out the resource's fields
func (this *Account) Populate(
ctx context.Context,
ca core.Account,
cd []core.AccountData,
cs []core.Signer,
ct []core.Trustline,
ha history.Account,
) (err error) {
this.ID = ca.Accountid
this.PT = ha.PagingToken()
this.AccountID = ca.Accountid
this.Sequence = ca.Seqnum
this.SubentryCount = ca.Numsubentries
this.InflationDestination = ca.Inflationdest.String
this.HomeDomain = ca.HomeDomain.String
this.Flags.Populate(ca)
this.Thresholds.Populate(ca)
// populate balances
this.Balances = make([]Balance, len(ct)+1)
for i, tl := range ct {
err = this.Balances[i].Populate(ctx, tl)
if err != nil {
return
}
}
// add native balance
err = this.Balances[len(this.Balances)-1].PopulateNative(ca.Balance)
if err != nil {
return
}
// populate data
this.Data = make(map[string]string)
for _, d := range cd {
this.Data[d.Key] = d.Value
}
// populate signers
this.Signers = make([]Signer, len(cs)+1)
for i, s := range cs {
this.Signers[i].Populate(ctx, s)
}
this.Signers[len(this.Signers)-1].PopulateMaster(ca)
lb := hal.LinkBuilder{httpx.BaseURL(ctx)}
self := fmt.Sprintf("/accounts/%s", ha.Address)
this.Links.Self = lb.Link(self)
this.Links.Transactions = lb.PagedLink(self, "transactions")
this.Links.Operations = lb.PagedLink(self, "operations")
this.Links.Payments = lb.PagedLink(self, "payments")
this.Links.Effects = lb.PagedLink(self, "effects")
this.Links.Offers = lb.PagedLink(self, "offers")
return
}
开发者ID:irisli,项目名称:horizon,代码行数:60,代码来源:account.go
注:本文中的github.com/stellar/horizon/render/hal.LinkBuilder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论