本文整理匯總了Golang中github.com/google/certificate-transparency/go/client.LogClient.GetSTH方法的典型用法代碼示例。如果您正苦於以下問題:Golang LogClient.GetSTH方法的具體用法?Golang LogClient.GetSTH怎麽用?Golang LogClient.GetSTH使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/certificate-transparency/go/client.LogClient
的用法示例。
在下文中一共展示了LogClient.GetSTH方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getSTH
func getSTH(logClient *client.LogClient) {
sth, err := logClient.GetSTH()
if err != nil {
log.Fatal(err)
}
// Display the STH
when := ctTimestampToTime(sth.Timestamp)
fmt.Printf("%v: Got STH for %v log (size=%d) at %v, hash %x\n", when, sth.Version, sth.TreeSize, *logURI, sth.SHA256RootHash)
fmt.Printf("%v\n", signatureToString(&sth.TreeHeadSignature))
}
示例2: downloadLog
func downloadLog(ctLogUrl *url.URL, ctLog *client.LogClient, db *sqldb.EntriesDatabase) error {
if *config.OffsetByte > 0 {
return fmt.Errorf("Cannot set offsetByte for CT log downloads")
}
fmt.Printf("Fetching signed tree head... ")
sth, err := ctLog.GetSTH()
if err != nil {
return err
}
// Set pointer in DB, now that we've verified the log works
err = db.SetLog(fmt.Sprintf("%s%s", ctLogUrl.Host, ctLogUrl.Path))
if err != nil {
log.Fatalf("unable to set Certificate Log: %s", err)
}
var origCount uint64
// Now we're OK to use the DB
if *config.Offset > 0 {
log.Printf("Starting from offset %d", *config.Offset)
origCount = *config.Offset
} else {
log.Printf("Counting existing entries... ")
origCount, err = db.Count()
if err != nil {
err = fmt.Errorf("Failed to read entries file: %s", err)
return err
}
}
fmt.Printf("%d total entries at %s\n", sth.TreeSize, sqldb.Uint64ToTimestamp(sth.Timestamp).Format(time.ANSIC))
if origCount == sth.TreeSize {
fmt.Printf("Nothing to do\n")
return nil
}
endPos := sth.TreeSize
if *config.Limit > 0 && endPos > origCount+*config.Limit {
endPos = origCount + *config.Limit
}
fmt.Printf("Going from %d to %d\n", origCount, endPos)
entryChan := make(chan ct.LogEntry, 100)
statusChan := make(chan OperationStatus, 1)
wg := new(sync.WaitGroup)
displayProgress(statusChan, wg)
numWorkers := *config.NumThreads * runtime.NumCPU()
for i := 0; i < numWorkers; i++ {
go insertCTWorker(entryChan, db, wg)
}
_, err = downloadCTRangeToChannel(ctLog, entryChan, statusChan, int64(origCount), int64(endPos))
wg.Wait()
clearLine()
if err != nil {
err = fmt.Errorf("Error while downloading: %s", err)
return err
}
return nil
}