Skip to content

Commit

Permalink
Merge pull request #2 from paicha/main
Browse files Browse the repository at this point in the history
CHG: replace sia with skynet
  • Loading branch information
scorpiotzh authored Jun 15, 2022
2 parents 7d3865e + fd22e24 commit 0a17a6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dao/dao_records_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func (d *DbDao) FindRecordInfoByKeys(keys []string) (recordInfo []TableRecordsIn
}

func (d *DbDao) FindContentRecordInfoByMaxId(id uint64) (recordInfo []TableRecordsInfo, err error) {
err = d.db.Where("`key` IN(?) AND id > ? ", []string{"ipfs", "ipns", "sia"}, id).Find(&recordInfo).Error
err = d.db.Where("`key` IN(?) AND id > ? ", []string{"ipfs", "ipns", "skynet"}, id).Find(&recordInfo).Error
return
}

func (d *DbDao) FindContentRecordInfoByAccount(account string) (recordInfo []TableRecordsInfo, err error) {
err = d.db.Where("`key` IN(?) AND account = ? ", []string{"ipfs", "ipns", "sia"}, account).Find(&recordInfo).Error
err = d.db.Where("`key` IN(?) AND account = ? ", []string{"ipfs", "ipns", "skynet"}, account).Find(&recordInfo).Error
return
}
6 changes: 3 additions & 3 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (d *DNSData) updateDNSRecord(contentRecord dao.TableRecordsInfo) (dao.Table
oldRecords = *d.cnameRecords
content := d.ipfsCname
// CNAME content for skynet
if contentRecord.Key == "sia" {
if contentRecord.Key == "skynet" {
content = d.skynetCname
}
newRecord = cloudflare.DNSRecord{
Expand All @@ -96,14 +96,14 @@ func (d *DNSData) updateDNSRecord(contentRecord dao.TableRecordsInfo) (dao.Table
oldRecords = *d.txtRecords
value := contentRecord.Value
// compatible with ipfs://xxx sia://xxx https://ipfs.io/ipfs/xxx
if contentRecord.Key == "sia" || contentRecord.Key == "ipfs" {
if contentRecord.Key == "skynet" || contentRecord.Key == "ipfs" {
re := regexp.MustCompile(`([0-9A-Za-z-]{46})`)
if results := re.FindStringSubmatch(value); len(results) == 2 {
value = results[1]
}
}
txt := "dnslink=/" + contentRecord.Key + "/" + value
if contentRecord.Key == "sia" {
if contentRecord.Key == "skynet" {
txt = "dnslink=/skynet-ns/" + value
}
newRecord = cloudflare.DNSRecord{
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func runServer(ctx *cli.Context) error {
}
log.Info("dns data ok")

// read all das accounts that has ipfs/ipns/sia record
contentRecordList, _ := dbDao.FindRecordInfoByKeys([]string{"ipfs", "ipns", "sia"})
// read all das accounts that has ipfs/ipns/skynet record
contentRecordList, _ := dbDao.FindRecordInfoByKeys([]string{"ipfs", "ipns", "skynet"})

jobsChanLength := len(contentRecordList)
if jobsChanLength == 0 {
Expand Down
2 changes: 1 addition & 1 deletion sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func findPriorityRecord(contentRecord dao.TableRecordsInfo, contentRecordList []
if priorityRecord.Id > candidateRecord.Id {
priorityRecord = candidateRecord
}
} else if priorityRecord.Key == "sia" {
} else if priorityRecord.Key == "skynet" {
// Skynet record lowest priority
priorityRecord = candidateRecord
} else if candidateRecord.Key == "ipns" {
Expand Down

0 comments on commit 0a17a6d

Please sign in to comment.