mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 02:46:58 +00:00
multi: Correct typos.
Correct typos found by reading code, ispell, and creative grepping.
This commit is contained in:
parent
665ab37c68
commit
8be96a8729
@ -1064,7 +1064,7 @@ const (
|
||||
// addresses.
|
||||
Ipv6Weak
|
||||
|
||||
// Ipv4 represents an IPV4 connection state between two addreses.
|
||||
// Ipv4 represents an IPV4 connection state between two addresses.
|
||||
Ipv4
|
||||
|
||||
// Ipv6Strong represents a connection state between two IPV6 addresses.
|
||||
|
||||
@ -18,7 +18,7 @@ const charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
|
||||
var gen = []int{0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3}
|
||||
|
||||
// toBytes converts each character in the string 'chars' to the value of the
|
||||
// index of the correspoding character in 'charset'.
|
||||
// index of the corresponding character in 'charset'.
|
||||
func toBytes(chars string) ([]byte, error) {
|
||||
decoded := make([]byte, 0, len(chars))
|
||||
for i := 0; i < len(chars); i++ {
|
||||
|
||||
@ -76,7 +76,7 @@ func TestBech32(t *testing.T) {
|
||||
str, encoded)
|
||||
}
|
||||
|
||||
// Flip a bit in the string an make sure it is caught.
|
||||
// Flip a bit in the string and make sure it is caught.
|
||||
pos := strings.LastIndexAny(str, "1")
|
||||
flipped := str[:pos+1] + string((str[pos+1] ^ 1)) + str[pos+2:]
|
||||
_, _, err = Decode(flipped)
|
||||
|
||||
@ -1413,7 +1413,7 @@ func (b *BlockChain) connectBestChain(node *blockNode, block, parent *dcrutil.Bl
|
||||
// and flush the status changes to the database. It is safe to
|
||||
// ignore any errors when flushing here as the changes will be
|
||||
// flushed when a valid block is connected, and the worst case
|
||||
// scenario if a block a invalid is it would need to be
|
||||
// scenario if a block is invalid is it would need to be
|
||||
// revalidated after a restart.
|
||||
view := NewUtxoViewpoint()
|
||||
view.SetBestHash(parentHash)
|
||||
|
||||
@ -652,7 +652,7 @@ func decodeSpentTxOut(serialized []byte, stxo *spentTxOut, amount int64, height
|
||||
// Since the serialization format is not self describing, as noted in the
|
||||
// format comments, this function also requires the transactions that spend the
|
||||
// txouts and a utxo view that contains any remaining existing utxos in the
|
||||
// transactions referenced by the inputs to the passed transasctions.
|
||||
// transactions referenced by the inputs to the passed transactions.
|
||||
func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx) ([]spentTxOut, error) {
|
||||
// Calculate the total number of stxos.
|
||||
var numStxos int
|
||||
@ -1659,7 +1659,7 @@ func (b *BlockChain) initChainState() error {
|
||||
|
||||
// Determine how many blocks will be loaded into the index in order to
|
||||
// allocate the right amount as a single alloc versus a whole bunch of
|
||||
// littles ones to reduce pressure on the GC.
|
||||
// little ones to reduce pressure on the GC.
|
||||
blockIndexBucket := meta.Bucket(dbnamespace.BlockIndexBucketName)
|
||||
var blockCount int32
|
||||
cursor := blockIndexBucket.Cursor()
|
||||
|
||||
@ -81,7 +81,7 @@ func TestErrNotInMainChain(t *testing.T) {
|
||||
|
||||
// Ensure the stringized output for the error is as expected.
|
||||
if err.Error() != errStr {
|
||||
t.Fatalf("errNotInMainChain retuned unexpected error string - "+
|
||||
t.Fatalf("errNotInMainChain returned unexpected error string - "+
|
||||
"got %q, want %q", err.Error(), errStr)
|
||||
}
|
||||
|
||||
|
||||
@ -259,7 +259,7 @@ func (c *chainView) next(node *blockNode) *blockNode {
|
||||
}
|
||||
|
||||
// Next returns the successor to the provided node for the chain view. It will
|
||||
// return nil if there is no successfor or the provided node is not part of the
|
||||
// return nil if there is no successor or the provided node is not part of the
|
||||
// view.
|
||||
//
|
||||
// For example, assume a block chain with a side chain as depicted below:
|
||||
|
||||
@ -614,7 +614,7 @@ func calcNextStakeDiffV2(params *chaincfg.Params, nextHeight, curDiff, prevPoolS
|
||||
// Calculate the difficulty by multiplying the old stake difficulty
|
||||
// with two ratios that represent a force to counteract the relative
|
||||
// change in the pool size (Fc) and a restorative force to push the pool
|
||||
// size towards the target value (Fr).
|
||||
// size towards the target value (Fr).
|
||||
//
|
||||
// Per DCP0001, the generalized equation is:
|
||||
//
|
||||
|
||||
@ -615,7 +615,7 @@ func (e RuleError) Error() string {
|
||||
return e.Description
|
||||
}
|
||||
|
||||
// ruleError creates an RuleError given a set of arguments.
|
||||
// ruleError creates a RuleError given a set of arguments.
|
||||
func ruleError(c ErrorCode, desc string) RuleError {
|
||||
return RuleError{ErrorCode: c, Description: desc}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ func (b *addrIndexBucket) sanityCheck(addrKey [addrKeySize]byte, expectedTotal i
|
||||
var totalEntries int
|
||||
maxEntries := level0MaxEntries
|
||||
for level := uint8(0); level <= highestLevel; level++ {
|
||||
// Level 0 can'have more entries than the max allowed if the
|
||||
// Level 0 can't have more entries than the max allowed if the
|
||||
// levels after it have data and it can't be empty. All other
|
||||
// levels must either be half full or full.
|
||||
data := b.levels[keyForLevel(addrKey, level)]
|
||||
|
||||
@ -29,7 +29,7 @@ const (
|
||||
// It should be noted that the block might still ultimately fail to
|
||||
// become the new main chain tip if it contains invalid scripts, double
|
||||
// spends, etc. However, this is quite rare in practice because a lot
|
||||
// of work was expended to create a block which satisifies the proof of
|
||||
// of work was expended to create a block which satisfies the proof of
|
||||
// work requirement.
|
||||
//
|
||||
// Finally, this notification is only sent if the chain is believed
|
||||
|
||||
@ -102,7 +102,7 @@ func (b *BlockChain) processOrphans(hash *chainhash.Hash, flags BehaviorFlags) e
|
||||
// the best chain or is now the tip of the best chain due to causing a
|
||||
// reorganize, the fork length will be 0. The second return value indicates
|
||||
// whether or not the block is an orphan, in which case the fork length will
|
||||
// also be zero as expected, because it, by definition, does not connect ot the
|
||||
// also be zero as expected, because it, by definition, does not connect to the
|
||||
// best chain.
|
||||
//
|
||||
// This function is safe for concurrent access.
|
||||
|
||||
@ -249,7 +249,7 @@ func (e RuleError) GetCode() ErrorCode {
|
||||
return e.ErrorCode
|
||||
}
|
||||
|
||||
// stakeRuleError creates an RuleError given a set of arguments.
|
||||
// stakeRuleError creates a RuleError given a set of arguments.
|
||||
func stakeRuleError(c ErrorCode, desc string) RuleError {
|
||||
return RuleError{ErrorCode: c, Description: desc}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ func (e ErrorCode) String() string {
|
||||
return fmt.Sprintf("Unknown ErrorCode (%d)", int(e))
|
||||
}
|
||||
|
||||
// DBError identifies a an error in the stake database for tickets.
|
||||
// DBError identifies an error in the stake database for tickets.
|
||||
// The caller can use type assertions to determine if a failure was
|
||||
// specifically due to a rule violation and access the ErrorCode field to
|
||||
// ascertain the specific reason for the rule violation.
|
||||
|
||||
@ -179,7 +179,7 @@ func (s *parentStack) Push(node *treapNode) {
|
||||
// This approach is used over append because reslicing the slice to pop
|
||||
// the item causes the compiler to make unneeded allocations. Also,
|
||||
// since the max number of items is related to the tree depth which
|
||||
// requires expontentially more items to increase, only increase the cap
|
||||
// requires exponentially more items to increase, only increase the cap
|
||||
// one item at a time. This is more intelligent than the generic append
|
||||
// expansion algorithm which often doubles the cap.
|
||||
index := s.index - staticDepth
|
||||
|
||||
@ -373,7 +373,7 @@ func TestImmutableReverseSequential(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestImmutableUnordered ensures that putting keys into an immutable treap in
|
||||
// no paritcular order works as expected.
|
||||
// no particular order works as expected.
|
||||
func TestImmutableUnordered(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@ -842,7 +842,7 @@ func CheckSSGen(tx *wire.MsgTx) error {
|
||||
}
|
||||
|
||||
// IsSSGen returns whether or not a transaction is a stake submission generation
|
||||
// transaction. There are also known as votes.
|
||||
// transaction. These are also known as votes.
|
||||
func IsSSGen(tx *wire.MsgTx) bool {
|
||||
return CheckSSGen(tx) == nil
|
||||
}
|
||||
@ -937,7 +937,7 @@ func CheckSSRtx(tx *wire.MsgTx) error {
|
||||
}
|
||||
|
||||
// IsSSRtx returns whether or not a transaction is a stake submission revocation
|
||||
// transaction. There are also known as revocations.
|
||||
// transaction. These are also known as revocations.
|
||||
func IsSSRtx(tx *wire.MsgTx) bool {
|
||||
return CheckSSRtx(tx) == nil
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ func TestTicketDBLongChain(t *testing.T) {
|
||||
filename := filepath.Join("testdata", "testexpiry.bz2")
|
||||
fi, err := os.Open(filename)
|
||||
if err != nil {
|
||||
t.Fatalf("failed ot open test data: %v", err)
|
||||
t.Fatalf("failed to open test data: %v", err)
|
||||
}
|
||||
bcStream := bzip2.NewReader(fi)
|
||||
defer fi.Close()
|
||||
|
||||
@ -531,7 +531,7 @@ func (b *BlockChain) StateLastChangedHeight(hash *chainhash.Hash, version uint32
|
||||
return 0, HashError(hash.String())
|
||||
}
|
||||
|
||||
// Fetch the treshold state cache for the provided deployment id as well as
|
||||
// Fetch the threshold state cache for the provided deployment id as well as
|
||||
// the condition checker.
|
||||
var cache *thresholdStateCache
|
||||
var checker thresholdConditionChecker
|
||||
|
||||
@ -250,7 +250,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// version 3.
|
||||
//
|
||||
// This will result in triggering enforcement of the stake version and
|
||||
// that the stake version is 3. The treshold state for the test dummy
|
||||
// that the stake version is 3. The threshold state for the test dummy
|
||||
// deployments must still be defined since a v4 majority proof-of-work
|
||||
// and proof-of-stake upgrade are required before moving to started.
|
||||
// ---------------------------------------------------------------------
|
||||
@ -308,7 +308,7 @@ func TestThresholdState(t *testing.T) {
|
||||
//
|
||||
// This will result in achieving stake version 4 enforcement.
|
||||
//
|
||||
// The treshold state for the dummy deployments must still be defined
|
||||
// The threshold state for the dummy deployments must still be defined
|
||||
// since it can only change on a rule change boundary and it still
|
||||
// requires a v4 majority proof-of-work upgrade before moving to
|
||||
// started.
|
||||
@ -338,7 +338,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// the final two blocks to block version 4 so that majority version 4
|
||||
// is not achieved, but the final block in the interval is version 4.
|
||||
//
|
||||
// The treshold state for the dummy deployments must still be defined
|
||||
// The threshold state for the dummy deployments must still be defined
|
||||
// since it still requires a v4 majority proof-of-work upgrade before
|
||||
// moving to started.
|
||||
// ---------------------------------------------------------------------
|
||||
@ -375,7 +375,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// achieved and this will achieve v4 majority proof-of-work upgrade,
|
||||
// voting can begin at the next rule change interval.
|
||||
//
|
||||
// The treshold state for the dummy deployments must still be defined
|
||||
// The threshold state for the dummy deployments must still be defined
|
||||
// since even though all required upgrade conditions are met, the state
|
||||
// change must not happen until the start of the next rule change
|
||||
// interval.
|
||||
@ -405,7 +405,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// vote bits to include yes votes for the first test dummy agenda and
|
||||
// no for the second test dummy agenda to ensure they aren't counted.
|
||||
//
|
||||
// The treshold state for the dummy deployments must move to started.
|
||||
// The threshold state for the dummy deployments must move to started.
|
||||
// Even though the majority of the votes have already been voting yes
|
||||
// for the first test dummy agenda, and no for the second one, they must
|
||||
// not count, otherwise it would move straight to lockedin or failed,
|
||||
@ -437,7 +437,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// vote bits to include yes votes for the first test dummy agenda and
|
||||
// no for the second test dummy agenda to ensure they aren't counted.
|
||||
//
|
||||
// The treshold state for the dummy deployments must remain in started
|
||||
// The threshold state for the dummy deployments must remain in started
|
||||
// because the votes are an old version and thus have a different
|
||||
// definition and don't apply to version 4.
|
||||
// ---------------------------------------------------------------------
|
||||
@ -468,7 +468,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// votes for the first test dummy agenda and a majority no for the
|
||||
// second test dummy agenda.
|
||||
//
|
||||
// The treshold state for the dummy deployments must remain in started
|
||||
// The threshold state for the dummy deployments must remain in started
|
||||
// because quorum was not reached.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@ -504,7 +504,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// majority yes for the first test dummy agenda and a few votes shy of a
|
||||
// majority no for the second test dummy agenda.
|
||||
//
|
||||
// The treshold state for the dummy deployments must remain in started
|
||||
// The threshold state for the dummy deployments must remain in started
|
||||
// because even though quorum was reached, a required majority was not.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@ -547,7 +547,7 @@ func TestThresholdState(t *testing.T) {
|
||||
// vote bits to yes for the first test dummy agenda and no to the second
|
||||
// one.
|
||||
//
|
||||
// The treshold state for the first dummy deployment must move to
|
||||
// The threshold state for the first dummy deployment must move to
|
||||
// lockedin since a majority yes vote was achieved while the second
|
||||
// dummy deployment must move to failed since a majority no vote was
|
||||
// achieved.
|
||||
@ -578,12 +578,12 @@ func TestThresholdState(t *testing.T) {
|
||||
// vote bits to include no votes for the first test dummy agenda and
|
||||
// yes votes for the second one.
|
||||
//
|
||||
// The treshold state for the first dummy deployment must move to active
|
||||
// since even though the interval had a majority no votes, lockedin
|
||||
// status has already been achieved and can't be undone without a new
|
||||
// agenda. Similarly, the second one must remain in failed even though
|
||||
// the interval had a majority yes votes since a failed state can't be
|
||||
// undone.
|
||||
// The threshold state for the first dummy deployment must move to
|
||||
// active since even though the interval had a majority no votes,
|
||||
// lockedin status has already been achieved and can't be undone without
|
||||
// a new agenda. Similarly, the second one must remain in failed even
|
||||
// though the interval had a majority yes votes since a failed state
|
||||
// can't be undone.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
blocksNeeded = stakeValidationHeight + ruleChangeInterval*8 - 1 -
|
||||
|
||||
@ -1496,7 +1496,7 @@ func isStakeScriptHash(script []byte, stakeOpcode byte) bool {
|
||||
}
|
||||
|
||||
// isAllowedTicketInputScriptForm returns whether or not the passed public key
|
||||
// script is a one of the allowed forms for a ticket input.
|
||||
// script is one of the allowed forms for a ticket input.
|
||||
func isAllowedTicketInputScriptForm(script []byte) bool {
|
||||
return isPubKeyHash(script) || isScriptHash(script) ||
|
||||
isStakePubKeyHash(script, txscript.OP_SSGEN) ||
|
||||
@ -1726,7 +1726,7 @@ func checkTicketRedeemerCommitments(ticketHash *chainhash.Hash, ticketOuts []*st
|
||||
}
|
||||
contributionSumBig := big.NewInt(contributionSum)
|
||||
|
||||
// The outputs that satisify the commitments of the ticket start at offset
|
||||
// The outputs that satisfy the commitments of the ticket start at offset
|
||||
// 2 for votes while they start at 0 for revocations. Also, the payments
|
||||
// must be tagged with the appropriate stake opcode depending on whether it
|
||||
// is a vote or a revocation. Finally, the fee limits in the original
|
||||
@ -1908,7 +1908,7 @@ func checkVoteInputs(subsidyCache *standalone.SubsidyCache, tx *dcrutil.Tx, txHe
|
||||
ticketHash := &ticketIn.PreviousOutPoint.Hash
|
||||
ticketUtxo := view.LookupEntry(ticketHash)
|
||||
if ticketUtxo == nil || ticketUtxo.IsFullySpent() {
|
||||
str := fmt.Sprintf("ticket output %v referenced by vote %s:%d either "+
|
||||
str := fmt.Sprintf("ticket output %v referenced by vote %s:%d either "+
|
||||
"does not exist or has already been spent",
|
||||
ticketIn.PreviousOutPoint, voteHash, ticketInIdx)
|
||||
return ruleError(ErrMissingTxOut, str)
|
||||
|
||||
@ -66,7 +66,7 @@ var (
|
||||
},
|
||||
{
|
||||
Id: "Vote against",
|
||||
Description: "Vote against all multiple ",
|
||||
Description: "Vote against all multiple",
|
||||
Bits: 0x20, // 0b0010 0000
|
||||
IsAbstain: false,
|
||||
IsNo: true,
|
||||
|
||||
@ -330,7 +330,7 @@ type blockManagerConfig struct {
|
||||
TxMemPool *mempool.TxPool
|
||||
BgBlkTmplGenerator *BgBlkTmplGenerator
|
||||
|
||||
// The following fields are blockManger callbacks.
|
||||
// The following fields are blockManager callbacks.
|
||||
NotifyWinningTickets func(*WinningTicketsNtfnData)
|
||||
PruneRebroadcastInventory func()
|
||||
RpcServer func() *rpcServer
|
||||
@ -468,7 +468,7 @@ func (b *blockManager) startSync(peers *list.List) {
|
||||
|
||||
// Remove sync candidate peers that are no longer candidates due
|
||||
// to passing their latest known block. NOTE: The < is
|
||||
// intentional as opposed to <=. While techcnically the peer
|
||||
// intentional as opposed to <=. While technically the peer
|
||||
// doesn't have a later block when it's equal, it will likely
|
||||
// have one soon so it is a reasonable choice. It also allows
|
||||
// the case where both are at 0 such as during regression test.
|
||||
@ -1065,7 +1065,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
|
||||
b.cfg.TxMemPool.PruneExpiredTx()
|
||||
|
||||
// Update this peer's latest block height, for future
|
||||
// potential sync node candidancy.
|
||||
// potential sync node candidacy.
|
||||
heightUpdate = best.Height
|
||||
blkHashUpdate = &best.Hash
|
||||
|
||||
@ -1223,7 +1223,7 @@ func (b *blockManager) handleHeadersMsg(hmsg *headersMsg) {
|
||||
prevNodeEl := b.headerList.Back()
|
||||
if prevNodeEl == nil {
|
||||
bmgrLog.Warnf("Header list does not contain a previous" +
|
||||
"element as expected -- disconnecting peer")
|
||||
" element as expected -- disconnecting peer")
|
||||
hmsg.peer.Disconnect()
|
||||
return
|
||||
}
|
||||
@ -1889,7 +1889,7 @@ func (b *blockManager) handleBlockchainNotification(notification *blockchain.Not
|
||||
// TODO: In the case the new tip disapproves the previous block, any
|
||||
// transactions the previous block contains in its regular tree which
|
||||
// double spend the same inputs as transactions in either tree of the
|
||||
// current tip should ideally be tracked in the pool as eligibile for
|
||||
// current tip should ideally be tracked in the pool as eligible for
|
||||
// inclusion in an alternative tip (side chain block) in case the
|
||||
// current tip block does not get enough votes. However, the
|
||||
// transaction pool currently does not provide any way to distinguish
|
||||
|
||||
@ -153,7 +153,7 @@ func (e edwardsDSA) Decrypt(privkey []byte, in []byte) ([]byte,
|
||||
return e.decrypt(privkey, in)
|
||||
}
|
||||
|
||||
// newEdwardsDSA instatiates a function DSA subsystem over the edwards 25519
|
||||
// newEdwardsDSA instantiates a function DSA subsystem over the edwards 25519
|
||||
// curve. A caveat for the functions below is that they're all routed through
|
||||
// interfaces, and nil returns from the library itself for interfaces must
|
||||
// ALWAYS be checked by checking the return value by attempted dereference
|
||||
|
||||
@ -154,7 +154,7 @@ func (sp secp256k1DSA) Decrypt(privkey []byte, in []byte) ([]byte,
|
||||
return sp.decrypt(privkey, in)
|
||||
}
|
||||
|
||||
// newSecp256k1DSA instatiates a function DSA subsystem over the secp256k1
|
||||
// newSecp256k1DSA instantiates a function DSA subsystem over the secp256k1
|
||||
// curve. A caveat for the functions below is that they're all routed through
|
||||
// interfaces, and nil returns from the library itself for interfaces must
|
||||
// ALWAYS be checked by checking the return value by attempted dereference
|
||||
|
||||
@ -150,7 +150,7 @@ func (sp secSchnorrDSA) Decrypt(privkey []byte, in []byte) ([]byte,
|
||||
return sp.decrypt(privkey, in)
|
||||
}
|
||||
|
||||
// newSecSchnorrDSA instatiates a function DSA subsystem over the secp256k1
|
||||
// newSecSchnorrDSA instantiates a function DSA subsystem over the secp256k1
|
||||
// curve. A caveat for the functions below is that they're all routed through
|
||||
// interfaces, and nil returns from the library itself for interfaces must
|
||||
// ALWAYS be checked by checking the return value by attempted dereference
|
||||
|
||||
@ -45,7 +45,7 @@ type config struct {
|
||||
Progress int `short:"p" long:"progress" description:"Show a progress message each time this number of seconds have passed -- Use 0 to disable progress announcements"`
|
||||
}
|
||||
|
||||
// filesExists reports whether the named file or directory exists.
|
||||
// fileExists reports whether the named file or directory exists.
|
||||
func fileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@ -139,7 +139,7 @@ func (bi *blockImporter) processBlock(serializedBlock []byte) (bool, error) {
|
||||
}
|
||||
isMainChain := !isOrphan && forkLen == 0
|
||||
if !isMainChain {
|
||||
return false, fmt.Errorf("import file contains an block that "+
|
||||
return false, fmt.Errorf("import file contains a block that "+
|
||||
"does not extend the main chain: %v", blockHash)
|
||||
}
|
||||
if isOrphan {
|
||||
|
||||
@ -212,7 +212,7 @@ func cleanAndExpandPath(path string) string {
|
||||
return filepath.Join(homeDir, path)
|
||||
}
|
||||
|
||||
// filesExists reports whether the named file or directory exists.
|
||||
// fileExists reports whether the named file or directory exists.
|
||||
func fileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@ -134,7 +134,7 @@ func cleanAndExpandPath(path string) string {
|
||||
return filepath.Join(homeDir, path)
|
||||
}
|
||||
|
||||
// filesExists reports whether the named file or directory exists.
|
||||
// fileExists reports whether the named file or directory exists.
|
||||
func fileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@ -359,7 +359,7 @@ func normalizeAddresses(addrs []string, defaultPort string) []string {
|
||||
return removeDuplicateAddresses(addrs)
|
||||
}
|
||||
|
||||
// filesExists reports whether the named file or directory exists.
|
||||
// fileExists reports whether the named file or directory exists.
|
||||
func fileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
|
||||
const (
|
||||
// Halflife defines the time (in seconds) by which the transient part
|
||||
// of the ban score decays to one half of it's original value.
|
||||
// of the ban score decays to one half of its original value.
|
||||
Halflife = 60
|
||||
|
||||
// lambda is the decaying constant.
|
||||
|
||||
@ -1086,7 +1086,7 @@ func (tx *transaction) fetchKey(key []byte) []byte {
|
||||
// NOTE: This function must only be called on a writable transaction. Since it
|
||||
// is an internal helper function, it does not check.
|
||||
func (tx *transaction) deleteKey(key []byte, notifyIterators bool) {
|
||||
// Remove the key from the list of pendings keys to be written on
|
||||
// Remove the key from the list of pending keys to be written on
|
||||
// transaction commit if needed.
|
||||
tx.pendingKeys.Delete(key)
|
||||
|
||||
@ -1999,7 +1999,7 @@ func (db *db) Close() error {
|
||||
return closeErr
|
||||
}
|
||||
|
||||
// filesExists reports whether the named file or directory exists.
|
||||
// fileExists reports whether the named file or directory exists.
|
||||
func fileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@ -195,7 +195,7 @@ func TestCornerCases(t *testing.T) {
|
||||
ldb := idb.(*db).cache.ldb
|
||||
ldb.Close()
|
||||
|
||||
// Ensure initilization errors in the underlying database work as
|
||||
// Ensure initialization errors in the underlying database work as
|
||||
// expected.
|
||||
testName = "initDB: reinitialization"
|
||||
wantErrCode = database.ErrDbNotOpen
|
||||
|
||||
@ -119,7 +119,7 @@ func (s *parentStack) Push(node *treapNode) {
|
||||
// This approach is used over append because reslicing the slice to pop
|
||||
// the item causes the compiler to make unneeded allocations. Also,
|
||||
// since the max number of items is related to the tree depth which
|
||||
// requires expontentially more items to increase, only increase the cap
|
||||
// requires exponentially more items to increase, only increase the cap
|
||||
// one item at a time. This is more intelligent than the generic append
|
||||
// expansion algorithm which often doubles the cap.
|
||||
index := s.index - staticDepth
|
||||
|
||||
@ -255,7 +255,7 @@ func TestImmutableReverseSequential(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestImmutableUnordered ensures that putting keys into an immutable treap in
|
||||
// no paritcular order works as expected.
|
||||
// no particular order works as expected.
|
||||
func TestImmutableUnordered(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ func TestMutableReverseSequential(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestMutableUnordered ensures that putting keys into a mutable treap in no
|
||||
// paritcular order works as expected.
|
||||
// particular order works as expected.
|
||||
func TestMutableUnordered(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ func SignFromSecretNoReader(priv *PrivateKey, hash []byte) (r, s *big.Int, err e
|
||||
return
|
||||
}
|
||||
|
||||
// nonceRFC6979 is a local instatiation of deterministic nonce generation
|
||||
// nonceRFC6979 is a local instantiation of deterministic nonce generation
|
||||
// by the standards of RFC6979.
|
||||
func nonceRFC6979(privkey []byte, hash []byte, extra []byte, version []byte) []byte {
|
||||
pkD := new(big.Int).SetBytes(privkey)
|
||||
|
||||
@ -95,7 +95,7 @@ func parseSig(sigStr []byte, der bool) (*Signature, error) {
|
||||
}
|
||||
|
||||
// ParseSignature parses a signature in BER format for the curve type `curve'
|
||||
// into a Signature type, perfoming some basic sanity checks.
|
||||
// into a Signature type, performing some basic sanity checks.
|
||||
func ParseSignature(sigStr []byte) (*Signature, error) {
|
||||
return parseSig(sigStr, false)
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ func combinePubkeys(pks []*PublicKey) *PublicKey {
|
||||
}
|
||||
|
||||
// generateNoncePair deterministically generate a nonce pair for use in
|
||||
// partial signing of a message. Returns a public key (nonce to dissemanate)
|
||||
// partial signing of a message. Returns a public key (nonce to disseminate)
|
||||
// and a private nonce to keep as a secret for the signer.
|
||||
func generateNoncePair(msg []byte, priv []byte,
|
||||
nonceFunction func([]byte, []byte, []byte,
|
||||
|
||||
@ -166,7 +166,7 @@ func (f *fieldVal) Set(val *fieldVal) *fieldVal {
|
||||
}
|
||||
|
||||
// SetInt sets the field value to the passed integer. This is a convenience
|
||||
// function since it is fairly common to perform some arithemetic with small
|
||||
// function since it is fairly common to perform some arithmetic with small
|
||||
// native integers.
|
||||
//
|
||||
// The field value is returned to support chaining. This enables syntax such
|
||||
@ -506,7 +506,7 @@ func (f *fieldVal) Negate(magnitude uint32) *fieldVal {
|
||||
|
||||
// AddInt adds the passed integer to the existing field value and stores the
|
||||
// result in f. This is a convenience function since it is fairly common to
|
||||
// perform some arithemetic with small native integers.
|
||||
// perform some arithmetic with small native integers.
|
||||
//
|
||||
// The field value is returned to support chaining. This enables syntax like:
|
||||
// f.AddInt(1).Add(f2) so that f = f + 1 + f2.
|
||||
|
||||
@ -655,7 +655,7 @@ func TestMulInt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestMul ensures that multiplying two field valuess via Mul works as expected.
|
||||
// TestMul ensures that multiplying two field values via Mul works as expected.
|
||||
func TestMul(t *testing.T) {
|
||||
tests := []struct {
|
||||
in1 string // first hex encoded value
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v2"
|
||||
)
|
||||
|
||||
type SchorrSigningTestVectorHex struct {
|
||||
type SchnorrSigningTestVectorHex struct {
|
||||
msg string
|
||||
nonce string
|
||||
priv string
|
||||
@ -24,7 +24,7 @@ type SchorrSigningTestVectorHex struct {
|
||||
// schnorrSigningTestVectors were produced using the testing functions
|
||||
// implemented in libsecp256k1.
|
||||
// https://github.com/bitcoin/secp256k1/blob/258720851e24e23c1036b4802a185850e258a105/src/modules/schnorr/tests_impl.h
|
||||
var schnorrSigningTestVectors = []SchorrSigningTestVectorHex{
|
||||
var schnorrSigningTestVectors = []SchnorrSigningTestVectorHex{
|
||||
{"304502210088BE0644191B935DB1CD786B43FF27798006578D8C908906B49E89", "D1C4C30F60582323A609B56B92270181EB05C3E5AB3E19AE1F768C65C6D09A29", "714D90C991E5D26CBF5771D8A84D087200AAA3197C3217A702ED8D69EA714CAB", "0A3E13BFD0B64C120AA25D27E3CD87678154A4461CE0AD471273927A6459F0C6" + "B9A36629C110ECEEEBBD52E7A5D491BB10AF59C3C73285B9427D1254F28DC460"},
|
||||
{"304502210088BE0644191B935DB1CD786B43FF27798006578D8C908906B49E89", "86D9A69D76C1435EDC35347B50B4F944D30EDF8B5CB8E897E95F2C1F1B72D3C3", "60A30BC3BC7CDED4F13C9E3F20F69B8F7B4AB70E60825AE053FC88A2E7046C1F", "D60EFA079B194592A5200C60438A3617691FDE1B5FBCF788D0943A4BB69592F1" + "66D469F48267AA71DAF4BA996BA2BF3A99858C4BF854E2CDFC8AB7E6571D6A8C"},
|
||||
{"304502210088BE0644191B935DB1CD786B43FF27798006578D8C908906B49E89", "499FE87D281A8EDEC40D7C29202CA93F9E612760C689543897255CC3B543F2E9", "0C23A2A854DD57AC4773533E84039BA165CA1F79BE8019BDF9EA3173741C67E9", "3C3483E5CDAAF894261071A948B1E21906CEF0293D10A3D20325EA84CC129B32" + "FF07618FAD7BE485A5A1C15DD6EE5485058D03514259714E724879AABCD70C5D"},
|
||||
@ -85,21 +85,21 @@ var schnorrSigningTestVectors = []SchorrSigningTestVectorHex{
|
||||
{"304402207C7BC9E2D115C4C5C3E50950E69B30A9810BD73946A6D23C4ACBFF2E", "FFFF01000000FEFFFFFFFFF3FFFFFFFFFFFF7F000000000000F07FF8FFFFFFFF", "FFFFFFFF80FFFF07FEFF7F00000000000000FC07FCFFFF0700000000E0FFFFFF", "93E083E71C14BA94479CBE92213A56FF2ECFF8F2B085B2B3AA5CC6E8FEFAEAC0" + "76444710354091BB4FE9A218E875885F81DD787241A766C4E0422C5C1D7AD271"},
|
||||
}
|
||||
|
||||
type SchorrSigningTestVector struct {
|
||||
type SchnorrSigningTestVector struct {
|
||||
msg []byte
|
||||
nonce []byte
|
||||
priv []byte
|
||||
sig []byte
|
||||
}
|
||||
|
||||
func GetSigningTestVectors() []*SchorrSigningTestVector {
|
||||
tvs := make([]*SchorrSigningTestVector, 0, len(schnorrSigningTestVectors))
|
||||
func GetSigningTestVectors() []*SchnorrSigningTestVector {
|
||||
tvs := make([]*SchnorrSigningTestVector, 0, len(schnorrSigningTestVectors))
|
||||
for _, v := range schnorrSigningTestVectors {
|
||||
msg, _ := hex.DecodeString(v.msg)
|
||||
nonce, _ := hex.DecodeString(v.nonce)
|
||||
priv, _ := hex.DecodeString(v.priv)
|
||||
sig, _ := hex.DecodeString(v.sig)
|
||||
lv := SchorrSigningTestVector{msg, nonce, priv, sig}
|
||||
lv := SchnorrSigningTestVector{msg, nonce, priv, sig}
|
||||
tvs = append(tvs, &lv)
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ func parseSig(sigStr []byte) (*Signature, error) {
|
||||
}
|
||||
|
||||
// ParseSignature parses a signature in BER format for the curve type `curve'
|
||||
// into a Signature type, perfoming some basic sanity checks.
|
||||
// into a Signature type, performing some basic sanity checks.
|
||||
func ParseSignature(sigStr []byte) (*Signature, error) {
|
||||
return parseSig(sigStr)
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ func combinePubkeys(pks []*secp256k1.PublicKey) *secp256k1.PublicKey {
|
||||
return secp256k1.NewPublicKey(pkSumX, pkSumY)
|
||||
}
|
||||
|
||||
// nonceRFC6979 is a local instatiation of deterministic nonce generation
|
||||
// nonceRFC6979 is a local instantiation of deterministic nonce generation
|
||||
// by the standards of RFC6979.
|
||||
func nonceRFC6979(privkey []byte, hash []byte, extra []byte,
|
||||
version []byte) []byte {
|
||||
@ -69,7 +69,7 @@ func nonceRFC6979(privkey []byte, hash []byte, extra []byte,
|
||||
}
|
||||
|
||||
// generateNoncePair deterministically generate a nonce pair for use in
|
||||
// partial signing of a message. Returns a public key (nonce to dissemanate)
|
||||
// partial signing of a message. Returns a public key (nonce to disseminate)
|
||||
// and a private nonce to keep as a secret for the signer.
|
||||
func generateNoncePair(msg []byte, priv []byte,
|
||||
nonceFunction func([]byte, []byte, []byte, []byte) []byte, extra []byte,
|
||||
|
||||
@ -210,7 +210,7 @@ func parseSig(sigStr []byte, der bool) (*Signature, error) {
|
||||
}
|
||||
|
||||
// ParseSignature parses a signature in BER format for the curve type `curve'
|
||||
// into a Signature type, perfoming some basic sanity checks. If parsing
|
||||
// into a Signature type, performing some basic sanity checks. If parsing
|
||||
// according to the more strict DER format is needed, use ParseDERSignature.
|
||||
func ParseSignature(sigStr []byte) (*Signature, error) {
|
||||
return parseSig(sigStr, false)
|
||||
@ -352,7 +352,7 @@ func recoverKeyFromSignature(sig *Signature, msg []byte,
|
||||
// public key or not. If successful the bytes of the compact signature will be
|
||||
// returned in the format:
|
||||
// <(byte of 27+public key solution)+4 if compressed >< padded bytes for signature R><padded bytes for signature S>
|
||||
// where the R and S parameters are padded up to the bitlengh of the curve.
|
||||
// where the R and S parameters are padded up to the bitlength of the curve.
|
||||
func SignCompact(key *PrivateKey,
|
||||
hash []byte, isCompressedKey bool) ([]byte, error) {
|
||||
sig, err := key.Sign(hash)
|
||||
@ -399,7 +399,7 @@ func SignCompact(key *PrivateKey,
|
||||
|
||||
// RecoverCompact verifies the compact signature "signature" of "hash" for the
|
||||
// Koblitz curve in "curve". If the signature matches then the recovered public
|
||||
// key will be returned as well as a boolen if the original key was compressed
|
||||
// key will be returned as well as a boolean if the original key was compressed
|
||||
// or not, else an error will be returned.
|
||||
func RecoverCompact(signature,
|
||||
hash []byte) (*PublicKey, bool, error) {
|
||||
|
||||
@ -174,7 +174,7 @@ func TestAssignField(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Inidirect through to the base types to ensure their values
|
||||
// Indirect through to the base types to ensure their values
|
||||
// are the same.
|
||||
for dst.Kind() == reflect.Ptr {
|
||||
dst = dst.Elem()
|
||||
|
||||
@ -197,7 +197,7 @@ func reflectTypeToJSONExample(xT descLookupFunc, rt reflect.Type, indentLevel in
|
||||
// previous field to house the opening array bracket, so
|
||||
// replace the opening object brace with the array
|
||||
// syntax. Also, replace the final closing object brace
|
||||
// with the variadiac array closing syntax.
|
||||
// with the variadic array closing syntax.
|
||||
indent := strings.Repeat(" ", indentLevel)
|
||||
if indentLevel == 0 {
|
||||
results[0] = indent + "[{"
|
||||
@ -209,7 +209,7 @@ func reflectTypeToJSONExample(xT descLookupFunc, rt reflect.Type, indentLevel in
|
||||
// the opening array bracket and object brace are
|
||||
// already a part of the previous field. However, the
|
||||
// closing entry is a simple object brace, so replace it
|
||||
// with the variadiac array closing syntax. The final
|
||||
// with the variadic array closing syntax. The final
|
||||
// tabs are necessary so the tab writer lines things up
|
||||
// properly.
|
||||
results[len(results)-1] = indent + "},...],\t\t"
|
||||
@ -537,7 +537,7 @@ func GenerateHelp(method interface{}, descs map[string]string, resultTypes ...in
|
||||
}
|
||||
|
||||
// Create a closure for the description lookup function which falls back
|
||||
// to the base help descritptions map for unrecognized keys and tracks
|
||||
// to the base help descriptions map for unrecognized keys and tracks
|
||||
// and missing keys.
|
||||
var missingKey string
|
||||
xT := func(key string) string {
|
||||
|
||||
@ -23,10 +23,10 @@ type RPCError struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// Guarantee RPCError satisifies the builtin error interface.
|
||||
// Guarantee RPCError satisfies the builtin error interface.
|
||||
var _, _ error = RPCError{}, (*RPCError)(nil)
|
||||
|
||||
// Error returns a string describing the RPC error. This satisifies the
|
||||
// Error returns a string describing the RPC error. This satisfies the
|
||||
// builtin error interface.
|
||||
func (e RPCError) Error() string {
|
||||
return fmt.Sprintf("%d: %s", e.Code, e.Message)
|
||||
|
||||
@ -102,7 +102,7 @@ func (a Amount) ToCoin() float64 {
|
||||
|
||||
// Format formats a monetary amount counted in coin base units as a
|
||||
// string for a given unit. The conversion will succeed for any unit,
|
||||
// however, known units will be formated with an appended label describing
|
||||
// however, known units will be formatted with an appended label describing
|
||||
// the units with SI notation, or "atom" for the base unit.
|
||||
func (a Amount) Format(u AmountUnit) string {
|
||||
units := " " + u.String()
|
||||
|
||||
@ -82,7 +82,7 @@ func ExampleAmount_unitConversions() {
|
||||
}
|
||||
|
||||
// This example demonstrates decoding addresses, determining their underlying
|
||||
// type, and displaying their associated underlying hash160 and digitial
|
||||
// type, and displaying their associated underlying hash160 and digital
|
||||
// signature algorithm.
|
||||
func ExampleDecodeAddress() {
|
||||
// Ordinarily addresses would be read from the user or the result of a
|
||||
@ -105,7 +105,7 @@ func ExampleDecodeAddress() {
|
||||
// algorithms, so this code is limited to that type
|
||||
switch a := addr.(type) {
|
||||
case *dcrutil.AddressPubKeyHash:
|
||||
// Determine and display the digitial signature algorithm.
|
||||
// Determine and display the digital signature algorithm.
|
||||
algo := "unknown"
|
||||
switch a.DSA() {
|
||||
case dcrec.STEcdsaSecp256k1:
|
||||
|
||||
@ -24,7 +24,7 @@ func (s sortableInputSlice) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Swap swaps the transaction intputs at the passed indices. It is part of the
|
||||
// Swap swaps the transaction inputs at the passed indices. It is part of the
|
||||
// sort.Interface implementation.
|
||||
func (s sortableInputSlice) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
|
||||
@ -76,7 +76,7 @@ func TestSort(t *testing.T) {
|
||||
sortedHash: "bb5f9b338c0244e51182b10f36b5ca4c6eeaa2eae98a7bfc106d1f108f154525",
|
||||
},
|
||||
{
|
||||
name: "block 150626 tx[24] - sorts outputs only, based on amount and output script ",
|
||||
name: "block 150626 tx[24] - sorts outputs only, based on amount and output script",
|
||||
hexFile: "tx150626-24.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "60542bf8ff4acd9ddb28fd9a2df33d23dd2b70a9aaca1f3dd5fe737879205e56",
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
// encountered.
|
||||
var ErrMalformedPrivateKey = errors.New("malformed private key")
|
||||
|
||||
// ErrWrongWIFNetwork desribes an error in which the provided WIF is not for
|
||||
// ErrWrongWIFNetwork describes an error in which the provided WIF is not for
|
||||
// the expected network.
|
||||
type ErrWrongWIFNetwork [2]byte
|
||||
|
||||
|
||||
@ -2071,7 +2071,7 @@ The recvtx notification for the same txout, after the transaction was mined into
|
||||
# <code>Block details</code>: <code>(object, optional)</code> details about a block and the index of the transaction within a block, if the transaction is mined.
|
||||
|-
|
||||
!Description
|
||||
|Notifies a client when an registered outpoint is spent by a transaction accepted to mempool and/or mined into a block.
|
||||
|Notifies a client when a registered outpoint is spent by a transaction accepted to mempool and/or mined into a block.
|
||||
|-
|
||||
!Example
|
||||
|Example redeemingtx notification for mainnet outpoint <code>61d3696de4c888730cbe06b0ad8ecb6d72d6108e893895aa9bc067bd7eba3fad:0</code> after being spent by transaction <code>4ad0c16ac973ff675dec1f3e5f1273f1c45be2a63554343f21b70240a1e43ece</code>:
|
||||
|
||||
@ -59,7 +59,7 @@ func Example_defaultWalletLayout() {
|
||||
|
||||
// Ordinarily this would either be read from some encrypted source
|
||||
// and be decrypted or generated as the NewMaster example shows, but
|
||||
// for the purposes of this example, the private exteded key for the
|
||||
// for the purposes of this example, the private extended key for the
|
||||
// master node is being hard coded here.
|
||||
master := "dprv3hCznBesA6jBushjx7y9NrfheE4ZshnaKYtsoLXefmLPzrXgEiXkd" +
|
||||
"RMD6UngnmBYZzgNhdEd4K3PidxcaCiR6HC9hmpj8FcrP4Cv7zBwELA"
|
||||
@ -173,7 +173,7 @@ func Example_audits() {
|
||||
|
||||
// Ordinarily this would either be read from some encrypted source
|
||||
// and be decrypted or generated as the NewMaster example shows, but
|
||||
// for the purposes of this example, the private exteded key for the
|
||||
// for the purposes of this example, the private extended key for the
|
||||
// master node is being hard coded here.
|
||||
master := "dprv3hCznBesA6jBushjx7y9NrfheE4ZshnaKYtsoLXefmLPzrXgEiXkd" +
|
||||
"RMD6UngnmBYZzgNhdEd4K3PidxcaCiR6HC9hmpj8FcrP4Cv7zBwELA"
|
||||
|
||||
4
log.go
4
log.go
@ -108,9 +108,9 @@ var subsystemLoggers = map[string]slog.Logger{
|
||||
"TXMP": txmpLog,
|
||||
}
|
||||
|
||||
// initLogRotator initializes the logging rotater to write logs to logFile and
|
||||
// initLogRotator initializes the logging rotator to write logs to logFile and
|
||||
// create roll files in the same directory. It must be called before the
|
||||
// package-global log rotater variables are used.
|
||||
// package-global log rotator variables are used.
|
||||
func initLogRotator(logFile string) {
|
||||
logDir, _ := filepath.Split(logFile)
|
||||
err := os.MkdirAll(logDir, 0700)
|
||||
|
||||
@ -73,7 +73,7 @@ testLoop:
|
||||
cache.Add(uint64(numNonces) + 1)
|
||||
|
||||
// Ensure the original lru entry still exists since it was updated
|
||||
// and should've have become the lru entry.
|
||||
// and should have become the lru entry.
|
||||
if !cache.Contains(nonces[origLruIndex]) {
|
||||
t.Errorf("Contains #%d (%s) entry %d does not exist", i, test.name,
|
||||
nonces[origLruIndex])
|
||||
|
||||
@ -221,7 +221,7 @@ func (s *fakeChain) CalcSequenceLock(tx *dcrutil.Tx, view *blockchain.UtxoViewpo
|
||||
// in order to facilitate testing the fake chain instance instead
|
||||
// allows callers to directly set median times associated with fake
|
||||
// utxos and looks up those values here.
|
||||
medianTime := s.FakeUxtoMedianTime(&txIn.PreviousOutPoint)
|
||||
medianTime := s.FakeUtxoMedianTime(&txIn.PreviousOutPoint)
|
||||
|
||||
// Calculate the minimum required timestamp based on the sum of the
|
||||
// past median time and required relative number of seconds. Since
|
||||
@ -262,9 +262,9 @@ func (s *fakeChain) SetStandardVerifyFlags(flags txscript.ScriptFlags) {
|
||||
s.scriptFlags = flags
|
||||
}
|
||||
|
||||
// FakeUxtoMedianTime returns the median time associated with the requested utxo
|
||||
// FakeUtxoMedianTime returns the median time associated with the requested utxo
|
||||
// from the fake chain instance.
|
||||
func (s *fakeChain) FakeUxtoMedianTime(prevOut *wire.OutPoint) int64 {
|
||||
func (s *fakeChain) FakeUtxoMedianTime(prevOut *wire.OutPoint) int64 {
|
||||
s.RLock()
|
||||
medianTime := s.utxoTimes[*prevOut]
|
||||
s.RUnlock()
|
||||
@ -349,7 +349,7 @@ func (p *poolHarness) GetKey(addr dcrutil.Address) (chainec.PrivateKey, bool, er
|
||||
return p.signKey, true, nil
|
||||
}
|
||||
|
||||
// AddFakeUTXO creates a fake mined uxto for the provided transaction.
|
||||
// AddFakeUTXO creates a fake mined utxo for the provided transaction.
|
||||
func (p *poolHarness) AddFakeUTXO(tx *dcrutil.Tx, blockHeight int64) {
|
||||
p.chain.utxos.AddTxOuts(tx, blockHeight, wire.NullBlockIndex)
|
||||
}
|
||||
@ -1333,7 +1333,7 @@ func TestBasicOrphanRemoval(t *testing.T) {
|
||||
testPoolMembership(tc, tx, true, false)
|
||||
}
|
||||
|
||||
// Attempt to remove an orphan that has a existing redeemer but itself
|
||||
// Attempt to remove an orphan that has an existing redeemer but itself
|
||||
// is not present and ensure the state of all other orphans (including
|
||||
// the one that redeems it) are unaffected.
|
||||
harness.txPool.RemoveOrphan(chainedTxns[0])
|
||||
@ -1599,14 +1599,14 @@ func TestSequenceLockAcceptance(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "By-time lock with unsatisifed seq == 1024",
|
||||
name: "By-time lock with unsatisfied seq == 1024",
|
||||
txVersion: 2,
|
||||
sequence: mustLockTimeToSeq(true, seqIntervalToSecs(2)),
|
||||
secsOffset: int64(seqIntervalToSecs(1)),
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "By-time lock with unsatisifed masked max sequence",
|
||||
name: "By-time lock with unsatisfied masked max sequence",
|
||||
txVersion: 2,
|
||||
sequence: 0xffffffff &^ seqLockTimeDisabled,
|
||||
secsOffset: int64(seqIntervalToSecs(65534)),
|
||||
@ -1620,7 +1620,7 @@ func TestSequenceLockAcceptance(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Disabled by-height lock with unsatisified sequence",
|
||||
name: "Disabled by-height lock with unsatisfied sequence",
|
||||
txVersion: 2,
|
||||
sequence: mustLockTimeToSeq(false, 2) | seqLockTimeDisabled,
|
||||
heightOffset: 0,
|
||||
@ -1634,7 +1634,7 @@ func TestSequenceLockAcceptance(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Disabled by-time lock with unsatisifed seq == 1024",
|
||||
name: "Disabled by-time lock with unsatisfied seq == 1024",
|
||||
txVersion: 2,
|
||||
sequence: mustLockTimeToSeq(true, seqIntervalToSecs(2)) |
|
||||
seqLockTimeDisabled,
|
||||
@ -1666,7 +1666,7 @@ func TestSequenceLockAcceptance(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "By-time lock with unsatisifed seq == 1024 (v1)",
|
||||
name: "By-time lock with unsatisfied seq == 1024 (v1)",
|
||||
txVersion: 1,
|
||||
sequence: mustLockTimeToSeq(true, seqIntervalToSecs(2)),
|
||||
secsOffset: int64(seqIntervalToSecs(1)),
|
||||
@ -1680,7 +1680,7 @@ func TestSequenceLockAcceptance(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Disabled by-height lock with unsatisified seq (v1)",
|
||||
name: "Disabled by-height lock with unsatisfied seq (v1)",
|
||||
txVersion: 1,
|
||||
sequence: mustLockTimeToSeq(false, 2) | seqLockTimeDisabled,
|
||||
heightOffset: 0,
|
||||
@ -1694,7 +1694,7 @@ func TestSequenceLockAcceptance(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Disabled by-time lock with unsatisifed seq == 1024 (v1)",
|
||||
name: "Disabled by-time lock with unsatisfied seq == 1024 (v1)",
|
||||
txVersion: 1,
|
||||
sequence: mustLockTimeToSeq(true, seqIntervalToSecs(2)) |
|
||||
seqLockTimeDisabled,
|
||||
|
||||
12
mining.go
12
mining.go
@ -833,7 +833,7 @@ func handleTooFewVoters(subsidyCache *standalone.SubsidyCache, nextHeight int64,
|
||||
// Fetch the latest block and head and begin working
|
||||
// off of it with an empty transaction tree regular
|
||||
// and the contents of that stake tree. In the future
|
||||
// we should have the option of readding some
|
||||
// we should have the option of reading some
|
||||
// transactions from this block, too.
|
||||
topBlock, err := bm.chain.BlockByHash(&best.Hash)
|
||||
if err != nil {
|
||||
@ -1050,7 +1050,7 @@ func newBlkTmplGenerator(policy *mining.Policy, txSource mining.TxSource,
|
||||
// This function returns nil, nil if there are not enough voters on any of
|
||||
// the current top blocks to create a new block template.
|
||||
func (g *BlkTmplGenerator) NewBlockTemplate(payToAddress dcrutil.Address) (*BlockTemplate, error) {
|
||||
// All transaction scripts are verified using the more strict standarad
|
||||
// All transaction scripts are verified using the more strict standard
|
||||
// flags.
|
||||
scriptFlags, err := standardScriptVerifyFlags(g.chain)
|
||||
if err != nil {
|
||||
@ -1455,7 +1455,7 @@ mempoolLoop:
|
||||
priorityQueue.SetLessFunc(txPQByStakeAndFee)
|
||||
|
||||
// Put the transaction back into the priority queue and
|
||||
// skip it so it is re-priortized by fees if it won't
|
||||
// skip it so it is re-prioritized by fees if it won't
|
||||
// fit into the high-priority section or the priority is
|
||||
// too low. Otherwise this transaction will be the
|
||||
// final one in the high-priority section, so just fall
|
||||
@ -1518,7 +1518,7 @@ mempoolLoop:
|
||||
prioItem.tx.Hash(), prioItem.priority, prioItem.feePerKB)
|
||||
|
||||
// Add transactions which depend on this one (and also do not
|
||||
// have any other unsatisified dependencies) to the priority
|
||||
// have any other unsatisfied dependencies) to the priority
|
||||
// queue.
|
||||
for _, item := range deps {
|
||||
// Add the transaction to the priority queue if there
|
||||
@ -2423,7 +2423,7 @@ type regenHandlerState struct {
|
||||
// can be reset at any time without needing to create a new one and the
|
||||
// associated extra garbage.
|
||||
//
|
||||
// regenTimer is a underlying timer that is used to implement the timeout.
|
||||
// regenTimer is an underlying timer that is used to implement the timeout.
|
||||
//
|
||||
// regenChanDrained indicates whether or not the channel for the regen timer
|
||||
// has already been read and is used when resetting the timer to ensure the
|
||||
@ -2926,7 +2926,7 @@ func (g *BgBlkTmplGenerator) handleVote(ctx context.Context, state *regenHandler
|
||||
}
|
||||
}
|
||||
|
||||
// handleTemplateUpdate handles the rtTemlateUpdate event by updating the state
|
||||
// handleTemplateUpdate handles the rtTemplateUpdate event by updating the state
|
||||
// accordingly.
|
||||
//
|
||||
// This function is only intended for use by the regen handler goroutine.
|
||||
|
||||
@ -107,7 +107,7 @@ func CalcPriority(tx *wire.MsgTx, utxoView *blockchain.UtxoViewpoint, nextBlockH
|
||||
// A compressed pubkey pay-to-script-hash redemption with a maximum len
|
||||
// signature is of the form:
|
||||
// [OP_DATA_73 <73-byte sig> + OP_DATA_35 + {OP_DATA_33
|
||||
// <33 byte compresed pubkey> + OP_CHECKSIG}]
|
||||
// <33 byte compressed pubkey> + OP_CHECKSIG}]
|
||||
//
|
||||
// Thus 1 + 73 + 1 + 1 + 33 + 1 = 110
|
||||
overhead := 0
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
// mockRemotePeer creates a basic inbound peer listening on the simnet port for
|
||||
// use with Example_peerConnection. It does not return until the listner is
|
||||
// use with Example_peerConnection. It does not return until the listener is
|
||||
// active.
|
||||
func mockRemotePeer() error {
|
||||
// Configure peer to act as a simnet node that offers no services.
|
||||
|
||||
@ -208,12 +208,12 @@ type Config struct {
|
||||
NewestBlock HashFunc
|
||||
|
||||
// HostToNetAddress returns the netaddress for the given host. This can be
|
||||
// nil in which case the host will be parsed as an IP address.
|
||||
// nil in which case the host will be parsed as an IP address.
|
||||
HostToNetAddress HostToNetAddrFunc
|
||||
|
||||
// Proxy indicates a proxy is being used for connections. The only
|
||||
// effect this has is to prevent leaking the tor proxy address, so it
|
||||
// only needs to specified if using a tor proxy.
|
||||
// only needs to be specified if using a tor proxy.
|
||||
Proxy string
|
||||
|
||||
// UserAgentName specifies the user agent name to advertise. It is
|
||||
@ -1057,7 +1057,7 @@ func (p *Peer) maybeAddDeadline(pendingResponses map[string]time.Time, msgCmd st
|
||||
// Setup a deadline for each message being sent that expects a response.
|
||||
//
|
||||
// NOTE: Pings are intentionally ignored here since they are typically
|
||||
// sent asynchronously and as a result of a long backlock of messages,
|
||||
// sent asynchronously and as a result of a long backlog of messages,
|
||||
// such as is typical in the case of initial block download, the
|
||||
// response won't be received in time.
|
||||
log.Debugf("Adding deadline for command %s for peer %s", msgCmd, p.addr)
|
||||
|
||||
@ -44,7 +44,7 @@ const (
|
||||
// persistent peer.
|
||||
NRemove NodeSubCmd = "remove"
|
||||
|
||||
// NDisconnect indicates the specified peer should be disonnected.
|
||||
// NDisconnect indicates the specified peer should be disconnected.
|
||||
NDisconnect NodeSubCmd = "disconnect"
|
||||
)
|
||||
|
||||
|
||||
@ -1206,7 +1206,7 @@ func TestChainSvrCmds(t *testing.T) {
|
||||
// new command creation function.
|
||||
cmd, err := test.newCmd()
|
||||
if err != nil {
|
||||
t.Errorf("Test #%d (%s) unexpected dcrjson.NewCmd error: %v ",
|
||||
t.Errorf("Test #%d (%s) unexpected dcrjson.NewCmd error: %v",
|
||||
i, test.name, err)
|
||||
}
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ func TestChainSvrWsCmds(t *testing.T) {
|
||||
// new command creation function.
|
||||
cmd, err := test.newCmd()
|
||||
if err != nil {
|
||||
t.Errorf("Test #%d (%s) unexpected dcrjson.NewCmd error: %v ",
|
||||
t.Errorf("Test #%d (%s) unexpected dcrjson.NewCmd error: %v",
|
||||
i, test.name, err)
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ func TestChainSvrWsNtfns(t *testing.T) {
|
||||
// generic new notification creation function.
|
||||
cmd, err := test.newNtfn()
|
||||
if err != nil {
|
||||
t.Errorf("Test #%d (%s) unexpected dcrjson.NewCmd error: %v ",
|
||||
t.Errorf("Test #%d (%s) unexpected dcrjson.NewCmd error: %v",
|
||||
i, test.name, err)
|
||||
}
|
||||
|
||||
|
||||
@ -707,7 +707,7 @@ func (r FutureGetTxOutResult) Receive() (*chainjson.GetTxOutResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Unmarshal result as an gettxout result object.
|
||||
// Unmarshal result as a gettxout result object.
|
||||
var txOutInfo *chainjson.GetTxOutResult
|
||||
err = json.Unmarshal(res, &txOutInfo)
|
||||
if err != nil {
|
||||
|
||||
@ -107,7 +107,7 @@ Some of the commands are extensions specific to a particular RPC server. For
|
||||
example, the DebugLevel call is an extension only provided by dcrd (and
|
||||
dcrwallet passthrough). Therefore if you call one of these commands against
|
||||
an RPC server that doesn't provide them, you will get an unimplemented error
|
||||
from the server. An effort has been made to call out which commmands are
|
||||
from the server. An effort has been made to call out which commands are
|
||||
extensions in their documentation.
|
||||
|
||||
Also, it is important to realize that dcrd intentionally separates the wallet
|
||||
|
||||
@ -117,7 +117,7 @@ func (r FutureEstimateStakeDiffResult) Receive() (*chainjson.EstimateStakeDiffRe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unmarsal result as a estimatestakediff result object.
|
||||
// Unmarshal result as an estimatestakediff result object.
|
||||
var est chainjson.EstimateStakeDiffResult
|
||||
err = json.Unmarshal(res, &est)
|
||||
if err != nil {
|
||||
@ -600,7 +600,7 @@ func (r FutureGetHeadersResult) Receive() (*chainjson.GetHeadersResult, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unmarsal result as a getheaders result object.
|
||||
// Unmarshal result as a getheaders result object.
|
||||
var vr chainjson.GetHeadersResult
|
||||
err = json.Unmarshal(res, &vr)
|
||||
if err != nil {
|
||||
@ -1048,7 +1048,7 @@ func (r FutureTicketFeeInfoResult) Receive() (*chainjson.TicketFeeInfoResult, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unmarsal result as a ticketfeeinfo result object.
|
||||
// Unmarshal result as a ticketfeeinfo result object.
|
||||
var tfir chainjson.TicketFeeInfoResult
|
||||
err = json.Unmarshal(res, &tfir)
|
||||
if err != nil {
|
||||
@ -1105,7 +1105,7 @@ func (r FutureTicketVWAPResult) Receive() (dcrutil.Amount, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Unmarsal result as a ticketvwap result object.
|
||||
// Unmarshal result as a ticketvwap result object.
|
||||
var vwap float64
|
||||
err = json.Unmarshal(res, &vwap)
|
||||
if err != nil {
|
||||
@ -1158,7 +1158,7 @@ func (r FutureTxFeeInfoResult) Receive() (*chainjson.TxFeeInfoResult, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unmarsal result as a txfeeinfo result object.
|
||||
// Unmarshal result as a txfeeinfo result object.
|
||||
var tfir chainjson.TxFeeInfoResult
|
||||
err = json.Unmarshal(res, &tfir)
|
||||
if err != nil {
|
||||
@ -1206,7 +1206,7 @@ func (r FutureVersionResult) Receive() (map[string]chainjson.VersionResult, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unmarsal result as a version result object.
|
||||
// Unmarshal result as a version result object.
|
||||
var vr map[string]chainjson.VersionResult
|
||||
err = json.Unmarshal(res, &vr)
|
||||
if err != nil {
|
||||
|
||||
@ -816,8 +816,8 @@ func (c *Client) sendPostRequest(httpReq *http.Request, jReq *jsonRequest) {
|
||||
}
|
||||
|
||||
// newFutureError returns a new future result channel that already has the
|
||||
// passed error waitin on the channel with the reply set to nil. This is useful
|
||||
// to easily return errors from the various Async functions.
|
||||
// passed error waiting on the channel with the reply set to nil. This is
|
||||
// useful to easily return errors from the various Async functions.
|
||||
func newFutureError(err error) chan *response {
|
||||
responseChan := make(chan *response, 1)
|
||||
responseChan <- &response{err: err}
|
||||
|
||||
@ -527,12 +527,12 @@ func (c *Client) handleNotification(ntfn *rawNotification) {
|
||||
}
|
||||
|
||||
// wrongNumParams is an error type describing an unparseable JSON-RPC
|
||||
// notificiation due to an incorrect number of parameters for the
|
||||
// notification due to an incorrect number of parameters for the
|
||||
// expected notification type. The value is the number of parameters
|
||||
// of the invalid notification.
|
||||
type wrongNumParams int
|
||||
|
||||
// Error satisifies the builtin error interface.
|
||||
// Error satisfies the builtin error interface.
|
||||
func (e wrongNumParams) Error() string {
|
||||
return fmt.Sprintf("wrong number of parameters (%d)", e)
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ func (c *Client) SendToAddressCommentAsync(address dcrutil.Address,
|
||||
// SendToAddressComment sends the passed amount to the given address and stores
|
||||
// the provided comment and comment to in the wallet. The comment parameter is
|
||||
// intended to be used for the purpose of the transaction while the commentTo
|
||||
// parameter is indended to be used for who the transaction is being sent to.
|
||||
// parameter is intended to be used for who the transaction is being sent to.
|
||||
//
|
||||
// The comments are not part of the transaction and are only internal
|
||||
// to the wallet.
|
||||
@ -587,7 +587,7 @@ func (c *Client) SendFromCommentAsync(fromAccount string,
|
||||
// SendFromComment sends the passed amount to the given address using the
|
||||
// provided account as a source of funds and stores the provided comment and
|
||||
// comment to in the wallet. The comment parameter is intended to be used for
|
||||
// the purpose of the transaction while the commentTo parameter is indended to
|
||||
// the purpose of the transaction while the commentTo parameter is intended to
|
||||
// be used for who the transaction is being sent to. Only funds with the passed
|
||||
// number of minimum confirmations will be used.
|
||||
//
|
||||
@ -2226,7 +2226,7 @@ func (r FutureAccountAddressIndexResult) Receive() (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Unmarshal result as a accountaddressindex result object.
|
||||
// Unmarshal result as an accountaddressindex result object.
|
||||
var index int
|
||||
err = json.Unmarshal(res, &index)
|
||||
if err != nil {
|
||||
|
||||
12
rpcserver.go
12
rpcserver.go
@ -157,7 +157,7 @@ var (
|
||||
}
|
||||
|
||||
// ErrInvalidLongPoll is an internal error code to indicate that
|
||||
// longpollid is not formated properly.
|
||||
// longpollid is not formatted properly.
|
||||
ErrInvalidLongPoll = errors.New("invalid longpollid format")
|
||||
)
|
||||
|
||||
@ -425,7 +425,7 @@ func rpcNoTxInfoError(txHash *chainhash.Hash) *dcrjson.RPCError {
|
||||
}
|
||||
|
||||
// rpcMiscError is a convenience function for returning a nicely formatted RPC
|
||||
// error which indicates there is a unquantifiable error. Use this sparingly;
|
||||
// error which indicates there is an unquantifiable error. Use this sparingly;
|
||||
// misc return codes are a cop out.
|
||||
func rpcMiscError(message string) *dcrjson.RPCError {
|
||||
return dcrjson.NewRPCError(dcrjson.ErrRPCMisc, message)
|
||||
@ -2280,7 +2280,7 @@ func (state *gbtWorkState) templateUpdateChan(prevHash *chainhash.Hash, lastGene
|
||||
// changed or the transactions in the memory pool have been updated and it has
|
||||
// been long enough since the last template was generated. Otherwise, the
|
||||
// timestamp for the existing block template is updated (and possibly the
|
||||
// difficulty on testnet per the consesus rules). Finally, if the
|
||||
// difficulty on testnet per the consensus rules). Finally, if the
|
||||
// useCoinbaseValue flag is false and the existing block template does not
|
||||
// already contain a valid payment address, the block template will be updated
|
||||
// with a randomly selected payment address from the list of configured
|
||||
@ -2813,7 +2813,7 @@ func handleGetBlockTemplateRequest(s *rpcServer, request *types.TemplateRequest,
|
||||
// transactions in the memory pool have been updated and it has been at
|
||||
// least five seconds since the last template was generated.
|
||||
// Otherwise, the timestamp for the existing block template is updated
|
||||
// (and possibly the difficulty on testnet per the consesus rules).
|
||||
// (and possibly the difficulty on testnet per the consensus rules).
|
||||
if err := state.updateBlockTemplate(s, useCoinbaseValue); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -4188,7 +4188,7 @@ func handleGetWorkRequest(s *rpcServer) (interface{}, error) {
|
||||
|
||||
// Serialize the block header into a buffer large enough to hold the
|
||||
// the block header and the internal blake256 padding that is added and
|
||||
// retuned as part of the data below. For reference:
|
||||
// returned as part of the data below. For reference:
|
||||
// data[116] --> nBits
|
||||
// data[136] --> Timestamp
|
||||
// data[140] --> nonce
|
||||
@ -6170,7 +6170,7 @@ func (s *rpcServer) jsonRPCRead(w http.ResponseWriter, r *http.Request, isAdmin
|
||||
defer buf.Flush()
|
||||
conn.SetReadDeadline(timeZeroVal)
|
||||
// Setup a close notifier. Since the connection is hijacked,
|
||||
// the CloseNotifer on the ResponseWriter is not available.
|
||||
// the CloseNotifier on the ResponseWriter is not available.
|
||||
closeChan := make(chan struct{}, 1)
|
||||
go func() {
|
||||
_, err := conn.Read(make([]byte, 1))
|
||||
|
||||
@ -379,7 +379,7 @@ var helpDescsEnUS = map[string]string{
|
||||
// TemplateRequest help.
|
||||
"templaterequest-mode": "This is 'template', 'proposal', or omitted",
|
||||
"templaterequest-capabilities": "List of capabilities",
|
||||
"templaterequest-longpollid": "The long poll ID of a job to monitor for expiration; required and valid only for long poll requests ",
|
||||
"templaterequest-longpollid": "The long poll ID of a job to monitor for expiration; required and valid only for long poll requests",
|
||||
"templaterequest-sigoplimit": "Number of signature operations allowed in blocks (this parameter is ignored)",
|
||||
"templaterequest-sizelimit": "Number of bytes allowed in blocks (this parameter is ignored)",
|
||||
"templaterequest-maxversion": "Highest supported block version number (this parameter is ignored)",
|
||||
@ -403,7 +403,7 @@ var helpDescsEnUS = map[string]string{
|
||||
"getblocktemplateresult-curtime": "Current time as seen by the server (recommended for block time); must fall within mintime/maxtime rules",
|
||||
"getblocktemplateresult-height": "Height of the block to be solved",
|
||||
"getblocktemplateresult-previousblockhash": "Hex-encoded big-endian hash of the previous block",
|
||||
"getblocktemplateresult-sigoplimit": "Number of sigops allowed in blocks ",
|
||||
"getblocktemplateresult-sigoplimit": "Number of sigops allowed in blocks",
|
||||
"getblocktemplateresult-sizelimit": "Number of bytes allowed in blocks",
|
||||
"getblocktemplateresult-transactions": "Array of transactions as JSON objects",
|
||||
"getblocktemplateresult-version": "The block version",
|
||||
|
||||
@ -1308,7 +1308,7 @@ out:
|
||||
rpcsLog.Debugf("Received command <%s> from %s", cmd.method, c.addr)
|
||||
|
||||
// Check auth. The client is immediately disconnected if the
|
||||
// first request of an unauthentiated websocket client is not
|
||||
// first request of an unauthenticated websocket client is not
|
||||
// the authenticate request, an authenticate request is received
|
||||
// when the client is already authenticated, or incorrect
|
||||
// authentication credentials are provided in the request.
|
||||
@ -1545,7 +1545,7 @@ out:
|
||||
rpcsLog.Debugf("Received command <%s> from %s", cmd.method, c.addr)
|
||||
|
||||
// Check auth. The client is immediately disconnected if the
|
||||
// first request of an unauthentiated websocket client is not
|
||||
// first request of an unauthenticated websocket client is not
|
||||
// the authenticate request, an authenticate request is received
|
||||
// when the client is already authenticated, or incorrect
|
||||
// authentication credentials are provided in the request.
|
||||
|
||||
@ -327,7 +327,7 @@ func (sp *serverPeer) newestBlock() (*chainhash.Hash, int64, error) {
|
||||
return &best.Hash, best.Height, nil
|
||||
}
|
||||
|
||||
// addKnownAddresses adds the given addresses to the set of known addreses to
|
||||
// addKnownAddresses adds the given addresses to the set of known addresses to
|
||||
// the peer to prevent sending duplicate addresses.
|
||||
func (sp *serverPeer) addKnownAddresses(addresses []*wire.NetAddress) {
|
||||
for _, na := range addresses {
|
||||
@ -1453,7 +1453,7 @@ func (s *server) handleAddPeerMsg(state *peerState, sp *serverPeer) bool {
|
||||
|
||||
port, err := strconv.ParseUint(activeNetParams.DefaultPort, 10, 16)
|
||||
if err != nil {
|
||||
srvrLog.Errorf("unabled to parse active network port: %v", err)
|
||||
srvrLog.Errorf("unable to parse active network port: %v", err)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -1853,7 +1853,7 @@ func (s *server) outboundPeerConnected(c *connmgr.ConnReq, conn net.Conn) {
|
||||
s.addrManager.Attempt(sp.NA())
|
||||
}
|
||||
|
||||
// peerDoneHandler handles peer disconnects by notifiying the server that it's
|
||||
// peerDoneHandler handles peer disconnects by notifying the server that it's
|
||||
// done.
|
||||
func (s *server) peerDoneHandler(sp *serverPeer) {
|
||||
sp.WaitForDisconnect()
|
||||
|
||||
@ -151,7 +151,7 @@ func installService() error {
|
||||
|
||||
// Support events to the event log using the standard "standard" Windows
|
||||
// EventCreate.exe message file. This allows easy logging of custom
|
||||
// messges instead of needing to create our own message catalog.
|
||||
// messages instead of needing to create our own message catalog.
|
||||
eventlog.Remove(svcName)
|
||||
eventsSupported := uint32(eventlog.Error | eventlog.Warning | eventlog.Info)
|
||||
return eventlog.InstallAsEventCreate(svcName, eventsSupported)
|
||||
|
||||
@ -131,7 +131,7 @@ func TestCheckErrorCondition(t *testing.T) {
|
||||
|
||||
err = vm.CheckErrorCondition(false)
|
||||
if !IsErrorCode(err, ErrScriptUnfinished) {
|
||||
t.Fatalf("got unexepected error %v on %dth iteration",
|
||||
t.Fatalf("got unexpected error %v on %dth iteration",
|
||||
err, i)
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ const (
|
||||
ErrPubKeyType
|
||||
|
||||
// ErrCleanStack is returned when the ScriptVerifyCleanStack flag
|
||||
// is set, and after evalution, the stack does not contain only a
|
||||
// is set, and after evaluation, the stack does not contain only a
|
||||
// single element.
|
||||
ErrCleanStack
|
||||
|
||||
|
||||
@ -2879,7 +2879,7 @@ func opcodeCheckSigAlt(op *opcode, data []byte, vm *Engine) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Fallthrough of somekind automatically results in false, but
|
||||
// Fallthrough of some kind automatically results in false, but
|
||||
// this should never be hit.
|
||||
vm.dstack.PushBool(false)
|
||||
return nil
|
||||
|
||||
@ -351,7 +351,7 @@ func TestRemoveOpcodeByData(t *testing.T) {
|
||||
"0x01020304"),
|
||||
},
|
||||
{
|
||||
name: "invalid opcode ",
|
||||
name: "invalid opcode",
|
||||
before: []byte{OP_UNKNOWN193},
|
||||
remove: []byte{1, 2, 3, 4},
|
||||
after: []byte{OP_UNKNOWN193},
|
||||
|
||||
@ -79,7 +79,7 @@ func TestSigCacheAddEvictEntry(t *testing.T) {
|
||||
sigCopy, _ := secp256k1.ParseSignature(sig.Serialize())
|
||||
keyCopy, _ := secp256k1.ParsePubKey(key.SerializeCompressed())
|
||||
if !sigCache.Exists(*msg, sigCopy, keyCopy) {
|
||||
t.Errorf("previously added item not found in signature" +
|
||||
t.Errorf("previously added item not found in signature " +
|
||||
"cache")
|
||||
}
|
||||
}
|
||||
@ -131,13 +131,13 @@ func TestSigCacheAddMaxEntriesZeroOrNegative(t *testing.T) {
|
||||
sig1Copy, _ := secp256k1.ParseSignature(sig1.Serialize())
|
||||
key1Copy, _ := secp256k1.ParsePubKey(key1.SerializeCompressed())
|
||||
if sigCache.Exists(*msg1, sig1Copy, key1Copy) {
|
||||
t.Errorf("previously added signature found in sigcache, but" +
|
||||
t.Errorf("previously added signature found in sigcache, but " +
|
||||
"shouldn't have been")
|
||||
}
|
||||
|
||||
// There shouldn't be any entries in the sigCache.
|
||||
if len(sigCache.validSigs) != 0 {
|
||||
t.Errorf("%v items found in sigcache, no items should have"+
|
||||
t.Errorf("%v items found in sigcache, no items should have "+
|
||||
"been added", len(sigCache.validSigs))
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ sigLoop:
|
||||
}
|
||||
|
||||
for _, addr := range addresses {
|
||||
// All multisig addresses should be pubkey addreses
|
||||
// All multisig addresses should be pubkey addresses
|
||||
// it is an error to call this internal function with
|
||||
// bad input.
|
||||
pkaddr := addr.(*dcrutil.AddressSecpPubKey)
|
||||
@ -569,7 +569,7 @@ func (kc KeyClosure) GetKey(address dcrutil.Address) (chainec.PrivateKey, bool,
|
||||
}
|
||||
|
||||
// ScriptDB is an interface type provided to SignTxOutput, it encapsulates any
|
||||
// user state required to get the scripts for an pay-to-script-hash address.
|
||||
// user state required to get the scripts for a pay-to-script-hash address.
|
||||
type ScriptDB interface {
|
||||
GetScript(dcrutil.Address) ([]byte, error)
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ func IsMultisigSigScript(script []byte) bool {
|
||||
// will return nil otherwise.
|
||||
func extractCompressedPubKey(script []byte) []byte {
|
||||
// A pay-to-compressed-pubkey script is of the form:
|
||||
// OP_DATA_33 <33-byte compresed pubkey> OP_CHECKSIG
|
||||
// OP_DATA_33 <33-byte compressed pubkey> OP_CHECKSIG
|
||||
|
||||
// All compressed secp256k1 public keys must start with 0x02 or 0x03.
|
||||
if len(script) == 35 &&
|
||||
@ -252,8 +252,8 @@ func extractUncompressedPubKey(script []byte) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
// extractPubKey extracts either compressed or uncompressed public key from the
|
||||
// passed script if it is a either a standard pay-to-compressed-secp256k1-pubkey
|
||||
// extractPubKey extracts either a compressed or uncompressed public key from the
|
||||
// passed script if it is either a standard pay-to-compressed-secp256k1-pubkey
|
||||
// or pay-to-uncompressed-secp256k1-pubkey script, respectively. It will return
|
||||
// nil otherwise.
|
||||
func extractPubKey(script []byte) []byte {
|
||||
|
||||
@ -998,7 +998,7 @@ func TestGenerateProvablyPruneableOut(t *testing.T) {
|
||||
for i, test := range tests {
|
||||
script, err := GenerateProvablyPruneableOut(test.data)
|
||||
if e := tstCheckScriptError(err, test.err); e != nil {
|
||||
t.Errorf("GenerateProvablyPruneableOut: #%d (%s) %v: ",
|
||||
t.Errorf("GenerateProvablyPruneableOut: #%d (%s) %v",
|
||||
i, test.name, e)
|
||||
continue
|
||||
|
||||
|
||||
2
upnp.go
2
upnp.go
@ -375,7 +375,7 @@ func (n *upnpNAT) AddPortMapping(protocol string, externalPort, internalPort int
|
||||
}
|
||||
|
||||
// TODO: check response to see if the port was forwarded
|
||||
// If the port was not wildcard we don't get an reply with the port in
|
||||
// If the port was not wildcard we don't get a reply with the port in
|
||||
// it. Not sure about wildcard yet. miniupnpc just checks for error
|
||||
// codes here.
|
||||
mappedExternalPort = externalPort
|
||||
|
||||
@ -342,7 +342,7 @@ func BenchmarkDeserializeTxSmall(b *testing.B) {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // // Previous output hash
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0xff, 0xff, 0xff, 0xff, // Previous output index
|
||||
0x07, // Varint for length of signature script
|
||||
0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04, // Signature script
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
|
||||
@ -647,7 +647,7 @@ func WriteVarString(w io.Writer, pver uint32, str string) error {
|
||||
// as a varInt containing the length of the array followed by the bytes
|
||||
// themselves. An error is returned if the length is greater than the
|
||||
// passed maxAllowed parameter which helps protect against memory exhaustion
|
||||
// attacks and forced panics thorugh malformed messages. The fieldName
|
||||
// attacks and forced panics through malformed messages. The fieldName
|
||||
// parameter is only used for the error message so it provides more context in
|
||||
// the error.
|
||||
func ReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32,
|
||||
|
||||
@ -10,7 +10,7 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// fixedWriter implements the io.Writer interface and intentially allows
|
||||
// fixedWriter implements the io.Writer interface and intentionally allows
|
||||
// testing of error paths by forcing short writes.
|
||||
type fixedWriter struct {
|
||||
b []byte
|
||||
@ -45,7 +45,7 @@ func newFixedWriter(max int) io.Writer {
|
||||
return &fw
|
||||
}
|
||||
|
||||
// fixedReader implements the io.Reader interface and intentially allows
|
||||
// fixedReader implements the io.Reader interface and intentionally allows
|
||||
// testing of error paths by forcing short reads.
|
||||
type fixedReader struct {
|
||||
buf []byte
|
||||
|
||||
@ -85,7 +85,7 @@ func TestAddr(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestAddrWire tests the MsgAddr wire encode and decode for various numbers
|
||||
// of addreses and protocol versions.
|
||||
// of addresses and protocol versions.
|
||||
func TestAddrWire(t *testing.T) {
|
||||
// A couple of NetAddresses to use for testing.
|
||||
na := &NetAddress{
|
||||
|
||||
@ -732,7 +732,7 @@ var testBlockBytes = []byte{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Previous output hash [186]
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index [218]
|
||||
0xff, 0xff, 0xff, 0xff, // Previous output index [218]
|
||||
0x00, // Previous output tree [222]
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence [223]
|
||||
0x01, // Varint for number of transaction outputs [227]
|
||||
@ -767,7 +767,7 @@ var testBlockBytes = []byte{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Previous output hash
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0xff, 0xff, 0xff, 0xff, // Previous output index
|
||||
0x01, // Previous output tree
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0x01, // Varint for number of transaction outputs
|
||||
|
||||
@ -169,7 +169,7 @@ func TestCFTypesWireErrors(t *testing.T) {
|
||||
oldPver := NodeCFVersion - 1
|
||||
wireErr := &MessageError{}
|
||||
|
||||
// Valid MsgCFTypes with it's encoded format.
|
||||
// Valid MsgCFTypes with its encoded format.
|
||||
baseCf := NewMsgCFTypes([]FilterType{GCSFilterExtended})
|
||||
baseCfEncoded := []byte{
|
||||
0x01, // Varint for number of filter types
|
||||
|
||||
@ -199,7 +199,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
bits := uint32(0x1d00ffff)
|
||||
nonce := uint32(0x9962e301)
|
||||
bh := NewBlockHeader(
|
||||
int32(pver), // Verision
|
||||
int32(pver), // Version
|
||||
&hash, // PrevHash
|
||||
&merkleHash, // MerkleRootHash
|
||||
&merkleHash, // StakeRoot
|
||||
@ -271,7 +271,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
// Intentionally invalid block header that has a transaction count used
|
||||
// to force errors.
|
||||
bhTrans := NewBlockHeader(
|
||||
int32(0), // Verision
|
||||
int32(0), // Version
|
||||
&hash, // PrevHash
|
||||
&merkleHash, // MerkleRootHash
|
||||
&merkleHash, // StakeRoot
|
||||
|
||||
@ -211,7 +211,7 @@ var scriptPool scriptFreeList = make(chan []byte, freeListMaxItems)
|
||||
// script. It is encoded as a varInt containing the length of the array
|
||||
// followed by the bytes themselves. An error is returned if the length is
|
||||
// greater than the passed maxAllowed parameter which helps protect against
|
||||
// memory exhaustion attacks and forced panics thorugh malformed messages. The
|
||||
// memory exhaustion attacks and forced panics through malformed messages. The
|
||||
// fieldName parameter is only used for the error message so it provides more
|
||||
// context in the error.
|
||||
func readScript(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error) {
|
||||
|
||||
@ -790,7 +790,7 @@ func TestTxOverflowErrors(t *testing.T) {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Previous output hash
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0xff, 0xff, 0xff, 0xff, // Previous output index
|
||||
0x00, // Previous output tree
|
||||
0x00, // Varint for length of signature script
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
|
||||
@ -48,7 +48,7 @@ type MsgVersion struct {
|
||||
// connections.
|
||||
Nonce uint64
|
||||
|
||||
// The user agent that generated messsage. This is a encoded as a varString
|
||||
// The user agent that generated message. This is encoded as a varString
|
||||
// on the wire. This has a max length of MaxUserAgentLen.
|
||||
UserAgent string
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ func TestVersionWireErrors(t *testing.T) {
|
||||
|
||||
// Make a new buffer big enough to hold the base version plus the new
|
||||
// bytes for the bigger varint to hold the new size of the user agent
|
||||
// and the new user agent string. Then stich it all together.
|
||||
// and the new user agent string. Then stitch it all together.
|
||||
newLen := len(baseVersionEncoded) - len(baseVersion.UserAgent)
|
||||
newLen = newLen + len(newUAVarIntBuf.Bytes()) - 1 + len(newUA)
|
||||
exceedUAVerEncoded := make([]byte, newLen)
|
||||
|
||||
@ -48,7 +48,7 @@ const (
|
||||
// SFNodeNetwork is a flag used to indicate a peer is a full node.
|
||||
SFNodeNetwork ServiceFlag = 1 << iota
|
||||
|
||||
// SFNodeBloom is a flag used to indiciate a peer supports bloom
|
||||
// SFNodeBloom is a flag used to indicate a peer supports bloom
|
||||
// filtering.
|
||||
SFNodeBloom
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user