[#392] ir: Implement type for group of alphabet contracts
Define `alphabetContracts` type that map glagolic letters to smart contract addresses. Implement constructor and all methods which are going to be used in IR processing. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3430a6d101
commit
1016ba3a5d
1 changed files with 32 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
package innerring
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/util"
|
||||
|
||||
type glagoliticLetter int8
|
||||
|
||||
const (
|
||||
|
@ -139,3 +141,33 @@ func (l glagoliticLetter) configString() string {
|
|||
return "izhitsa"
|
||||
}
|
||||
}
|
||||
|
||||
type alphabetContracts map[glagoliticLetter]util.Uint160
|
||||
|
||||
func newAlphabetContracts() alphabetContracts {
|
||||
return make(map[glagoliticLetter]util.Uint160, lastLetterNum)
|
||||
}
|
||||
|
||||
func (a alphabetContracts) GetByIndex(ind int) (util.Uint160, bool) {
|
||||
if ind < 0 || ind >= int(lastLetterNum) {
|
||||
return util.Uint160{}, false
|
||||
}
|
||||
|
||||
contract, ok := a[glagoliticLetter(ind)]
|
||||
|
||||
return contract, ok
|
||||
}
|
||||
|
||||
func (a alphabetContracts) indexOutOfRange(ind int) bool {
|
||||
return ind < 0 && ind >= len(a)
|
||||
}
|
||||
|
||||
func (a alphabetContracts) iterate(f func(glagoliticLetter, util.Uint160)) {
|
||||
for letter, contract := range a {
|
||||
f(letter, contract)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *alphabetContracts) set(l glagoliticLetter, h util.Uint160) {
|
||||
(*a)[l] = h
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue