[lbry] enable segwit

This commit is contained in:
Brannon King 2021-08-03 22:10:55 -07:00 committed by Roy Lee
parent 2fec3e3fee
commit a8205851ab
4 changed files with 19 additions and 6 deletions

View file

@ -230,8 +230,8 @@ func ValidateWitnessCommitment(blk *btcutil.Block) error {
coinbaseWitness := coinbaseTx.MsgTx().TxIn[0].Witness
if len(coinbaseWitness) != 1 {
str := fmt.Sprintf("the coinbase transaction has %d items in "+
"its witness stack when only one is allowed",
len(coinbaseWitness))
"its witness stack when only one is allowed. Height: %d",
len(coinbaseWitness), blk.Height())
return ruleError(ErrInvalidWitnessCommitment, str)
}
witnessNonce := coinbaseWitness[0]

View file

@ -20,11 +20,11 @@ const (
// weight of a "base" byte is 4, while the weight of a witness byte is
// 1. As a result, for a block to be valid, the BlockWeight MUST be
// less than, or equal to MaxBlockWeight.
MaxBlockWeight = 4000000
MaxBlockWeight = 8000000
// MaxBlockBaseSize is the maximum number of bytes within a block
// which can be allocated to non-witness data.
MaxBlockBaseSize = 2000000
MaxBlockBaseSize = 8000000
// MaxBlockSigOpsCost is the maximum number of signature operations
// allowed for a block. It is calculated via a weighted algorithm which

View file

@ -1293,9 +1293,16 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
break
}
}
e := wire.BaseEncoding
// we think that the iv.Type set above is sufficient. If not:
// if peer.IsWitnessEnabled() {
// e = wire.WitnessEncoding
//}
state.requestQueue = requestQueue
if len(gdmsg.InvList) > 0 {
peer.QueueMessage(gdmsg, nil)
peer.QueueMessageWithEncoding(gdmsg, nil, e)
}
}

View file

@ -2226,9 +2226,15 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
cfg.TrickleInterval = DefaultTrickleInterval
}
encoding := wire.BaseEncoding
// we think this gets overwritten downstream. If not:
// if cfg.Services&wire.SFNodeWitness > 0 {
// encoding = wire.WitnessEncoding
//}
p := Peer{
inbound: inbound,
wireEncoding: wire.BaseEncoding,
wireEncoding: encoding,
knownInventory: lru.NewCache(maxKnownInventory),
stallControl: make(chan stallControlMsg, 1), // nonblocking sync
outputQueue: make(chan outMsg, outputBufferSize),