Anna Shaleva
e1d5ac8557
Merge pull request #3515 from nspcc-dev/block-fetcher
...
services: add new block fetching from NeoFS service
2024-09-12 11:45:31 +05:00
Roman Khimov
4445a0c42c
Merge pull request #3584 from nspcc-dev/allow-null-structs
...
rpcbinding: handle NULL results for structures, fix #3581
2024-09-12 09:02:08 +03:00
Roman Khimov
80dd6359a5
Merge pull request #3583 from nspcc-dev/extend-accepted-parameters
...
Extend accepted parameters
2024-09-12 08:57:04 +03:00
Roman Khimov
4e3f17d06f
rpcbinding: handle NULL results for structures, fix #3581
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-11 18:54:16 +03:00
Roman Khimov
8469f97d09
smartcontract: extend slice types accepted by NewParameterFromValue
...
It's _very_ annoying to not be able to use []string types properly:
test invocation failed: unsupported parameter []string
But the same thing can happen to any other slice, so accept slices of every
basic type we accept above. Reorder tests to match implementation switch as
well.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-11 17:08:01 +03:00
Roman Khimov
f80f453933
smartcontract: use generics to simplify slice handling
...
It's all the same in its essence.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-11 16:22:46 +03:00
Ekaterina Pavlova
0b31a29f39
services: add new service for fetching blocks from NeoFS
...
Close #3496
Co-authored-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-09-11 08:50:31 +04:00
Ekaterina Pavlova
5dff3fc13d
neofs: add GetSDKClient, ObjectSearch and GetWithClient
...
Could be used for operation with neofs.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-09-10 13:29:54 +04:00
Ekaterina Pavlova
69b655ec7a
queue: add Blocking OperationMode
...
If Blocking mode is on PutBlock will block until there is enough space
in the queue.
Co-authored-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-09-09 10:28:15 +04:00
Ekaterina Pavlova
6f2712ee55
network: make cash size of bqueue configurable
...
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-09-06 19:17:20 +04:00
Pavel Karpy
f8549a4fb8
mpt: refactor lcp
to be possible to use range
...
It took some time to understand why changing a regular `for` to a `range`
one leads to behavior changes; let it be more clear and explicit. Also, a
correct code is always better than a correct code with `nolint`.
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2024-09-04 14:15:44 +03:00
Pavel Karpy
32f91dd726
.golangci.yml: add intrange
linter
...
It checks that go 1.22's range-over-numbers feature is not skipped. Also,
fix some warnings it found.
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2024-09-04 14:15:32 +03:00
Roman Khimov
565f8cfb7a
*: fix copyloopvar warnings
...
Go 1.22+ allows to drop these:
The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 22:02:57 +03:00
Roman Khimov
74cf5cbeae
vm: drop *vm.VM parameter of CheckMultisigPar()
...
It's unused. Maybe we can move it out of VM completely decoupling VM from
crypto.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:48:27 +03:00
Roman Khimov
1b83dc2476
*: improve for loop syntax
...
Mostly it's about Go 1.22+ syntax with ranging over integers, but it also
prefers ranging over slices where possible (it makes code a little better to
read).
Notice that we have a number of dangerous loops where slices are mutated
during loop execution, many of these can't be converted since we need proper
length evalutation at every iteration.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:45:18 +03:00
Roman Khimov
133cd1dcf8
rpcbinding: use slices.Delete* for element filtering
...
It's a bit easier this way, loops that change slices aren't fun.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:35:27 +03:00
Roman Khimov
0fec17d7c0
bqueue: simplify queue flush on Discard()
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:30:00 +03:00
Roman Khimov
8f45d57612
*: stop using math/rand
...
Mostly this switches to math/rand/v2, but sometimes randomness is not really needed.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
a50723ff72
*: use cmp.Or where appropriate
...
It's slightly less efficient (all comparisons are always made), but for
strings/ints it's negligible performance difference, while the code looks a
tiny bit better.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
357bc76882
*: use slices.Concat where appropriate
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
d5b7fc54e7
manifest: deduplicate test logic a bit with slices.Concat
...
LIkely it's more readable this way.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
dfcff64acb
go.mod: update to Go 1.22+
...
This also changes workflows to test 1.22 and 1.23 only (refs. https://github.com/nspcc-dev/.github/issues/30 ).
Fixes #3310 .
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
c07604fbf3
notary: simplify key presence check with slices
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:51:12 +03:00
Roman Khimov
6d4ebdcef3
*: return errors.ErrUnsupported where appropriate
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:51:12 +03:00
Roman Khimov
97506fb48d
keys: rework nep-2/wif encoding without bytes.Buffer
...
It doesn't make any sense here and the length check was just a dead code.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
9bc67f9da6
keys: mute elliptic.Marshal deprecation warning
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
b4e4567c2b
*: don't use CompareTo name for three-way comparison functions
...
"Compare" is almost a standard one now, although math/big uses Cmp for historic
reasons (keys.PublicKey does so too). This also fixes Fixed8 since int64 to int
conversion is lossy.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
a1a7e3d708
*: use slices package for sorting and searching
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
6581bd47fc
interop: simplify code with slices.Insert
...
It's not performance-critical for sure.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
a0553f740d
statesync: simplify Pool management code
...
* use slices.BinarySearchFunc with its boolean status
* use slices.Insert/slices.Delete, tnis can be a little less efficient, but it
frees the memory faster and this code is more I/O (networking) bound to care
about 1-3%
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
5431b31d84
core: fix extensible sender check
...
Looks like it was wrong since 9592f3e052
because
sort.Search can return an index that is not equal to the target.
slices.BinarySearchFunc can do that too, but it also return a very convenient
boolean status that can be used.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
74acfe5288
network: rework insertion into sorting in tryInitStateSync
...
Overall this'd be less operations and less allocations.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
49438798b5
manifest: deduplicate duplicate-checking code
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
db820cb0dc
manifest: rework method duplicate check
...
Don't use an additional type, it's inconvenient and this method is not
performance-critical.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
7f1690a840
manifest: use slices.SortFunc, deduplicate PermissionDesc code
...
Simplify Less and Equals, fix Equals as well for PermissionWildcard (it was
reporting false erroneously).
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
e0cf47e6d0
consensus: don't do useless key sorting
...
They're already sorted out of smartcontract.CreateMultiSigRedeemScript().
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
32e3310205
smartcontract: improve CreateMultiSigRedeemScript documentation
...
It was always like that, but this important aspect was never documented.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
de665b5567
*: use slices.Sort() where appropriate
...
It's always faster for simple types.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
d40ccb3e57
util: add Compare to Uint160
...
It's useful for slices-based sorting/finding.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
dda3d8b284
mempool: add some comments on potential slices.* use
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
a30792dbb6
*: use slices.Index/slices.Contains where appropriate
...
This doesn't touch performance-sensitive parts, but simplifies a lot of code.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
9cce148d83
*: use maps.Equal/slices.Equal where appropriate
...
Testing for equality has never been easier.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
93ecd61079
stackitem: microoptimize memory management of Make()
...
Preallocate as much as needed.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
e8a86e617b
transaction: microoptimize multiattribute check
...
We can't have more than 256 attribute types, so allocate and use 32 bytes
instead of a whole map.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
f15a163cdf
rpcsrv: deduplicate RunForErrors code
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
d22bdd8369
rpcsrv: microoptimize result allocation
...
We know the size.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
aefd0da181
payload: deduplicate test code slightly
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
35d5495d39
wallet: simplify signature handling
...
Don't use an additional buffer, drop one branch.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
9e112fc024
*: use slices.Clone instead of make/copy
...
It's much easier this way.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
7243754a0d
*: drop open-coded slice reversing
...
Less code, same performance.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00