parent
f72c321426
commit
ccd88c3af8
4 changed files with 58 additions and 1 deletions
|
@ -53,7 +53,7 @@ which would yield the response:
|
|||
| `getrawmempool` | Yes |
|
||||
| `getrawtransaction` | Yes |
|
||||
| `getstorage` | Yes |
|
||||
| `gettransactionheight` | No (#713) |
|
||||
| `gettransactionheight` | Yes |
|
||||
| `gettxout` | Yes |
|
||||
| `getunclaimed` | No (#712) |
|
||||
| `getunspents` | Yes |
|
||||
|
|
|
@ -147,6 +147,14 @@ var (
|
|||
},
|
||||
)
|
||||
|
||||
gettransactionheightCalled = prometheus.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Help: "Number of calls to gettransactionheight rpc endpoint",
|
||||
Name: "gettransactionheight_called",
|
||||
Namespace: "neogo",
|
||||
},
|
||||
)
|
||||
|
||||
gettxoutCalled = prometheus.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Help: "Number of calls to gettxout rpc endpoint",
|
||||
|
@ -206,6 +214,7 @@ func init() {
|
|||
getassetstateCalled,
|
||||
getaccountstateCalled,
|
||||
getunspentsCalled,
|
||||
gettransactionheightCalled,
|
||||
gettxoutCalled,
|
||||
getrawtransactionCalled,
|
||||
sendrawtransactionCalled,
|
||||
|
|
|
@ -285,6 +285,10 @@ Methods:
|
|||
getrawtransactionCalled.Inc()
|
||||
results, resultsErr = s.getrawtransaction(reqParams)
|
||||
|
||||
case "gettransactionheight":
|
||||
gettransactionheightCalled.Inc()
|
||||
results, resultsErr = s.getTransactionHeight(reqParams)
|
||||
|
||||
case "gettxout":
|
||||
gettxoutCalled.Inc()
|
||||
results, resultsErr = s.getTxOut(reqParams)
|
||||
|
@ -589,6 +593,25 @@ func (s *Server) getrawtransaction(reqParams request.Params) (interface{}, error
|
|||
return results, resultsErr
|
||||
}
|
||||
|
||||
func (s *Server) getTransactionHeight(ps request.Params) (interface{}, error) {
|
||||
p, ok := ps.Value(0)
|
||||
if !ok {
|
||||
return nil, response.ErrInvalidParams
|
||||
}
|
||||
|
||||
h, err := p.GetUint256()
|
||||
if err != nil {
|
||||
return nil, response.ErrInvalidParams
|
||||
}
|
||||
|
||||
_, height, err := s.chain.GetTransaction(h)
|
||||
if err != nil {
|
||||
return nil, response.NewRPCError("unknown transaction", "", nil)
|
||||
}
|
||||
|
||||
return height, nil
|
||||
}
|
||||
|
||||
func (s *Server) getTxOut(ps request.Params) (interface{}, error) {
|
||||
p, ok := ps.Value(0)
|
||||
if !ok {
|
||||
|
|
|
@ -576,6 +576,31 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
fail: true,
|
||||
},
|
||||
},
|
||||
"gettransactionheight": {
|
||||
{
|
||||
name: "poositive",
|
||||
params: `["3fee783413c27849c8ee2656fd757a7483de64f4e78bd7897f30ecdf42ce788b"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
h := 202
|
||||
return &h
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no params",
|
||||
params: `[]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
name: "invalid hash",
|
||||
params: `["notahex"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
name: "missing hash",
|
||||
params: `["` + util.Uint256{}.String() + `"]`,
|
||||
fail: true,
|
||||
},
|
||||
},
|
||||
"getunspents": {
|
||||
{
|
||||
name: "positive",
|
||||
|
|
Loading…
Reference in a new issue