Commit graph

201 commits

Author SHA1 Message Date
Roman Khimov
c4c080d240 rpc: add subscriber queue overflow check
Server-side test is added, but disabled because of its unreliability.
2020-05-26 11:36:47 +03:00
Roman Khimov
fc22a46a4c rpc/server: add notification subscription
Note that the protocol differs a bit from #895 in its notifications format,
to avoid additional server-side processing we're omitting some metadata like:
 * block size and confirmations
 * transaction fees, confirmations, block hash and timestamp
 * application execution doesn't have ScriptHash populated

Some block fields may also differ in encoding compared to `getblock` results
(like nonce field).

I think these differences are unnoticieable for most use cases, so we can
leave them as is, but it can be changed in the future.
2020-05-26 11:36:47 +03:00
Roman Khimov
612500ed96 rpc/server: start and shutdown Server in tests
It will be important for proper subscription testing and it doesn't hurt even
though technically we've got two http servers listening after this change (one
is a regular Server's http.Server and one is httptest's Server). Reusing
rpc.Server would be nice, but it requires some changes to Start sequence to
start Listener with net.Listen and then communicate back its resulting
Addr. It's not very convenient especially given that no other code needs it,
so doing these changes just for a bit cleaner testing seems like and
overkill.

Update config appropriately. Update Start comment along the way.
2020-05-25 00:27:39 +03:00
Anna Shaleva
7acf5b2841 core: add SystemFee and NetworkFee to transaction
closes #831
2020-05-20 23:26:48 +03:00
Roman Khimov
ec62edac68 rpc/server: add websockets support via '/ws' URL 2020-05-04 16:54:35 +03:00
Roman Khimov
1b523be4b6 rpc: shuffle handleHttpRequest/handleRequest responsibilities
Make handleRequest reusable in other contexts like websockets.
2020-05-04 13:57:23 +03:00
Roman Khimov
236f3dabdd rpc: change handlers to always return response.Error for errors
As it's expected by WriteErrorResponse() actually.
2020-05-04 13:57:15 +03:00
Roman Khimov
57de98e1a3 rpc/server: refactor handler methods a little
request.In is a natural request representation, one can always get
request.Params from it.
2020-05-04 13:57:08 +03:00
Roman Khimov
b83e84ca08 core: switch to the new voting system (via native NEO contract)
It has all the methods required now, so you can register, vote and get
voting results. Fixes #865.
2020-04-27 16:06:50 +03:00
Roman Khimov
1e3c36433f
Merge pull request #844 from nspcc-dev/neo3/nonce
core: add nonce field to transaction
2020-04-14 16:24:02 +03:00
Anna Shaleva
d1f92a585b core: add NewTransactionFromBytes method to Transaction
Added `NewTransactionFromBytes(b []byte)` method to
transaction.Transaction in order to avoid code duplication.
2020-04-13 12:04:43 +03:00
Evgenii Stratonikov
a7c19d445b core: move Blockchainer interface to a separate package 2020-04-11 10:56:36 +03:00
Roman Khimov
5f09381cf4 core: wrap cached dao properly, don't miss cached data
Fixes #817 where invoked contract missed updated account information because
it got it one layer below cachedDao used to process the block.
2020-04-03 10:15:11 +03:00
Anna Shaleva
5a984fdf88 config: move config.go out of config/
closes #423
2020-03-31 17:55:59 +03:00
Evgenii Stratonikov
2ed417388b rpc: unify RPC handlers
Move all of them to a map. This can make it easier
to add/remove RPC based on plugins and makes code less verbose.
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
8236217a01 rpc: make all handler have the same signature 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
6e801d33f0 rpc: make a separate handler for every RPC
Move getbestblockhash, getblockcount, getconnectioncount RPC.
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
969ed6e6e1 rpc: move getaccountstate/getunspents RPCs to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
2ec5b9f08a rpc: move getblock RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
e442ebdb69 rpc: move getblockhash RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
90fdde4018 rpc: move getversion RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
99d02d5de0 rpc: move getpeers RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
dfb4171e3c rpc: move getrawmempool RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
4e25c9121b rpc: move validateaddress RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
70eb0b175a rpc: move getassetstate RPC to a separate func 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
9e6785bed9 rpc: unify counter metrics update 2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
dfbb84ef38 rpc: support https
Allow to start TLS RPC server on a separate port.
Closes #702.
2020-03-17 12:44:23 +03:00
Evgenii Stratonikov
e503d1001d core/state: do not unmarshal Unclaimed balances in account 2020-03-16 12:19:32 +03:00
Evgenii Stratonikov
df2598c8dc core: store NEP5 balances separately
There is no need to take and unmarshal an account structure only
to get it's NEP5 balances.
2020-03-12 12:58:28 +03:00
Evgenii Stratonikov
d25dddc780 rpc: refactor getDecimals
Use existing functions to invoke smartcontract's
method instead of constructing ad-hoc script.
2020-03-12 12:19:31 +03:00
Evgenii Stratonikov
05544a1510 rpc: return empty arrays instead of null in getnep5* RPCs 2020-03-12 12:19:30 +03:00
Anna Shaleva
c23a522d25 rpc: implement getunclaimed
closes #712
2020-03-11 18:33:15 +03:00
Anna Shaleva
456a2d55fd rpc: implement getvalidators
closes #714
2020-03-07 18:05:40 +03:00
Roman Khimov
f8eee778f4
Merge pull request #724 from nspcc-dev/feature/submitblock
rpc: implement submitblock
2020-03-06 12:08:45 +03:00
Anna Shaleva
2031d8d103 rpc: add custom errors to sendrawtransaction
In case of unsuccessful relyReason sendRawTransaction should return
errors with codes [-500, ..., -505] instead of error with code -32603
2020-03-06 12:04:51 +03:00
Anna Shaleva
a746d8e6e6 rpc: implement submitblock RPC
closes #344
2020-03-06 12:03:08 +03:00
Anna Shaleva
ccd88c3af8 rpc: implement gettransactionheight
closes #713
2020-03-05 19:34:11 +03:00
Roman Khimov
fbdc60b731
Merge pull request #723 from nspcc-dev/feature/nep5
core,rpc: implement NEP5-related logic
2020-03-05 18:33:58 +03:00
Evgenii Stratonikov
547bd3bde3 rpc: display for NEP5 token amount properly
Every NEP5 contract MUST have `decimals` method which
is used to properly display token amount.
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
95a8fa234f rpc: implement getnep5transfers RPC 2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
2757882d26 rpc: implement getnep5balances RPC 2020-03-05 18:22:40 +03:00
Anna Shaleva
42e2aff381 rpc: implement getblockheader RPC
closes #711
2020-03-05 14:47:45 +03:00
Roman Khimov
e41d434a49 *: move all packages from CityOfZion to nspcc-dev 2020-03-03 17:21:42 +03:00
Roman Khimov
4c8d327353 rpc: drop duplicating Invoke* structures
And use smartcontract.Parameter instead of vm.StackItem where
appropriate. Closes #689.
2020-03-03 15:38:03 +03:00
Roman Khimov
3282c6ed41
Merge pull request #704 from nspcc-dev/feature/getrawmempool
rpc: implement getrawmempool RPC
2020-03-02 19:44:19 +03:00
Anna Shaleva
e1fe12a07f rpc: implement getrawmempool RPC
closes #175
2020-03-02 19:35:51 +03:00
Evgenii Stratonikov
51c4868641 rpc: implement getclaimable RPC 2020-03-02 18:01:49 +03:00
Anna Shaleva
ff4384d7ff rpc: implement getapplicationlog RPC
Closes #500
2020-03-02 17:25:27 +03:00
Anna Shaleva
76a0a6e7e8 rpc: implement getblocksysfee RPC
Closes #341
2020-02-21 18:45:52 +03:00
Roman Khimov
3fa9de764b rpc/client: only return the Result from calls, handle Error internally
Adjust structures accordingly and throw away most of them, they're useless.
2020-02-21 15:23:11 +03:00
Evgenii Stratonikov
b50704fd3b rpc: move server-related code to a separate package 2020-02-21 15:12:04 +03:00
Renamed from pkg/rpc/server.go (Browse further)