Remove dead code. Tighten definition of TransactionBroadcastReq.

This commit is contained in:
Jonathan Moody 2022-12-16 12:33:10 -06:00
parent 8f6a8db681
commit 5e977e59a2
2 changed files with 1 additions and 35 deletions

View file

@ -705,7 +705,7 @@ func (s *BlockchainScripthashService) Unsubscribe(req *ScripthashSubscribeReq, r
return nil return nil
} }
type TransactionBroadcastReq []string type TransactionBroadcastReq [1]string
type TransactionBroadcastResp string type TransactionBroadcastResp string
// 'blockchain.transaction.broadcast' // 'blockchain.transaction.broadcast'

View file

@ -1,14 +1,12 @@
package server package server
import ( import (
"bytes"
"context" "context"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"hash" "hash"
"io"
"io/ioutil" "io/ioutil"
golog "log" golog "log"
"net" "net"
@ -242,38 +240,6 @@ func LoadDatabase(args *Args, grp *stop.Group) (*db.ReadOnlyDBColumnFamily, erro
return myDB, nil return myDB, nil
} }
type BasicAuthClientCodec struct {
client http.Client
url string
user string
password string
buff *bytes.Buffer
}
func (c BasicAuthClientCodec) Read(p []byte) (n int, err error) {
return c.buff.Read(p)
}
func (c BasicAuthClientCodec) Write(p []byte) (n int, err error) {
req, err := http.NewRequest("POST", c.url, bytes.NewReader(p))
if err != nil {
return 0, err
}
req.SetBasicAuth(c.user, c.password)
req.Header.Add("Content-Type", "application/json")
resp, err := c.client.Do(req)
if err != nil {
return len(p), err
}
io.Copy(c.buff, resp.Body)
return len(p), err
}
func (c BasicAuthClientCodec) Close() error {
c.client.CloseIdleConnections()
return nil
}
// MakeHubServer takes the arguments given to a hub when it's started and // MakeHubServer takes the arguments given to a hub when it's started and
// initializes everything. It loads information about previously known peers, // initializes everything. It loads information about previously known peers,
// creates needed internal data structures, and initializes goroutines. // creates needed internal data structures, and initializes goroutines.