Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cmd/gencerts/gencerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"golang.org/x/net/idna"
)

func fatalf(format string, args ...interface{}) {
func fatalf(format string, args ...any) {
fmt.Fprintf(os.Stderr, format, args...)
os.Exit(1)
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func main() {
}
certname, keyname := args[0], args[1]

var keygen func() (pub, priv interface{})
var keygen func() (pub, priv any)
switch cfg.Algo {
case "P-256":
keygen = ecKeyGen(elliptic.P256())
Expand Down Expand Up @@ -136,7 +136,7 @@ func main() {
}
} else {
var ca *x509.Certificate
var caPriv interface{}
var caPriv any
tlsCert, err := tls.LoadX509KeyPair(cfg.CA, cfg.CAKey)
if err != nil {
fatalf("open CA keypair: %s\n", err)
Expand Down Expand Up @@ -177,15 +177,15 @@ func fileExists(name string) bool {
return true
}

func ed25519KeyGen() (pub, priv interface{}) {
func ed25519KeyGen() (pub, priv any) {
seed := make([]byte, ed25519.SeedSize)
rand.Read(seed)
key := ed25519.NewKeyFromSeed(seed)
return key.Public(), key
}

func ecKeyGen(curve elliptic.Curve) func() (pub, priv interface{}) {
return func() (pub, priv interface{}) {
func ecKeyGen(curve elliptic.Curve) func() (pub, priv any) {
return func() (pub, priv any) {
var key *ecdsa.PrivateKey
key, err := ecdsa.GenerateKey(curve, rand.Reader())
if err != nil {
Expand All @@ -195,8 +195,8 @@ func ecKeyGen(curve elliptic.Curve) func() (pub, priv interface{}) {
}
}

func rsaKeyGen(bits int) func() (pub, priv interface{}) {
return func() (pub, priv interface{}) {
func rsaKeyGen(bits int) func() (pub, priv any) {
return func() (pub, priv any) {
var key *rsa.PrivateKey
key, err := rsa.GenerateKey(rand.Reader(), bits)
if err != nil {
Expand Down Expand Up @@ -282,7 +282,7 @@ func newTemplate(hosts []string, org string, validUntil time.Time) (*x509.Certif
return template, nil
}

func generateAuthority(pub, priv interface{}, hosts []string, org string,
func generateAuthority(pub, priv any, hosts []string, org string,
years int, keyUsage x509.KeyUsage) (*certWithPEM, error) {

validUntil := time.Now().Add(time.Hour * 24 * 365 * time.Duration(years))
Expand Down Expand Up @@ -317,7 +317,7 @@ func generateAuthority(pub, priv interface{}, hosts []string, org string,
return ca, nil
}

func createIssuedCert(pub, caPriv interface{}, ca *x509.Certificate,
func createIssuedCert(pub, caPriv any, ca *x509.Certificate,
hosts []string, org string, years int, keyUsage x509.KeyUsage) (*certWithPEM, error) {

if ca.KeyUsage&x509.KeyUsageCertSign == 0 {
Expand Down Expand Up @@ -357,7 +357,7 @@ func createIssuedCert(pub, caPriv interface{}, ca *x509.Certificate,
return issuedCert, nil
}

func marshalPrivateKey(key interface{}) ([]byte, error) {
func marshalPrivateKey(key any) ([]byte, error) {
der, err := x509.MarshalPKCS8PrivateKey(key)
if err != nil {
return nil, fmt.Errorf("failed to marshal private key: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/blockchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
// panicf is a convenience function that formats according to the given format
// specifier and arguments and then logs the result at the critical level and
// panics with it.
func panicf(format string, args ...interface{}) {
func panicf(format string, args ...any) {
str := fmt.Sprintf(format, args...)
log.Critical(str)
panic(str)
Expand Down
2 changes: 1 addition & 1 deletion internal/blockchain/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ func (e MultiError) Is(target error) bool {
//
// This means it keeps all of the same semantics typically provided by As in
// terms of unwrapping error chains and setting the target to the matched error.
func (e MultiError) As(target interface{}) bool {
func (e MultiError) As(target any) bool {
for _, err := range e {
if errors.As(err, target) {
return true
Expand Down
4 changes: 2 additions & 2 deletions internal/blockchain/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ type TicketNotificationsData struct {
// - NTNewTickets: *TicketNotificationsData
type Notification struct {
Type NotificationType
Data interface{}
Data any
}

// sendNotification sends a notification with the passed type and data if the
// caller requested notifications by providing a callback function in the call
// to New.
func (b *BlockChain) sendNotification(typ NotificationType, data interface{}) {
func (b *BlockChain) sendNotification(typ NotificationType, data any) {
// Ignore it if the caller didn't request notifications.
if b.notifications == nil {
return
Expand Down
2 changes: 1 addition & 1 deletion internal/blockchain/utxoio.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var utxoSetDbPrefixSize = len(utxoPrefixUtxoSet)
// outpointKeyPool defines a concurrent safe free list of byte slices used to
// provide temporary buffers for outpoint database keys.
var outpointKeyPool = sync.Pool{
New: func() interface{} {
New: func() any {
b := make([]byte, utxoSetDbPrefixSize+chainhash.HashSize+
maxUint8VLQSerializeSize+maxUint32VLQSerializeSize)
return &b // Pointer to slice to avoid boxing alloc.
Expand Down
2 changes: 1 addition & 1 deletion internal/mining/bgblktmplgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ type templateUpdate struct {
// - rtTemplateUpdated: templateUpdate
type regenEvent struct {
reason regenEventType
value interface{}
value any
}

// waitGroup behaves simlarly to a sync.WaitGroup without the restriction that
Expand Down
4 changes: 2 additions & 2 deletions internal/mining/txpriorityqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ func (pq *txPriorityQueue) Swap(i, j int) {

// Push pushes the passed item onto the priority queue. It is part of the
// heap.Interface implementation.
func (pq *txPriorityQueue) Push(x interface{}) {
func (pq *txPriorityQueue) Push(x any) {
pq.items = append(pq.items, x.(*txPrioItem))
}

// Pop removes the highest priority item (according to Less) from the priority
// queue and returns it. It is part of the heap.Interface implementation.
func (pq *txPriorityQueue) Pop() interface{} {
func (pq *txPriorityQueue) Pop() any {
n := len(pq.items)
item := pq.items[n-1]
pq.items[n-1] = nil
Expand Down
2 changes: 1 addition & 1 deletion internal/rpcserver/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type ConnManager interface {
// AddRebroadcastInventory adds the provided inventory to the list of
// inventories to be rebroadcast at random intervals until they show up
// in a block.
AddRebroadcastInventory(iv *wire.InvVect, data interface{})
AddRebroadcastInventory(iv *wire.InvVect, data any)

// RelayTransactions generates and relays inventory vectors for all of
// the passed transactions to all connected peers.
Expand Down
Loading