本文整理汇总了C#中Protocol.SendMessageAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Protocol.SendMessageAsync方法的具体用法?C# Protocol.SendMessageAsync怎么用?C# Protocol.SendMessageAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol.SendMessageAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachedNode_MessageReceived
void AttachedNode_MessageReceived(Protocol.Node node, Protocol.IncomingMessage message)
{
var merkleBlock = message.Message.Payload as MerkleBlockPayload;
if(merkleBlock != null)
{
if(!CheckFPRate(merkleBlock))
{
return;
}
foreach(var txId in merkleBlock.Object.PartialMerkleTree.GetMatchedTransactions())
{
_TransactionsToBlock.AddOrUpdate(txId, merkleBlock.Object, (k, v) => merkleBlock.Object);
var tx = _Tracker.GetKnownTransaction(txId);
if(tx != null)
{
Notify(tx, merkleBlock.Object);
}
}
var h = merkleBlock.Object.Header.GetHash();
uint256 unused;
if(_InFlight.TryRemove(h, out unused))
{
if(_InFlight.Count == 0)
{
UpdateCurrentProgress(h);
StartScan(unused);
}
}
}
var pong = message.Message.Payload as PongPayload;
if(pong != null)
{
var ping = _RunningPing;
if(ping != null && pong.Nonce == ping.Nonce)
{
_RunningPing = null;
_FilterState = SPV.FilterState.Loaded;
foreach(var item in _OnFilterLoaded)
{
item();
}
_OnFilterLoaded = new ConcurrentBag<Action>();
}
}
var notfound = message.Message.Payload as NotFoundPayload;
if(notfound != null)
{
foreach(var txid in notfound)
{
uint256 unusued;
if(_InFlight.TryRemove(txid.Hash, out unusued))
{
if(_InFlight.Count == 0)
StartScan(null);
}
}
}
var invs = message.Message.Payload as InvPayload;
if(invs != null)
{
foreach(var inv in invs)
{
if((inv.Type & InventoryType.MSG_BLOCK) != 0)
node.SendMessageAsync(new GetDataPayload(new InventoryVector(InventoryType.MSG_FILTERED_BLOCK, inv.Hash)));
if((inv.Type & InventoryType.MSG_TX) != 0)
node.SendMessageAsync(new GetDataPayload(inv));
}
}
var txPayload = message.Message.Payload as TxPayload;
if(txPayload != null)
{
var tx = txPayload.Object;
MerkleBlock blk;
var h = tx.GetHash();
_TransactionsToBlock.TryGetValue(h, out blk);
Notify(tx, blk);
}
}
示例2: AttachedNode_MessageReceived
void AttachedNode_MessageReceived(Protocol.Node node, Protocol.IncomingMessage message)
{
var merkleBlock = message.Message.Payload as MerkleBlockPayload;
if(merkleBlock != null)
{
foreach(var txId in merkleBlock.Object.PartialMerkleTree.GetMatchedTransactions())
{
_TransactionsToBlock.AddOrUpdate(txId, merkleBlock.Object, (k, v) => merkleBlock.Object);
var tx = _Tracker.GetKnownTransaction(txId);
if(tx != null)
{
Notify(tx, merkleBlock.Object);
}
}
var h = merkleBlock.Object.Header.GetHash();
uint256 unused;
if(_InFlight.TryRemove(h, out unused))
{
if(_InFlight.Count == 0)
{
_LastSeen = h;
var chained = _Chain.GetBlock(h);
_CurrentProgress = chained == null ? _CurrentProgress : chained.GetLocator();
StartScan(unused);
}
}
}
var notfound = message.Message.Payload as NotFoundPayload;
if(notfound != null)
{
foreach(var txid in notfound)
{
uint256 unusued;
if(_InFlight.TryRemove(txid.Hash, out unusued))
{
if(_InFlight.Count == 0)
StartScan(null);
}
}
}
var invs = message.Message.Payload as InvPayload;
if(invs != null)
{
foreach(var inv in invs)
{
if(inv.Type == InventoryType.MSG_BLOCK)
node.SendMessageAsync(new GetDataPayload(new InventoryVector(InventoryType.MSG_FILTERED_BLOCK, inv.Hash)));
if(inv.Type == InventoryType.MSG_TX)
node.SendMessageAsync(new GetDataPayload(inv));
}
}
var txPayload = message.Message.Payload as TxPayload;
if(txPayload != null)
{
var tx = txPayload.Object;
MerkleBlock blk;
var h = tx.GetHash();
_TransactionsToBlock.TryGetValue(h, out blk);
Notify(tx, blk);
}
}