good morning!!!!

Skip to content
Snippets Groups Projects
Select Git revision
  • 08d72a9245ce6f1e11f84a6b59d66cb083bea9f9
  • master default protected
  • v0.2.16-candidate
  • shivam/rpcAddBorTx
  • default-cli-config
  • shivam/minerRecommitFix
  • vcastellm/pos-296-bump-go-version-in-bor-and-heimdall
  • shivam/ethstats-backend-fix
  • v0.2.16-beta1-candidate
  • v0.2.15-beta3-candidate
  • shivam/newCli-IPC
  • v0.3.0-dev
  • checkpoint-whitelist-master
  • shivam/codecov
  • jdkanani/fix-typo-log
  • shivam/hardcoded-spans-v0.2.14
  • shivam/hardcoded-spans
  • shivam/fast-state-sync
  • shivam/fast-state-sync-master
  • gethv1.10.15-merge
  • fix-txpool-2
  • v0.2.14-tmp-span-hotfix
  • v0.2.15-beta2
  • v0.2.15-beta1
  • v0.3.0-beta3
  • v0.3.0-beta2
  • v0.3.0-beta1
  • v0.2.14
  • v0.2.13
  • v0.2.13-beta2
  • v0.2.13-beta1
  • v0.2.12
  • v0.2.12-beta3
  • v0.2.12-beta1
  • v0.2.12-beta2
  • v0.2.11
  • v0.2.10
  • v0.2.10-beta2
  • v0.2.9
  • v0.2.9-beta1
  • v0.2.8
41 results

personal.go

Blame
  • Forked from github / maticnetwork / bor
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    encoding.go 1.17 KiB
    package main
    
    import (
      "bytes"
      "encoding/hex"
      "strings"
      _"fmt"
    )
    
    func CompactEncode(hexSlice []int) string {
      terminator := 0
      if hexSlice[len(hexSlice)-1] == 16 {
        terminator = 1
      }
    
      if terminator == 1 {
        hexSlice = hexSlice[:len(hexSlice)-1]
      }
    
      oddlen := len(hexSlice) % 2
      flags := 2 * terminator + oddlen
      if oddlen != 0 {
        hexSlice = append([]int{flags}, hexSlice...)
      } else {
        hexSlice = append([]int{flags, 0}, hexSlice...)
      }
    
      var buff bytes.Buffer
      for i := 0; i < len(hexSlice); i+=2 {
        buff.WriteByte(byte(16 * hexSlice[i] + hexSlice[i+1]))
      }
    
      return buff.String()
    }
    
    func CompactDecode(str string) []int {
      base := CompactHexDecode(str)
      base = base[:len(base)-1]
      if base[0] >= 2 {// && base[len(base)-1] != 16 {
        base = append(base, 16)
      }
      if base[0] % 2 == 1 {
        base = base[1:]
      } else {
        base = base[2:]
      }
    
      return base
    }
    
    func CompactHexDecode(str string) []int {
      base := "0123456789abcdef"
      hexSlice := make([]int, 0)
    
      enc := hex.EncodeToString([]byte(str))
      for _, v := range enc {
        hexSlice = append(hexSlice, strings.IndexByte(base, byte(v)))
      }
      hexSlice = append(hexSlice, 16)
    
      return hexSlice
    }