-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/vvarg229/neofs-node
- Loading branch information
Showing
78 changed files
with
2,324 additions
and
3,394 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @roman-khimov @notimetoname @cthulhu-rider | ||
* @roman-khimov @carpawell @cthulhu-rider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package morph | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"sort" | ||
"strings" | ||
"text/tabwriter" | ||
"time" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker" | ||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
nameDomainFlag = "domain" | ||
) | ||
|
||
type nameExp struct { | ||
name string | ||
exp int64 | ||
} | ||
|
||
func dumpNames(cmd *cobra.Command, _ []string) error { | ||
c, err := getN3Client(viper.GetViper()) | ||
if err != nil { | ||
return fmt.Errorf("can't create N3 client: %w", err) | ||
} | ||
cs, err := c.GetContractStateByID(1) // NNS. | ||
if err != nil { | ||
return err | ||
} | ||
var n11r = nep11.NewNonDivisibleReader(invoker.New(c, nil), cs.Hash) | ||
tokIter, err := n11r.Tokens() | ||
if err != nil { | ||
return err | ||
} | ||
zone, _ := cmd.Flags().GetString(nameDomainFlag) | ||
var res = make([]nameExp, 0) | ||
for toks, err := tokIter.Next(10); len(toks) != 0 && err == nil; toks, err = tokIter.Next(10) { | ||
for i := range toks { | ||
var name = string(toks[i]) | ||
if zone != "" && name != zone && !strings.HasSuffix(name, "."+zone) { | ||
continue | ||
} | ||
props, err := n11r.Properties(toks[i]) | ||
if err != nil { | ||
cmd.PrintErrf("Error getting properties for %s: %v\n", name, err) | ||
continue | ||
} | ||
exp, err := expirationFromProperties(props) | ||
if err != nil { | ||
cmd.PrintErrf("Error getting expiration from properties for %s: %v\n", name, err) | ||
continue | ||
} | ||
res = append(res, nameExp{name: name, exp: exp}) | ||
} | ||
} | ||
|
||
sort.Slice(res, func(i, j int) bool { | ||
var ( | ||
iParts = strings.Split(res[i].name, ".") | ||
jParts = strings.Split(res[j].name, ".") | ||
) | ||
if len(iParts) != len(jParts) { | ||
return len(iParts) < len(jParts) | ||
} | ||
for k := len(iParts) - 1; k >= 0; k-- { | ||
var c = strings.Compare(iParts[k], jParts[k]) | ||
if c != 0 { | ||
return c == -1 | ||
} | ||
} | ||
return false | ||
}) | ||
|
||
buf := bytes.NewBuffer(nil) | ||
tw := tabwriter.NewWriter(buf, 0, 2, 2, ' ', 0) | ||
for i := range res { | ||
_, _ = tw.Write([]byte(fmt.Sprintf("%s\t%s\n", | ||
res[i].name, time.UnixMilli(res[i].exp).String()))) | ||
} | ||
_ = tw.Flush() | ||
|
||
cmd.Print(buf.String()) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.