Browse Source

address PR comments

pull/522/head
zramsay 8 years ago
parent
commit
bf5181d9ca
3 changed files with 19 additions and 5 deletions
  1. +6
    -4
      p2p/upnp/probe.go
  2. +12
    -0
      state/execution.go
  3. +1
    -1
      types/block.go

+ 6
- 4
p2p/upnp/probe.go View File

@ -5,6 +5,8 @@ import (
"net"
"time"
"github.com/pkg/errors"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
@ -17,26 +19,26 @@ type UPNPCapabilities struct {
func makeUPNPListener(intPort int, extPort int, logger log.Logger) (NAT, net.Listener, net.IP, error) {
nat, err := Discover()
if err != nil {
return nil, nil, nil, fmt.Errorf("NAT upnp could not be discovered: %v", err)
return nil, nil, nil, errors.Errorf("NAT upnp could not be discovered: %v", err)
}
logger.Info(cmn.Fmt("ourIP: %v", nat.(*upnpNAT).ourIP))
ext, err := nat.GetExternalAddress()
if err != nil {
return nat, nil, nil, fmt.Errorf("External address error: %v", err)
return nat, nil, nil, errors.Errorf("External address error: %v", err)
}
logger.Info(cmn.Fmt("External address: %v", ext))
port, err := nat.AddPortMapping("tcp", extPort, intPort, "Tendermint UPnP Probe", 0)
if err != nil {
return nat, nil, ext, fmt.Errorf("Port mapping error: %v", err)
return nat, nil, ext, errors.Errorf("Port mapping error: %v", err)
}
logger.Info(cmn.Fmt("Port mapping mapped: %v", port))
// also run the listener, open for all remote addresses.
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", intPort))
if err != nil {
return nat, nil, ext, fmt.Errorf("Error establishing listener: %v", err)
return nat, nil, ext, errors.Errorf("Error establishing listener: %v", err)
}
return nat, listener, ext, nil
}


+ 12
- 0
state/execution.go View File

@ -155,6 +155,18 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci.
return nil
}
// return a bit array of validators that signed the last commit
// NOTE: assumes commits have already been authenticated
/*func commitBitArrayFromBlock(block *types.Block) *cmn.BitArray {
signed := cmn.NewBitArray(len(block.LastCommit.Precommits))
for i, precommit := range block.LastCommit.Precommits {
if precommit != nil {
signed.SetIndex(i, true) // val_.LastCommitHeight = block.Height - 1
}
}
return signed
}*/
//-----------------------------------------------------
// Validate block


+ 1
- 1
types/block.go View File

@ -282,7 +282,7 @@ func (commit *Commit) GetByIndex(index int) *Vote {
}
func (commit *Commit) IsCommit() bool {
return len(commit.Precommits) == 0
return len(commit.Precommits) != 0
}
func (commit *Commit) ValidateBasic() error {


Loading…
Cancel
Save