-
-
Save joe-p/ff3dfd382ccc2a9a0420dcf8c2e6ba60 to your computer and use it in GitHub Desktop.
Algorand app address lookup table
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
"time" | |
"github.com/algorand/go-algorand-sdk/crypto" | |
"github.com/algorand/go-algorand-sdk/types" | |
) | |
var addresses [10_000_000]types.Address | |
var index int | |
func getAddr(appID uint64) { | |
if index == 10_000_000 { | |
appendToFile() | |
index = 0 | |
} | |
addresses[index] = crypto.GetApplicationAddress(appID) | |
index++ | |
} | |
func getAddresses(start uint64, end uint64) { | |
for i := start; i < end; i++ { | |
getAddr(i) | |
} | |
} | |
func appendToFile() { | |
file, err := os.OpenFile("table.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) | |
if err != nil { | |
log.Fatalf("failed creating file: %s", err) | |
} | |
datawriter := bufio.NewWriter(file) | |
for _, addr := range addresses { | |
_, _ = datawriter.WriteString(addr.String() + "\n") | |
} | |
datawriter.Flush() | |
file.Close() | |
} | |
func main() { | |
start := time.Now() | |
index = 0 | |
getAddresses(1, 100_000_000) | |
fmt.Println(time.Since(start)) | |
appendToFile() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment