/// <summary> /// Builds the boss table. The boss table contains an entry for each participating member /// node on the network. /// </summary> /// <param name="blockHeight">The height of the block containing the crosschain transaction</param> /// <param name="keys">An array of the public keys of each federation member.</param> /// <returns></returns> public BossTable Build(int blockHeight, IEnumerable <string> keys) { var bossCards = keys .Select(key => BossTable.MakeBossTableEntry(blockHeight, key).ToString()) .OrderBy(k => k); return(new BossTable(bossCards.ToList())); }
public MonitorChainSession(int blockNumber, string[] federationPubKeys, string myPublicKey) { this.Status = SessionStatus.Created; this.startTime = DateTime.Now; this.CrossChainTransactions = new List <CrossChainTransactionInfo>(); this.BlockNumber = blockNumber; this.BossTable = new BossTableBuilder().Build(blockNumber, federationPubKeys); this.BossCard = BossTable.MakeBossTableEntry(blockNumber, myPublicKey).ToString(); }
/// <summary> /// Builds the boss table. The boss table contains an entry for each participating member /// node on the network. /// </summary> /// <param name="blockHeight">The height of the block containing the crosschain transaction</param> /// <param name="keys">An array of the public keys of each federation member.</param> /// <returns></returns> public BossTable Build(int blockHeight, IEnumerable <string> keys) { // BossTableEntries are strings. // Hash the concatination of the sessionId and the key to get each entry in the table. var bossCards = keys .Select(key => BossTable.MakeBossTableEntry(blockHeight, key).ToString()) .OrderBy(k => k); // We now have a table that is reproducable on every federation node on the network. return(new BossTable(bossCards.ToList())); }
private async Task OnMessageReceivedAsync(INetworkPeer peer, IncomingMessage message) { this.logger.LogTrace("({0}:'{1}',{2}:'{3}')", nameof(peer), peer.RemoteSocketEndpoint, nameof(message), message.Message.Command); if (message.Message.Payload is RequestPartialTransactionPayload payload) { this.logger.LogInformation("RequestPartialTransactionPayload received."); this.logger.LogInformation("OnMessageReceivedAsync: {0}", this.network.ToChain()); this.logger.LogInformation("RequestPartialTransactionPayload: BossCard - {0}.", payload.BossCard); this.logger.LogInformation("RequestPartialTransactionPayload: BlockHeight - {0}.", payload.BlockHeight); this.logger.LogInformation("RequestPartialTransactionPayload: PartialTransaction - {0}.", payload.PartialTransaction); this.logger.LogInformation("RequestPartialTransactionPayload: TemplateTransaction - {0}.", payload.TemplateTransaction); if (payload.BossCard == uint256.Zero) { //get the template from the payload this.logger.LogInformation("OnMessageReceivedAsync: Payload has no bossCard -> signing partial."); var template = payload.TemplateTransaction; var partialTransactionSession = this.counterChainSessionManager.VerifySession(payload.BlockHeight, template); if (partialTransactionSession == null) { return; } this.counterChainSessionManager.MarkSessionAsSigned(partialTransactionSession); var wallet = this.federationWalletManager.GetWallet(); var signedTransaction = wallet.SignPartialTransaction(template, this.federationWalletManager.Secret.WalletPassword); payload.AddPartial(signedTransaction, BossTable.MakeBossTableEntry(payload.BlockHeight, this.federationGatewaySettings.PublicKey)); this.logger.LogInformation("OnMessageReceivedAsync: PartialTransaction signed."); this.logger.LogInformation("RequestPartialTransactionPayload: BossCard - {0}.", payload.BossCard); this.logger.LogInformation("RequestPartialTransactionPayload: PartialTransaction - {0}.", payload.PartialTransaction); this.logger.LogInformation("Broadcasting Payload...."); await this.Broadcast(payload); this.logger.LogInformation("Broadcasted."); } else { //we got a partial back this.logger.LogInformation("RequestPartialTransactionPayload: PartialTransaction received."); this.counterChainSessionManager.ReceivePartial(payload.BlockHeight, payload.PartialTransaction, payload.BossCard); } } this.logger.LogTrace("(-)"); }