[#1557] morph/event: Remove embedded structs from scriptHashWithValue
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 4m15s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m38s
Tests and linters / gopls check (pull_request) Successful in 6m6s
DCO action / DCO (pull_request) Successful in 6m13s
Vulncheck / Vulncheck (pull_request) Successful in 7m12s
Build / Build Components (pull_request) Successful in 8m9s
Tests and linters / Tests with -race (pull_request) Successful in 8m32s
Tests and linters / Tests (pull_request) Successful in 8m35s
Tests and linters / Staticcheck (pull_request) Successful in 8m32s
Tests and linters / Lint (pull_request) Successful in 9m38s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 4m15s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m38s
Tests and linters / gopls check (pull_request) Successful in 6m6s
DCO action / DCO (pull_request) Successful in 6m13s
Vulncheck / Vulncheck (pull_request) Successful in 7m12s
Build / Build Components (pull_request) Successful in 8m9s
Tests and linters / Tests with -race (pull_request) Successful in 8m32s
Tests and linters / Tests (pull_request) Successful in 8m35s
Tests and linters / Staticcheck (pull_request) Successful in 8m32s
Tests and linters / Lint (pull_request) Successful in 9m38s
Also, make them public, because otherwise `unused` linter complains. ``` pkg/morph/event/utils.go:25:2 unused field `typ` is unused ``` This complain is wrong, though: we _use_ `typ` field because the whole struct is used as a map key. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
e9837bbcf9
commit
6f80c82d4d
2 changed files with 6 additions and 24 deletions
|
@ -180,7 +180,7 @@ func (l *listener) subscribe(errCh chan error) {
|
||||||
// fill the list with the contracts with set event parsers.
|
// fill the list with the contracts with set event parsers.
|
||||||
l.mtx.RLock()
|
l.mtx.RLock()
|
||||||
for hashType := range l.notificationParsers {
|
for hashType := range l.notificationParsers {
|
||||||
scHash := hashType.ScriptHash()
|
scHash := hashType.Hash
|
||||||
|
|
||||||
// prevent repetitions
|
// prevent repetitions
|
||||||
for _, hash := range hashes {
|
for _, hash := range hashes {
|
||||||
|
@ -189,7 +189,7 @@ func (l *listener) subscribe(errCh chan error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hashes = append(hashes, hashType.ScriptHash())
|
hashes = append(hashes, hashType.Hash)
|
||||||
}
|
}
|
||||||
l.mtx.RUnlock()
|
l.mtx.RUnlock()
|
||||||
|
|
||||||
|
@ -326,9 +326,7 @@ func (l *listener) parseAndHandleNotification(ctx context.Context, notifyEvent *
|
||||||
)
|
)
|
||||||
|
|
||||||
// get the event parser
|
// get the event parser
|
||||||
keyEvent := scriptHashWithType{}
|
keyEvent := scriptHashWithType{Hash: notifyEvent.ScriptHash, Type: typEvent}
|
||||||
keyEvent.SetScriptHash(notifyEvent.ScriptHash)
|
|
||||||
keyEvent.SetType(typEvent)
|
|
||||||
|
|
||||||
l.mtx.RLock()
|
l.mtx.RLock()
|
||||||
parser, ok := l.notificationParsers[keyEvent]
|
parser, ok := l.notificationParsers[keyEvent]
|
||||||
|
@ -451,9 +449,7 @@ func (l *listener) RegisterNotificationHandler(hi NotificationHandlerInfo) {
|
||||||
l.mtx.Lock()
|
l.mtx.Lock()
|
||||||
defer l.mtx.Unlock()
|
defer l.mtx.Unlock()
|
||||||
|
|
||||||
var k scriptHashWithType
|
k := scriptHashWithType{Hash: hi.Contract, Type: hi.Type}
|
||||||
k.hash = hi.Contract
|
|
||||||
k.typ = hi.Type
|
|
||||||
|
|
||||||
l.notificationParsers[k] = hi.Parser
|
l.notificationParsers[k] = hi.Parser
|
||||||
l.notificationHandlers[k] = append(
|
l.notificationHandlers[k] = append(
|
||||||
|
|
|
@ -20,13 +20,9 @@ type scriptHashValue struct {
|
||||||
hash util.Uint160
|
hash util.Uint160
|
||||||
}
|
}
|
||||||
|
|
||||||
type typeValue struct {
|
|
||||||
typ Type
|
|
||||||
}
|
|
||||||
|
|
||||||
type scriptHashWithType struct {
|
type scriptHashWithType struct {
|
||||||
scriptHashValue
|
Hash util.Uint160
|
||||||
typeValue
|
Type Type
|
||||||
}
|
}
|
||||||
|
|
||||||
type notaryRequestTypes struct {
|
type notaryRequestTypes struct {
|
||||||
|
@ -73,16 +69,6 @@ func (s scriptHashValue) ScriptHash() util.Uint160 {
|
||||||
return s.hash
|
return s.hash
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetType is an event type setter.
|
|
||||||
func (s *typeValue) SetType(v Type) {
|
|
||||||
s.typ = v
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetType is an event type getter.
|
|
||||||
func (s typeValue) GetType() Type {
|
|
||||||
return s.typ
|
|
||||||
}
|
|
||||||
|
|
||||||
// WorkerPoolHandler sets closure over worker pool w with passed handler h.
|
// WorkerPoolHandler sets closure over worker pool w with passed handler h.
|
||||||
func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *logger.Logger) Handler {
|
func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *logger.Logger) Handler {
|
||||||
return func(ctx context.Context, e Event) {
|
return func(ctx context.Context, e Event) {
|
||||||
|
|
Loading…
Reference in a new issue