@ -18,7 +18,7 @@ import (
var log , Log = xlog . New ( "ncdumpzone" )
const perCall = 1000
const defaultPerCall uint32 = 1000
func dumpRR ( rr dns . RR , dest io . Writer , format string ) error {
switch format {
@ -91,6 +91,7 @@ func Dump(conn *namecoin.Client, dest io.Writer, format string) error {
currentName := "d/"
continuing := 0
perCall := defaultPerCall
for {
results , err := conn . NameScan ( currentName , perCall )
@ -110,6 +111,33 @@ func Dump(conn *namecoin.Client, dest io.Writer, format string) error {
continuing = 1
}
// Temporary hack to fix
// https://github.com/namecoin/ncdns/issues/105
// TODO: Replace this hack with hex encoding after Namecoin
// Core 0.18.0+ is ubiquitous.
lenResults := len ( results )
for results [ len ( results ) - 1 ] . NameError != "" {
results = results [ : len ( results ) - 1 ]
if len ( results ) == 0 {
break
}
}
// Edge case: if all of the results had a NameError,
// then try to get more results at once.
if len ( results ) == 0 {
// All of the results had a nameError but we're
// at the end of the results, so not a problem.
if lenResults < int ( perCall ) - 1 {
log . Info ( "out of results, stopping" )
break
}
log . Warnf ( "All %d results (start point %s) had a NameError" , lenResults , currentName )
perCall *= 2
continue
}
for i := range results {
r := & results [ i ]