public IActionResult BlockFound(string address, [FromBody] BlockResource confirmation) { if (!ModelState.IsValid) { Console.WriteLine("shit"); return(BadRequest(ModelState)); } Block lastMiningBlock = this._nodeService.GetMiningJob(address); lastMiningBlock.MinedBy = address; lastMiningBlock.Nonce = confirmation.Nonce; lastMiningBlock.BlockHash = confirmation.BlockHash; lastMiningBlock.CreatedOn = DateTime.Parse(confirmation.CreatedOn); // Block confirmedBlock = this._mapper.Map<BlockResource, Block>(confirmedBlockResource); if (!this._nodeService.IsBlockValid(lastMiningBlock)) { return(BadRequest("Not valid block")); } this._nodeService.PayForBlock(address); this._nodeService.UpdateBlockchain(lastMiningBlock); return(Ok()); }
public IActionResult GetCandidate(string address) { Block candidateBlock = this._nodeService.GetBlockCandidate(); this._nodeService.AddMiningJob(address, candidateBlock); candidateBlock.MinedBy = this._nodeService.GetAddress(address).AddressId; BlockResource candidateResource = this._mapper.Map <Block, BlockResource>(candidateBlock); return(Ok(candidateResource)); }
public IActionResult GetBlock(int index) { Block block = this._nodeService.GetBlock(index); if (block == null) { return(NotFound($"Block with index '{index}' not found.")); } BlockResource blockResource = this._mapper.Map <Block, BlockResource>(block); Console.WriteLine(blockResource.Index); return(Ok(block)); }
public Block(Block block) : this(block._heroType, block.blockType, block.x, block.y) { this.blockResource = block.blockResource; }
void CreateObject() { if (blockResource == null) { blockResource = BlockResource.Create(_heroType, _blockType); blockResource.transform.parent = PuzzlePanel.BoardLayer.transform; GameObjectTool.SetLayerRecursively(blockResource.gameObject, PuzzlePanel.CullingLayer); Offset = new Vector2(x, y); //overlayAlpha = 0; } }
void DestroyGameObject() { if (blockResource != null) { RecycleManager.Instance.DestroyRecursively(blockResource.gameObject); blockResource = null; } }
public Block(Block block) : this(block.entity, block.x, block.y) { this.blockResource = block.blockResource; }