*: apply go 1.19 formatter heuristics
And make manual corrections where needed. See the "Common mistakes and pitfalls" section of https://tip.golang.org/doc/comment.
This commit is contained in:
parent
bb751535d3
commit
916f2293b8
20 changed files with 167 additions and 150 deletions
|
@ -32,8 +32,8 @@ var (
|
|||
// TestCreateBasicChain generates "../rpc/testdata/testblocks.acc" file which
|
||||
// contains data for RPC unit tests. It also is a nice integration test.
|
||||
// To generate new "../rpc/testdata/testblocks.acc", follow the steps:
|
||||
// 1. Set saveChain down below to true
|
||||
// 2. Run tests with `$ make test`
|
||||
// 1. Set saveChain down below to true
|
||||
// 2. Run tests with `$ make test`
|
||||
func TestCreateBasicChain(t *testing.T) {
|
||||
const saveChain = false
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Package core implements Neo ledger functionality.
|
||||
It's built around the Blockchain structure that maintains state of the ledger.
|
||||
|
||||
Events
|
||||
# Events
|
||||
|
||||
You can subscribe to Blockchain events using a set of Subscribe and Unsubscribe
|
||||
methods. These methods accept channels that will be used to send appropriate
|
||||
|
@ -24,6 +24,5 @@ way they're stored in the block.
|
|||
Be careful using these subscriptions, this mechanism is not intended to be used
|
||||
by lots of subscribers and failing to read from event channels can affect
|
||||
other Blockchain operations.
|
||||
|
||||
*/
|
||||
package core
|
||||
|
|
|
@ -21,12 +21,12 @@ var (
|
|||
|
||||
// Billet is a part of an MPT trie with missing hash nodes that need to be restored.
|
||||
// Billet is based on the following assumptions:
|
||||
// 1. Refcount can only be incremented (we don't change the MPT structure during restore,
|
||||
// thus don't need to decrease refcount).
|
||||
// 2. Each time a part of a Billet is completely restored, it is collapsed into
|
||||
// HashNode.
|
||||
// 3. Any pair (node, path) must be restored only once. It's a duty of an MPT pool to manage
|
||||
// MPT paths in order to provide this assumption.
|
||||
// 1. Refcount can only be incremented (we don't change the MPT structure during restore,
|
||||
// thus don't need to decrease refcount).
|
||||
// 2. Each time a part of a Billet is completely restored, it is collapsed into
|
||||
// HashNode.
|
||||
// 3. Any pair (node, path) must be restored only once. It's a duty of an MPT pool to manage
|
||||
// MPT paths in order to provide this assumption.
|
||||
type Billet struct {
|
||||
TempStoragePrefix storage.KeyPrefix
|
||||
Store *storage.MemCachedStore
|
||||
|
|
|
@ -37,15 +37,15 @@ func prepareMPTCompat() *Trie {
|
|||
// TestCompatibility contains tests present in C# implementation.
|
||||
// https://github.com/neo-project/neo-modules/blob/master/tests/Neo.Plugins.StateService.Tests/MPT/UT_MPTTrie.cs
|
||||
// There are some differences, though:
|
||||
// 1. In our implementation, delete is silent, i.e. we do not return an error if the key is missing or empty.
|
||||
// However, we do return an error when the contents of the hash node are missing from the store
|
||||
// (corresponds to exception in C# implementation). However, if the key is too big, an error is returned
|
||||
// (corresponds to exception in C# implementation).
|
||||
// 2. In our implementation, put returns an error if something goes wrong, while C# implementation throws
|
||||
// an exception and returns nothing.
|
||||
// 3. In our implementation, get does not immediately return any error in case of an empty key. An error is returned
|
||||
// only if the value is missing from the storage. C# implementation checks that the key is not empty and throws an error
|
||||
// otherwise. However, if the key is too big, an error is returned (corresponds to exception in C# implementation).
|
||||
// 1. In our implementation, delete is silent, i.e. we do not return an error if the key is missing or empty.
|
||||
// However, we do return an error when the contents of the hash node are missing from the store
|
||||
// (corresponds to exception in C# implementation). However, if the key is too big, an error is returned
|
||||
// (corresponds to exception in C# implementation).
|
||||
// 2. In our implementation, put returns an error if something goes wrong, while C# implementation throws
|
||||
// an exception and returns nothing.
|
||||
// 3. In our implementation, get does not immediately return any error in case of an empty key. An error is returned
|
||||
// only if the value is missing from the storage. C# implementation checks that the key is not empty and throws an error
|
||||
// otherwise. However, if the key is too big, an error is returned (corresponds to exception in C# implementation).
|
||||
func TestCompatibility(t *testing.T) {
|
||||
mainTrie := prepareMPTCompat()
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ Package mpt implements MPT (Merkle-Patricia Trie).
|
|||
An MPT stores key-value pairs and is a trie over 16-symbol alphabet. https://en.wikipedia.org/wiki/Trie
|
||||
A trie is a tree where values are stored in leafs and keys are paths from the root to the leaf node.
|
||||
An MPT consists of 4 types of nodes:
|
||||
- Leaf node only contains a value.
|
||||
- Extension node contains both a key and a value.
|
||||
- Branch node contains 2 or more children.
|
||||
- Hash node is a compressed node and only contains the actual node's hash.
|
||||
The actual node must be retrieved from the storage or over the network.
|
||||
- Leaf node only contains a value.
|
||||
- Extension node contains both a key and a value.
|
||||
- Branch node contains 2 or more children.
|
||||
- Hash node is a compressed node and only contains the actual node's hash.
|
||||
The actual node must be retrieved from the storage or over the network.
|
||||
|
||||
As an example here is a trie containing 3 pairs:
|
||||
- 0x1201 -> val1
|
||||
|
@ -16,18 +16,18 @@ As an example here is a trie containing 3 pairs:
|
|||
- 0x1224 -> val3
|
||||
- 0x12 -> val4
|
||||
|
||||
ExtensionNode(0x0102), Next
|
||||
_______________________|
|
||||
|
|
||||
BranchNode [0, 1, 2, ...], Last -> Leaf(val4)
|
||||
| |
|
||||
| ExtensionNode [0x04], Next -> Leaf(val3)
|
||||
|
|
||||
BranchNode [0, 1, 2, 3, ...], Last -> HashNode(nil)
|
||||
| |
|
||||
| Leaf(val2)
|
||||
|
|
||||
Leaf(val1)
|
||||
ExtensionNode(0x0102), Next
|
||||
_______________________|
|
||||
|
|
||||
BranchNode [0, 1, 2, ...], Last -> Leaf(val4)
|
||||
| |
|
||||
| ExtensionNode [0x04], Next -> Leaf(val3)
|
||||
|
|
||||
BranchNode [0, 1, 2, 3, ...], Last -> HashNode(nil)
|
||||
| |
|
||||
| Leaf(val2)
|
||||
|
|
||||
Leaf(val1)
|
||||
|
||||
There are 3 invariants that this implementation has:
|
||||
- Branch node cannot have <= 1 children
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue