Moving closer to interop
This commit is contained in:
parent
8124547348
commit
63883bf27d
@ -28,7 +28,7 @@ func Disassemble(script []byte) (asm []string) {
|
|||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
data = []byte{0}
|
data = []byte{0}
|
||||||
}
|
}
|
||||||
asm = append(asm, fmt.Sprintf("0x%x", data))
|
asm = append(asm, fmt.Sprintf("%#x", data))
|
||||||
|
|
||||||
pc.Add(pc, big.NewInt(a-1))
|
pc.Add(pc, big.NewInt(a-1))
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,8 @@ func (bc *BlockChain) NewBlock(coinbase []byte) *Block {
|
|||||||
nil,
|
nil,
|
||||||
"")
|
"")
|
||||||
|
|
||||||
|
block.MinGasPrice = big.NewInt(10000000000000)
|
||||||
|
|
||||||
if bc.CurrentBlock != nil {
|
if bc.CurrentBlock != nil {
|
||||||
var mul *big.Int
|
var mul *big.Int
|
||||||
if block.Time < lastBlockTime+42 {
|
if block.Time < lastBlockTime+42 {
|
||||||
|
@ -131,14 +131,21 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
return NonceError(tx.Nonce, sender.Nonce)
|
return NonceError(tx.Nonce, sender.Nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment the nonce for the next transaction
|
|
||||||
sender.Nonce += 1
|
|
||||||
|
|
||||||
// Pre-pay gas / Buy gas of the coinbase account
|
// Pre-pay gas / Buy gas of the coinbase account
|
||||||
if err = self.BuyGas(); err != nil {
|
if err = self.BuyGas(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX Transactions after this point are considered valid.
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
self.state.UpdateStateObject(sender)
|
||||||
|
self.state.UpdateStateObject(receiver)
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Increment the nonce for the next transaction
|
||||||
|
sender.Nonce += 1
|
||||||
|
|
||||||
// Get the receiver (TODO fix this, if coinbase is the receiver we need to save/retrieve)
|
// Get the receiver (TODO fix this, if coinbase is the receiver we need to save/retrieve)
|
||||||
receiver = self.Receiver()
|
receiver = self.Receiver()
|
||||||
|
|
||||||
@ -187,9 +194,6 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
remaining := new(big.Int).Mul(self.gas, tx.GasPrice)
|
remaining := new(big.Int).Mul(self.gas, tx.GasPrice)
|
||||||
sender.AddAmount(remaining)
|
sender.AddAmount(remaining)
|
||||||
|
|
||||||
self.state.UpdateStateObject(sender)
|
|
||||||
self.state.UpdateStateObject(receiver)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ var opCodeToString = map[OpCode]string{
|
|||||||
func (o OpCode) String() string {
|
func (o OpCode) String() string {
|
||||||
str := opCodeToString[o]
|
str := opCodeToString[o]
|
||||||
if len(str) == 0 {
|
if len(str) == 0 {
|
||||||
return fmt.Sprintf("Missing opcode 0x%x", int(o))
|
return fmt.Sprintf("Missing opcode %#x", int(o))
|
||||||
}
|
}
|
||||||
|
|
||||||
return str
|
return str
|
||||||
|
@ -136,11 +136,18 @@ func (self *Miner) mineNewBlock() {
|
|||||||
|
|
||||||
// Sort the transactions by nonce in case of odd network propagation
|
// Sort the transactions by nonce in case of odd network propagation
|
||||||
sort.Sort(ethchain.TxByNonce{self.txs})
|
sort.Sort(ethchain.TxByNonce{self.txs})
|
||||||
|
|
||||||
// Accumulate all valid transaction and apply them to the new state
|
// Accumulate all valid transaction and apply them to the new state
|
||||||
receipts, txs := stateManager.ApplyTransactions(self.block.Coinbase, self.block.State(), self.block, self.txs)
|
// Error may be ignored. It's not important during mining
|
||||||
self.txs = txs
|
receipts, txs, unhandledTxs, err := stateManager.ProcessTransactions(self.block.Coinbase, self.block.State(), self.block, self.block, self.txs)
|
||||||
|
if err != nil {
|
||||||
|
ethutil.Config.Log.Debugln("[MINER]", err)
|
||||||
|
}
|
||||||
|
self.txs = append(txs, unhandledTxs...)
|
||||||
|
|
||||||
// Set the transactions to the block so the new SHA3 can be calculated
|
// Set the transactions to the block so the new SHA3 can be calculated
|
||||||
self.block.SetReceipts(receipts, txs)
|
self.block.SetReceipts(receipts, txs)
|
||||||
|
|
||||||
// Accumulate the rewards included for this block
|
// Accumulate the rewards included for this block
|
||||||
stateManager.AccumelateRewards(self.block.State(), self.block)
|
stateManager.AccumelateRewards(self.block.State(), self.block)
|
||||||
|
|
||||||
|
4
peer.go
4
peer.go
@ -19,7 +19,7 @@ const (
|
|||||||
// Current protocol version
|
// Current protocol version
|
||||||
ProtocolVersion = 20
|
ProtocolVersion = 20
|
||||||
// Interval for ping/pong message
|
// Interval for ping/pong message
|
||||||
pingPongTimer = 30 * time.Second
|
pingPongTimer = 1 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiscReason byte
|
type DiscReason byte
|
||||||
@ -270,7 +270,7 @@ out:
|
|||||||
// Ping timer
|
// Ping timer
|
||||||
case <-pingTimer.C:
|
case <-pingTimer.C:
|
||||||
timeSince := time.Since(time.Unix(p.lastPong, 0))
|
timeSince := time.Since(time.Unix(p.lastPong, 0))
|
||||||
if p.pingStartTime.IsZero() == false && timeSince > (pingPongTimer+10*time.Second) {
|
if !p.pingStartTime.IsZero() && p.lastPong != 0 && timeSince > (pingPongTimer+10*time.Second) {
|
||||||
ethutil.Config.Log.Infof("[PEER] Peer did not respond to latest pong fast enough, it took %s, disconnecting.\n", timeSince)
|
ethutil.Config.Log.Infof("[PEER] Peer did not respond to latest pong fast enough, it took %s, disconnecting.\n", timeSince)
|
||||||
p.Stop()
|
p.Stop()
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user