本文整理匯總了Golang中github.com/ipfs/go-ipfs/thirdparty/testutil.Identity.ID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Identity.ID方法的具體用法?Golang Identity.ID怎麽用?Golang Identity.ID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ipfs/go-ipfs/thirdparty/testutil.Identity
的用法示例。
在下文中一共展示了Identity.ID方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Session
// session creates a test bitswap session.
//
// NB: It's easy make mistakes by providing the same peer ID to two different
// sessions. To safeguard, use the SessionGenerator to generate sessions. It's
// just a much better idea.
func Session(ctx context.Context, net tn.Network, p testutil.Identity) Instance {
bsdelay := delay.Fixed(0)
const bloomSize = 512
const writeCacheElems = 100
adapter := net.Adapter(p)
dstore := ds_sync.MutexWrap(datastore2.WithDelay(ds.NewMapDatastore(), bsdelay))
bstore, err := blockstore.CachedBlockstore(blockstore.NewBlockstore(
ds_sync.MutexWrap(dstore)), ctx, blockstore.DefaultCacheOpts())
if err != nil {
panic(err.Error()) // FIXME perhaps change signature and return error.
}
const alwaysSendToPeer = true
bs := New(ctx, p.ID(), adapter, bstore, alwaysSendToPeer).(*Bitswap)
return Instance{
Peer: p.ID(),
Exchange: bs,
blockstore: bstore,
blockstoreDelay: bsdelay,
}
}
示例2: Adapter
func (n *network) Adapter(p testutil.Identity) bsnet.BitSwapNetwork {
client := &networkClient{
local: p.ID(),
network: n,
routing: n.routingserver.Client(p),
}
n.clients[p.ID()] = client
return client
}