Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filecoin Integration into Blockbook #7

Open
wants to merge 32 commits into
base: trezor.rebase
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
437c89d
Begin filecoin implementation
cpacia May 18, 2020
bb7f2ee
Add filecoin.json
cpacia May 18, 2020
d28c0d9
Second pass rpc
cpacia May 25, 2020
9b85183
Update filecoinrpc
cpacia Jun 2, 2020
7112c03
Filecoin chain sync wired up
cpacia Jun 11, 2020
c704462
Update GetBlockHash method
cpacia Jun 15, 2020
53bd19f
Use hashes of tipset key
cpacia Jun 16, 2020
7fb37a4
Fix bug getting block header
cpacia Jun 18, 2020
dfcbf9c
Check if next block exists in GetBlockHeader
cpacia Jun 18, 2020
5223ccd
Use bchain not found error
cpacia Jun 19, 2020
450aa7e
Switch to bitcoin chain type
cpacia Jun 20, 2020
087d194
Fix GetBlockInfo
cpacia Jun 20, 2020
92d4aee
Fix saving block hashes at tip
cpacia Jun 23, 2020
5d4fe13
Update mempool functionality
cpacia Jun 25, 2020
d846e99
Change up GetAddrDescFromAddress
hoffmabc Jun 25, 2020
a7a0977
Add EthereumTypeGetBalance
hoffmabc Jun 25, 2020
e277944
Make server ip a config param
cpacia Jun 26, 2020
f808409
Make block hash 39 bytes
cpacia Jun 26, 2020
cb8c51e
Fix for updated filecoin version
hoffmabc Jun 27, 2020
02383a1
Update lotus version
hoffmabc Jun 27, 2020
43247e6
Retry chain and mpool subscriptions on closed channel
cpacia Jun 30, 2020
7e3aed3
Switch to 38 bytes len txid
cpacia Jul 14, 2020
9154dd8
Save tx height in badger db
cpacia Jul 16, 2020
05d067e
Correctly save input txid
cpacia Jul 16, 2020
f3acff0
Save tx hex in transaction
cpacia Jul 16, 2020
c2f2808
Save blocktime in badger db
cpacia Jul 16, 2020
a00e509
Fix blocktime
cpacia Jul 16, 2020
86a12b8
Set CoinSpecifcData in txs
cpacia Jul 20, 2020
ddc32db
Fix filecoin confirmations
cpacia Jul 20, 2020
8517d9a
Update filecoin dep
cpacia Jul 27, 2020
41022f7
Fix filecoin mismatched txid
cpacia Jul 29, 2020
dc2f39d
Fix for double transactions
hoffmabc Aug 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update mempool functionality
cpacia authored and hoffmabc committed Aug 4, 2020
commit 5d4fe13c45d79830a76d49e5a2aa62cccb3361b0
28 changes: 24 additions & 4 deletions bchain/coins/filecoin/filecoinrpc.go
Original file line number Diff line number Diff line change
@@ -200,8 +200,6 @@ func (f *FilecoinRPC) Initialize() error {
return err
}

// TODO: how do we subscribe to pending transactions from the full node?

go func() {
for {
select {
@@ -244,6 +242,23 @@ func (f *FilecoinRPC) InitializeMempool(addrDescForOutpoint bchain.AddrDescForOu

f.mempoolInitialized = true

mempoolChan, err := f.fullNode.MpoolSub(context.Background())
if err != nil {
return err
}

go func() {
for {
select {
case tx := <-mempoolChan:
f.Mempool.AddTransactionToMempool(tx.Message.Message.Cid().String())
f.pushHandler(bchain.NotificationNewTx)
case <-f.shutdown:
return
}
}
}()

return nil
}

@@ -341,7 +356,7 @@ func (f *FilecoinRPC) GetBlockHash(height uint32) (string, error) {
return "", nil
}
// This call is very expensive. Only do for less than 6000 from tip.
if uint32(tipSet.Height()) - height < 6000 {
if int32(tipSet.Height()) - int32(height) < 6000 {
tipSet, err := f.fullNode.ChainGetTipSetByHeight(context.Background(), abi.ChainEpoch(height), types.EmptyTSK)
if err != nil {
fmt.Println("^^^2", err)
@@ -363,7 +378,7 @@ func (f *FilecoinRPC) GetBlockHash(height uint32) (string, error) {
}
return hex.EncodeToString(hashTipsetKey(tipSet.Key())), nil
}
fmt.Println("^^^3", ">6000")
fmt.Println("^^^3", ">6000", tipSet.Height(), height)
return "", fmt.Errorf("tipset not found for height %d", height)
}
return blockHash, nil
@@ -478,6 +493,11 @@ func (f *FilecoinRPC) GetBlock(hash string, height uint32) (*bchain.Block, error
return nil, bchain.ErrBlockNotFound
}
height = header.Height
} else {
hash, err = f.GetBlockHash(height)
if err != nil {
glog.Warningf("Error querying for bock hash at height %d", height)
}
}
f.dbMtx.Lock()
err = f.db.View(func(tx *badger.Txn) error {