mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
pot, swarm/pss: Remove redundant conversions
This commit is contained in:
parent
d0c3029cdb
commit
63a44a80d6
3 changed files with 7 additions and 7 deletions
|
|
@ -105,13 +105,13 @@ func posProximity(one, other Address, pos int) (ret int, eq bool) {
|
|||
if one[i] == other[i] {
|
||||
continue
|
||||
}
|
||||
oxo := one[i] ^ other[i]
|
||||
oxo := uint8(one[i] ^ other[i])
|
||||
start := 0
|
||||
if i == pos/8 {
|
||||
start = pos % 8
|
||||
}
|
||||
for j := start; j < 8; j++ {
|
||||
if (uint8(oxo)>>uint8(7-j))&0x01 != 0 {
|
||||
if (oxo>>uint8(7-j))&0x01 != 0 {
|
||||
return i*8 + j, false
|
||||
}
|
||||
}
|
||||
|
|
@ -173,13 +173,13 @@ func RandomAddress() Address {
|
|||
func NewAddressFromString(s string) []byte {
|
||||
ha := [32]byte{}
|
||||
|
||||
t := s + string(zerosBin)[:len(zerosBin)-len(s)]
|
||||
t := s + zerosBin[:len(zerosBin)-len(s)]
|
||||
for i := 0; i < 4; i++ {
|
||||
n, err := strconv.ParseUint(t[i*64:(i+1)*64], 2, 64)
|
||||
if err != nil {
|
||||
panic("wrong format: " + err.Error())
|
||||
}
|
||||
binary.BigEndian.PutUint64(ha[i*8:(i+1)*8], uint64(n))
|
||||
binary.BigEndian.PutUint64(ha[i*8:(i+1)*8], n)
|
||||
}
|
||||
return ha[:]
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ func proximityOrder(one, other []byte, pos int) (int, bool) {
|
|||
start = pos % 8
|
||||
}
|
||||
for j := start; j < 8; j++ {
|
||||
if (uint8(oxo)>>uint8(7-j))&0x01 != 0 {
|
||||
if (oxo>>uint8(7-j))&0x01 != 0 {
|
||||
return i*8 + j, false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func (pssapi *API) BaseAddr() (PssAddress, error) {
|
|||
func (pssapi *API) GetPublicKey() (keybytes hexutil.Bytes) {
|
||||
key := pssapi.Pss.PublicKey()
|
||||
keybytes = crypto.FromECDSAPub(key)
|
||||
return hexutil.Bytes(keybytes)
|
||||
return keybytes
|
||||
}
|
||||
|
||||
// Set Public key to associate with a particular Pss peer
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ func (self *HandshakeAPI) Handshake(pubkeyid string, topic Topic, sync bool, flu
|
|||
keycount = self.ctrl.symKeyCapacity
|
||||
} else {
|
||||
validkeys := self.ctrl.validKeys(pubkeyid, &topic, false)
|
||||
keycount = uint8(self.ctrl.symKeyCapacity - uint8(len(validkeys)))
|
||||
keycount = self.ctrl.symKeyCapacity - uint8(len(validkeys))
|
||||
}
|
||||
if keycount == 0 {
|
||||
return keys, errors.New("Incoming symmetric key store is already full")
|
||||
|
|
|
|||
Loading…
Reference in a new issue