package main import ( "encoding/json" log "github.com/sirupsen/logrus" ) type SteemAPI struct { url string rpc *JSONRPC Debug bool log *log.Logger } func NewSteemAPI(url string, options ...func(s *SteemAPI)) *SteemAPI { rpc := NewJSONRPC(url, func(x *JSONRPC) { x.Debug = true }) self := &SteemAPI{ rpc: rpc, } self.log = log.New() for _, option := range options { option(self) } return self } func (self *SteemAPI) GetOpsInBlock(blockNum int) (GetOpsInBlockResponse, error) { // first fetch virtual ops vOpsParams := &GetOpsInBlockRequestParams{BlockNum: blockNum, VirtualOps: true} vop, err := vOpsParams.MarshalJSON() vOpsResponse, err := self.rpc.Call("condenser_api.get_ops_in_block", vop) if err != nil { return nil, err } var result []OperationObject err = json.Unmarshal(vOpsResponse, &result) if err != nil { return nil, err } // result is now populated with vops, now get real ops realOpsParams := &GetOpsInBlockRequestParams{BlockNum: blockNum, VirtualOps: false} rop, err := realOpsParams.MarshalJSON() realOpsResponse, err := self.rpc.Call("condenser_api.get_ops_in_block", rop) var secondResult []OperationObject err = json.Unmarshal(realOpsResponse, &secondResult) if err != nil { return nil, err } result = append(result, secondResult...) return result, nil }