func (this *RestServer) handleTransact(c *gin.Context) { _, hold := c.Get("hold") param := &TransactParam{} errD := this.codec.Decode(param, c.Request.Body) if errD != nil { c.AbortWithError(500, errD) } if hold { res, err := this.pipe.Transactor().TransactAndHold(param.PrivKey, param.Address, param.Data, param.GasLimit, param.Fee) if err != nil { c.AbortWithError(500, err) } c.Writer.WriteHeader(200) this.codec.Encode(res, c.Writer) } else { receipt, err := this.pipe.Transactor().Transact(param.PrivKey, param.Address, param.Data, param.GasLimit, param.Fee) if err != nil { c.AbortWithError(500, err) } c.Writer.WriteHeader(200) this.codec.Encode(receipt, c.Writer) } }
func (this *RestServer) handleNameRegEntries(c *gin.Context) { var filters []*ep.FilterData fs, exists := c.Get("filters") if exists { filters = fs.([]*ep.FilterData) } entries, err := this.pipe.NameReg().Entries(filters) if err != nil { c.AbortWithError(500, err) } c.Writer.WriteHeader(200) this.codec.Encode(entries, c.Writer) }
func (this *RestServer) handleBlocks(c *gin.Context) { var filters []*ep.FilterData fs, exists := c.Get("filters") if exists { filters = fs.([]*ep.FilterData) } blocks, err := this.pipe.Blockchain().Blocks(filters) if err != nil { c.AbortWithError(500, err) } c.Writer.WriteHeader(200) this.codec.Encode(blocks, c.Writer) }