Esempio n. 1
0
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package dagger

import (
	"hash"
	"math/big"
	"math/rand"
	"time"

	"github.com/shiftcurrency/shift/common"
	"github.com/shiftcurrency/shift/crypto/sha3"
	"github.com/shiftcurrency/shift/logger"
)

var powlogger = logger.NewLogger("POW")

type Dagger struct {
	hash *big.Int
	xn   *big.Int
}

var Found bool

func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))

	for i := 0; i < 1000; i++ {
		rnd := r.Int63()

		res := dag.Eval(big.NewInt(rnd))
Esempio n. 2
0
	"sync/atomic"
	"time"

	"github.com/hashicorp/golang-lru"
	"github.com/shiftcurrency/shift/common"
	"github.com/shiftcurrency/shift/core/state"
	"github.com/shiftcurrency/shift/core/types"
	"github.com/shiftcurrency/shift/event"
	"github.com/shiftcurrency/shift/logger"
	"github.com/shiftcurrency/shift/logger/glog"
	"github.com/shiftcurrency/shift/metrics"
	"github.com/shiftcurrency/shift/pow"
)

var (
	chainlogger = logger.NewLogger("CHAIN")
	jsonlogger  = logger.NewJsonLogger()

	blockInsertTimer = metrics.NewTimer("chain/inserts")

	ErrNoGenesis = errors.New("Genesis not found in chain")
)

const (
	blockCacheLimit     = 256
	maxFutureBlocks     = 256
	maxTimeFutureBlocks = 30
	checkpointLimit     = 200
)

type ChainManager struct {
Esempio n. 3
0
// Contains the external API to the whisper sub-protocol.

package xeth

import (
	"fmt"
	"time"

	"github.com/shiftcurrency/shift/common"
	"github.com/shiftcurrency/shift/crypto"
	"github.com/shiftcurrency/shift/logger"
	"github.com/shiftcurrency/shift/whisper"
)

var qlogger = logger.NewLogger("XSHH")

// Whisper represents the API wrapper around the internal whisper implementation.
type Whisper struct {
	*whisper.Whisper
}

// NewWhisper wraps an internal whisper client into an external API version.
func NewWhisper(w *whisper.Whisper) *Whisper {
	return &Whisper{w}
}

// NewIdentity generates a new cryptographic identity for the client, and injects
// it into the known identities for message decryption.
func (self *Whisper) NewIdentity() string {
	identity := self.Whisper.NewIdentity()