CreateOracle compiles and stores a raw *pb.Oracle object. If successful, the identifier of the newly created oracle is returned as the response message.
(ctx context.Context, oracle *pb.Oracle)
| 21 | // CreateOracle compiles and stores a raw *pb.Oracle object. If successful, the |
| 22 | // identifier of the newly created oracle is returned as the response message. |
| 23 | func (s *Service) CreateOracle(ctx context.Context, oracle *pb.Oracle) (*pb.OracleResponse, error) { |
| 24 | if compiled, err := compile(oracle); err != nil { |
| 25 | return errOracleResponse("%s", err), nil |
| 26 | } else if err := s.oracles.Create(oracle); err != nil { |
| 27 | return errOracleResponse("%s", err), nil |
| 28 | } else { |
| 29 | s.cache.Add(oracle.Id, compiled) |
| 30 | } |
| 31 | return &pb.OracleResponse{Success: true, Msg: fmt.Sprintf("%d", oracle.Id)}, nil |
| 32 | } |
| 33 | |
| 34 | // UpdateOracle updates the contents of an oracle with the ones of a raw *pb.Oracle |
| 35 | // object given its identifier. |
nothing calls this directly
no test coverage detected