mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
Preliminary Swarm contract code added to genesis
This commit is contained in:
parent
abec44cb9b
commit
ae39b1c599
2 changed files with 61 additions and 3 deletions
49
core/contracts.go
Normal file
49
core/contracts.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package core
|
||||
|
||||
const ( // built-in contracts address and code
|
||||
ContractAddrURLhint = "0000000000000000000000000000000000000008"
|
||||
//ContractCodeURLhint = "0x60b180600c6000396000f30060003560e060020a90048063d66d6c1014601557005b60216004356024356027565b60006000f35b6000600083815260200190815260200160002054600160a060020a0316600014806075575033600160a060020a03166000600084815260200190815260200160002054600160a060020a0316145b607c5760ad565b3360006000848152602001908152602001600020819055508060016000848152602001908152602001600020819055505b505056"
|
||||
ContractCodeURLhint = "0x60003560e060020a90048063d66d6c1014601557005b60216004356024356027565b60006000f35b6000600083815260200190815260200160002054600160a060020a0316600014806075575033600160a060020a03166000600084815260200190815260200160002054600160a060020a0316145b607c5760ad565b3360006000848152602001908152602001600020819055508060016000848152602001908152602001600020819055505b505056"
|
||||
/*
|
||||
contract URLhint {
|
||||
function register(uint256 _hash, uint256 _url) {
|
||||
if (owner[_hash] == 0 || owner[_hash] == msg.sender) {
|
||||
owner[_hash] = msg.sender;
|
||||
url[_hash] = _url;
|
||||
}
|
||||
}
|
||||
mapping (uint256 => address) owner;
|
||||
mapping (uint256 => uint256) url;
|
||||
}
|
||||
*/
|
||||
|
||||
ContractAddrHashReg = "0000000000000000000000000000000000000009"
|
||||
ContractCodeHashReg = "0x60003560e060020a9004806331e12c2014601f578063d66d6c1014602b57005b6025603d565b60006000f35b6037600435602435605d565b60006000f35b600054600160a060020a0316600014605357605b565b336000819055505b565b600054600160a060020a031633600160a060020a031614607b576094565b8060016000848152602001908152602001600020819055505b505056"
|
||||
//ContractCodeHashReg = "0x609880600c6000396000f30060003560e060020a9004806331e12c2014601f578063d66d6c1014602b57005b6025603d565b60006000f35b6037600435602435605d565b60006000f35b600054600160a060020a0316600014605357605b565b336000819055505b565b600054600160a060020a031633600160a060020a031614607b576094565b8060016000848152602001908152602001600020819055505b505056"
|
||||
/*
|
||||
contract HashReg {
|
||||
function setowner() {
|
||||
if (owner == 0) {
|
||||
owner = msg.sender;
|
||||
}
|
||||
}
|
||||
function register(uint256 _key, uint256 _content) {
|
||||
if (msg.sender == owner) {
|
||||
content[_key] = _content;
|
||||
}
|
||||
}
|
||||
address owner;
|
||||
mapping (uint256 => uint256) content;
|
||||
}
|
||||
*/
|
||||
|
||||
ContractAddrSwarm = "000000000000000000000000000000000000000a"
|
||||
ContractCodeSwarm = "0x60003560e060020a900480633ccfd60b1461002c5780636d5433e61461003a5780638843ffba1461005257005b6100346100db565b60006000f35b610048600435602435610063565b8060005260206000f35b61005d600435610084565b60006000f35b6000818310156100725761007a565b82905061007e565b8190505b92915050565b60006000600033600160a060020a03168152602001908152602001600020905042824201116100b2576100cb565b6100c28160010154834201610063565b81600101819055505b3481818154019150819055505050565b60006000600033600160a060020a0316815260200190815260200160002090508060010154421161010b57610136565b33600160a060020a0316600082546000600060006000848787f161012b57005b505050600081819055505b5056"
|
||||
// see bzz/bzzcontract/swarm.sol
|
||||
|
||||
BuiltInContracts = `
|
||||
"` + ContractAddrURLhint + `": {"balance": "0", "code": "` + ContractCodeURLhint + `" },
|
||||
"` + ContractAddrHashReg + `": {"balance": "0", "code": "` + ContractCodeHashReg + `" },
|
||||
"` + ContractAddrSwarm + `": {"balance": "0", "code": "` + ContractCodeSwarm + `" },
|
||||
`
|
||||
)
|
||||
|
|
@ -3,12 +3,12 @@ package core
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
/*
|
||||
|
|
@ -18,11 +18,13 @@ import (
|
|||
var ZeroHash256 = make([]byte, 32)
|
||||
var ZeroHash160 = make([]byte, 20)
|
||||
var ZeroHash512 = make([]byte, 64)
|
||||
var GenesisDiff = big.NewInt(131072)
|
||||
var GenesisGasLimit = big.NewInt(3141592)
|
||||
|
||||
func GenesisBlock(db common.Database) *types.Block {
|
||||
genesis := types.NewBlock(common.Hash{}, common.Address{}, common.Hash{}, params.GenesisDifficulty, 42, nil)
|
||||
genesis := types.NewBlock(common.Hash{}, common.Address{}, common.Hash{}, GenesisDiff, 42, "")
|
||||
genesis.Header().Number = common.Big0
|
||||
genesis.Header().GasLimit = params.GenesisGasLimit
|
||||
genesis.Header().GasLimit = GenesisGasLimit
|
||||
genesis.Header().GasUsed = common.Big0
|
||||
genesis.Header().Time = 0
|
||||
|
||||
|
|
@ -56,7 +58,14 @@ func GenesisBlock(db common.Database) *types.Block {
|
|||
return genesis
|
||||
}
|
||||
|
||||
const (
|
||||
TestAccount = "e273f01c99144c438695e10f24926dc1f9fbf62d"
|
||||
TestBalance = "1000000000000"
|
||||
)
|
||||
|
||||
var genesisData = []byte(`{
|
||||
"` + TestAccount + `": {"balance": "` + TestBalance + `"},
|
||||
` + BuiltInContracts + `
|
||||
"0000000000000000000000000000000000000001": {"balance": "1"},
|
||||
"0000000000000000000000000000000000000002": {"balance": "1"},
|
||||
"0000000000000000000000000000000000000003": {"balance": "1"},
|
||||
|
|
|
|||
Loading…
Reference in a new issue