func NewAddrBook(logger *zap.Logger, filePath string, routabilityStrict bool) *AddrBook {
	am := &AddrBook{
		rand:              rand.New(rand.NewSource(time.Now().UnixNano())),
		ourAddrs:          make(map[string]*NetAddress),
		addrLookup:        make(map[string]*knownAddress),
		filePath:          filePath,
		routabilityStrict: routabilityStrict,
		logger:            logger,
		slogger:           logger.Sugar(),
	}
	am.init()
	am.BaseService = *NewBaseService(logger, "AddrBook", am)
	return am
}
Use Start to begin processing asynchronous address updates.
package p2p
import (
	"encoding/binary"
	"encoding/json"
	"fmt"
	"math"
	"math/rand"
	"net"
	"os"
	"sync"
	"time"
	"go.uber.org/zap"
	. "github.com/annchain/annchain/module/lib/go-common"
	"github.com/annchain/annchain/module/lib/go-crypto"
)
const (
	needAddressThreshold = 1000
	dumpAddressInterval = time.Minute * 2
	oldBucketSize = 64
	oldBucketCount = 64
	newBucketSize = 64
	newBucketCount = 256
	oldBucketsPerGroup = 4
	newBucketsPerGroup = 32
	maxNewBucketsPerAddress = 4
	numMissingDays = 30
	numRetries = 3
	maxFailures = 10
	minBadDays = 7
	getSelectionPercent = 23
	minGetSelection = 32
	maxGetSelection = 250
	serializationVersion = 1
)
type AddrBook struct {
	BaseService
	mtx               sync.Mutex
	filePath          string
	routabilityStrict bool
	rand              *rand.Rand
	key               string
	ourAddrs          map[string]*NetAddress
	addrLookup        map[string]*knownAddress  
	addrNew           []map[string]*knownAddress
	addrOld           []map[string]*knownAddress
	wg                sync.WaitGroup
	nOld              int
	nNew              int
	logger  *zap.Logger
	slogger *zap.SugaredLogger
}
const (
	bucketTypeNew = 0x01
	bucketTypeOld = 0x02
)